Realtime: documented noise_reduction: null is rejected by TypeScript

Open Beginner friendly
#3,195 2 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
68/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
node.js, typescript

Research direction

Start with src/resources/realtime/realtime.ts, where the issue identifies RealtimeAudioConfigInput.noise_reduction and its JSDoc, then trace the schema or generation projection mentioned in the report. Add a compile-time regression for RealtimeSessionCreateRequest using noise_reduction: null; done means the public request type accepts null while omission and the near_field and far_field values still compile.

Written by the indexing model from the issue text.

Description

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.

Dominant language
TypeScript
Stars
11.3k
Forks
1.6k
Avg merge
19h 41m
Merged PRs (30d)
110

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from openai/openai-node

All issues in openai/openai-node

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.