Realtime: documented noise_reduction: null is rejected by TypeScript

Aperta Adatta ai principianti
#3,195 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
68/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
node.js, typescript

Direzione di ricerca

Inizia da src/resources/realtime/realtime.ts, dove l’issue indica RealtimeAudioConfigInput.noise_reduction e il relativo JSDoc, poi segui lo schema o la proiezione di generazione menzionati nel report. Aggiungi una regressione in fase di compilazione per RealtimeSessionCreateRequest usando noise_reduction: null; il lavoro è completato quando il tipo pubblico della richiesta accetta null e continuano a compilare sia l’omissione sia i valori near_field e far_field.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Confirm this is a Node library issue and not an underlying OpenAI API issue
  • This is an issue with the Node library.
Describe the bug

The documented way to disable Realtime input noise reduction does not type-check with strict null checking:

audio: { input: { noise_reduction: null } }

This prevents a typed client.realtime.clientSecrets.create() call from expressing the documented off setting without a cast, suppression, or weakening null checking. Omitting the property, selecting near_field, and selecting far_field all compile in otherwise equivalent controls.

The mismatch is present in the published [email protected] artifact and in a fresh build of main at 93f5f1ca7420fe711ed559eca6405044199f5c50. This is a compile-time SDK contract report, not a claim about a new server failure or a runtime regression introduced by the latest documentation change.

To Reproduce
  1. In an empty directory, run:

    npm init -y
    npm install [email protected]
    npm install --save-dev [email protected] @types/[email protected]
    
  2. Save the code below as repro.cts and this configuration as tsconfig.json:

    {
      "compilerOptions": {
        "target": "ES2022",
        "module": "Node16",
        "moduleResolution": "Node16",
        "strict": true,
        "noEmit": true,
        "skipLibCheck": true,
        "types": []
      },
      "files": ["repro.cts"]
    }
    
  3. Run npx tsc --project tsconfig.json. Compilation fails on noise_reduction: null:

    error TS2322: Type 'null' is not assignable to type 'NoiseReduction | undefined'.
    

The same result occurs with TypeScript 6.0.3 and when the file is .mts. skipLibCheck only skips dependency declaration checking; the failing assignment in this consumer remains checked under strict: true. The compatible Node declaration dependency isolates this SDK check from newer Node declarations that older TypeScript cannot parse.

Code snippets
import OpenAI from 'openai';
import type { RealtimeSessionCreateRequest } from 'openai/resources/realtime/realtime';

declare const client: OpenAI;

const session: RealtimeSessionCreateRequest = {
  type: 'realtime',
  audio: { input: { noise_reduction: null } },
};

client.realtime.clientSecrets.create({ session });

This example is compile-only; it needs no API key and should not be executed as JavaScript.

Expected and actual behavior / root cause
  • Expected: the documented null off setting is representable by the public Realtime request type, while omission and valid object configurations remain supported.
  • Actual: generated RealtimeAudioConfigInput.noise_reduction is noise_reduction?: RealtimeAudioConfigInput.NoiseReduction, with no | null.
  • The JSDoc immediately above that member explicitly describes null as the off setting, both in 7.64.0 and after the clarification in #3192. That merged PR changes documentation, not the nullable type, so it does not resolve this compilation failure. The open release PR #3191 likewise contains the documentation changes rather than a nullable-type fix.

Please reconcile the schema/generation projection with the documented contract and add a compile-time regression for the public request. I have not hand-edited generated resources or proposed a runtime validation change.

Validation
Target TypeScript .cts / .mts with null Omitted / near-field / far-field controls
Actual npm 7.64.0 4.9.5 TS2322 Pass
Actual npm 7.64.0 6.0.3 TS2322 Pass
Main 93f5f1ca build 4.9.5 TS2322 Pass
Main 93f5f1ca build 6.0.3 TS2322 Pass

The released tarball was checked against its registry SHA512 integrity. Synthetic fetch checks on Node 22.0.0 and 24.19.0 preserve the explicit JSON null through the public client-secret endpoint; these checks do not establish live server acceptance or account access. No real API calls or sensitive data were used.

OS

Windows x64.

Node version

Node 24.19.0 for compiler/build validation; additional synthetic runtime checks on Node 22.0.0.

Library version

openai 7.64.0; also reproduced on main 93f5f1ca7420fe711ed559eca6405044199f5c50.

Lingua principale
TypeScript
Stelle
11.3k
Fork
1.6k
Merge medio
19h 41m
PR unite (30g)
110

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di openai/openai-node

Tutte le issue di openai/openai-node

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.