Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(deps): update dependency openai to v4.83.0 #242

Merged
merged 1 commit into from
Feb 12, 2025

Conversation

renovate[bot]
Copy link
Contributor

@renovate renovate bot commented Feb 12, 2025

This PR contains the following updates:

Package Change Age Adoption Passing Confidence
openai 4.79.4 -> 4.83.0 age adoption passing confidence

Release Notes

openai/openai-node (openai)

v4.83.0

Compare Source

Full Changelog: v4.82.0...v4.83.0

Features
Bug Fixes

v4.82.0

Compare Source

Full Changelog: v4.81.0...v4.82.0

Features
Bug Fixes
  • examples/realtime: remove duplicate session.update call (#​1293) (ad800b4)
  • types: correct metadata type + other fixes (378e2f7)

v4.81.0

Compare Source

Full Changelog: v4.80.1...v4.81.0

Features

v4.80.1

Compare Source

Full Changelog: v4.80.0...v4.80.1

Bug Fixes
  • azure: include retry count header (3e0ba40)
Documentation

v4.80.0

Compare Source

Full Changelog: v4.79.4...v4.80.0

Features

Configuration

📅 Schedule: Branch creation - "* 0-12 * * 3" (UTC), Automerge - At any time (no schedule defined).

🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about this update again.


  • If you want to rebase/retry this PR, check this box

This PR was generated by Mend Renovate. View the repository job log.

Copy link

openai debug - [puLL-Merge] - openai/[email protected]

Diff
diff --git .release-please-manifest.json .release-please-manifest.json
index b1ab5c7b9..b2ee58e08 100644
--- .release-please-manifest.json
+++ .release-please-manifest.json
@@ -1,3 +1,3 @@
 {
-  ".": "4.79.4"
+  ".": "4.82.0"
 }
diff --git .stats.yml .stats.yml
index 9600edae3..e49b5c56e 100644
--- .stats.yml
+++ .stats.yml
@@ -1,2 +1,2 @@
 configured_endpoints: 69
-openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-b5b0e2c794b012919701c3fd43286af10fa25d33ceb8a881bec2636028f446e0.yml
+openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-6204952a29973265b9c0d66fc67ffaf53c6a90ae4d75cdacf9d147676f5274c9.yml
diff --git CHANGELOG.md CHANGELOG.md
index 4254a9b8f..7565cb01a 100644
--- CHANGELOG.md
+++ CHANGELOG.md
@@ -1,5 +1,50 @@
 # Changelog
 
+## 4.82.0 (2025-01-31)
+
+Full Changelog: [v4.81.0...v4.82.0](https://github.com/openai/openai-node/compare/v4.81.0...v4.82.0)
+
+### Features
+
+* **api:** add o3-mini ([#1295](https://github.com/openai/openai-node/issues/1295)) ([378e2f7](https://github.com/openai/openai-node/commit/378e2f7af62c570adb4c7644a4d49576b698de41))
+
+
+### Bug Fixes
+
+* **examples/realtime:** remove duplicate `session.update` call ([#1293](https://github.com/openai/openai-node/issues/1293)) ([ad800b4](https://github.com/openai/openai-node/commit/ad800b4f9410c6838994c24a3386ea708717f72b))
+* **types:** correct metadata type + other fixes ([378e2f7](https://github.com/openai/openai-node/commit/378e2f7af62c570adb4c7644a4d49576b698de41))
+
+## 4.81.0 (2025-01-29)
+
+Full Changelog: [v4.80.1...v4.81.0](https://github.com/openai/openai-node/compare/v4.80.1...v4.81.0)
+
+### Features
+
+* **azure:** Realtime API support ([#1287](https://github.com/openai/openai-node/issues/1287)) ([fe090c0](https://github.com/openai/openai-node/commit/fe090c0a57570217eb0b431e2cce40bf61de2b75))
+
+## 4.80.1 (2025-01-24)
+
+Full Changelog: [v4.80.0...v4.80.1](https://github.com/openai/openai-node/compare/v4.80.0...v4.80.1)
+
+### Bug Fixes
+
+* **azure:** include retry count header ([3e0ba40](https://github.com/openai/openai-node/commit/3e0ba409e57ce276fb1f95cd11c801e4ccaad572))
+
+
+### Documentation
+
+* fix typo, "zodFunctionTool" -> "zodFunction" ([#1128](https://github.com/openai/openai-node/issues/1128)) ([b7ab6bb](https://github.com/openai/openai-node/commit/b7ab6bb304973ade94830f37eb646e800226d5ef))
+* **helpers:** fix type annotation ([fc019df](https://github.com/openai/openai-node/commit/fc019df1d9cc276e8f8e689742853a09aa94991a))
+* **readme:** fix realtime errors docs link ([#1286](https://github.com/openai/openai-node/issues/1286)) ([d1d50c8](https://github.com/openai/openai-node/commit/d1d50c897c18cefea964e8057fe1acfd766ae2bf))
+
+## 4.80.0 (2025-01-22)
+
+Full Changelog: [v4.79.4...v4.80.0](https://github.com/openai/openai-node/compare/v4.79.4...v4.80.0)
+
+### Features
+
+* **api:** update enum values, comments, and examples ([#1280](https://github.com/openai/openai-node/issues/1280)) ([d38f2c2](https://github.com/openai/openai-node/commit/d38f2c2648b6990f217c3c7d83ca31f3739641d3))
+
 ## 4.79.4 (2025-01-21)
 
 Full Changelog: [v4.79.3...v4.79.4](https://github.com/openai/openai-node/compare/v4.79.3...v4.79.4)
diff --git README.md README.md
index 3bd386e99..a1f4bf760 100644
--- README.md
+++ README.md
@@ -157,7 +157,7 @@ A full example can be found [here](https://github.com/openai/openai-node/blob/ma
 
 ### Realtime error handling
 
-When an error is encountered, either on the client side or returned from the server through the [`error` event](https://platform.openai.com/docs/guides/realtime/realtime-api-beta#handling-errors), the `error` event listener will be fired. However, if you haven't registered an `error` event listener then an `unhandled Promise rejection` error will be thrown.
+When an error is encountered, either on the client side or returned from the server through the [`error` event](https://platform.openai.com/docs/guides/realtime-model-capabilities#error-handling), the `error` event listener will be fired. However, if you haven't registered an `error` event listener then an `unhandled Promise rejection` error will be thrown.
 
 It is **highly recommended** that you register an `error` event listener and handle errors approriately as typically the underlying connection is still usable.
 
@@ -499,7 +499,7 @@ const credential = new DefaultAzureCredential();
 const scope = 'https://cognitiveservices.azure.com/.default';
 const azureADTokenProvider = getBearerTokenProvider(credential, scope);
 
-const openai = new AzureOpenAI({ azureADTokenProvider });
+const openai = new AzureOpenAI({ azureADTokenProvider, apiVersion: "<The API version, e.g. 2024-10-01-preview>" });
 
 const result = await openai.chat.completions.create({
   model: 'gpt-4o',
@@ -509,6 +509,26 @@ const result = await openai.chat.completions.create({
 console.log(result.choices[0]!.message?.content);
 \`\`\`
 
+### Realtime API
+This SDK provides real-time streaming capabilities for Azure OpenAI through the `OpenAIRealtimeWS` and `OpenAIRealtimeWebSocket` clients described previously.
+
+To utilize the real-time features, begin by creating a fully configured `AzureOpenAI` client and passing it into either `OpenAIRealtimeWS.azure` or `OpenAIRealtimeWebSocket.azure`. For example:
+
+```ts
+const cred = new DefaultAzureCredential();
+const scope = 'https://cognitiveservices.azure.com/.default';
+const deploymentName = 'gpt-4o-realtime-preview-1001';
+const azureADTokenProvider = getBearerTokenProvider(cred, scope);
+const client = new AzureOpenAI({
+  azureADTokenProvider,
+  apiVersion: '2024-10-01-preview',
+  deployment: deploymentName,
+});
+const rt = await OpenAIRealtimeWS.azure(client);
+```
+
+Once the instance has been created, you can then begin sending requests and receiving streaming responses in real time.
+
 ### Retries
 
 Certain errors will be automatically retried 2 times by default, with a short exponential backoff.
diff --git api.md api.md
index 33ab95ef6..516188b20 100644
--- api.md
+++ api.md
@@ -5,6 +5,7 @@ Types:
 - <code><a href="./src/resources/shared.ts">ErrorObject</a></code>
 - <code><a href="./src/resources/shared.ts">FunctionDefinition</a></code>
 - <code><a href="./src/resources/shared.ts">FunctionParameters</a></code>
+- <code><a href="./src/resources/shared.ts">Metadata</a></code>
 - <code><a href="./src/resources/shared.ts">ResponseFormatJSONObject</a></code>
 - <code><a href="./src/resources/shared.ts">ResponseFormatJSONSchema</a></code>
 - <code><a href="./src/resources/shared.ts">ResponseFormatText</a></code>
diff --git examples/azure.ts examples/azure/chat.ts
similarity index 91%
rename from examples/azure.ts
rename to examples/azure/chat.ts
index 5fe1718fa..46df820f8 100755
--- examples/azure.ts
+++ examples/azure/chat.ts
@@ -2,6 +2,7 @@
 
 import { AzureOpenAI } from 'openai';
 import { getBearerTokenProvider, DefaultAzureCredential } from '@azure/identity';
+import 'dotenv/config';
 
 // Corresponds to your Model deployment within your OpenAI resource, e.g. gpt-4-1106-preview
 // Navigate to the Azure OpenAI Studio to deploy a model.
@@ -13,7 +14,7 @@ const azureADTokenProvider = getBearerTokenProvider(credential, scope);
 
 // Make sure to set AZURE_OPENAI_ENDPOINT with the endpoint of your Azure resource.
 // You can find it in the Azure Portal.
-const openai = new AzureOpenAI({ azureADTokenProvider });
+const openai = new AzureOpenAI({ azureADTokenProvider, apiVersion: '2024-10-01-preview' });
 
 async function main() {
   console.log('Non-streaming:');
diff --git a/examples/azure/realtime/websocket.ts b/examples/azure/realtime/websocket.ts
new file mode 100644
index 000000000..bec74e654
--- /dev/null
+++ examples/azure/realtime/websocket.ts
@@ -0,0 +1,60 @@
+import { OpenAIRealtimeWebSocket } from 'openai/beta/realtime/websocket';
+import { AzureOpenAI } from 'openai';
+import { DefaultAzureCredential, getBearerTokenProvider } from '@azure/identity';
+import 'dotenv/config';
+
+async function main() {
+  const cred = new DefaultAzureCredential();
+  const scope = 'https://cognitiveservices.azure.com/.default';
+  const deploymentName = 'gpt-4o-realtime-preview-1001';
+  const azureADTokenProvider = getBearerTokenProvider(cred, scope);
+  const client = new AzureOpenAI({
+    azureADTokenProvider,
+    apiVersion: '2024-10-01-preview',
+    deployment: deploymentName,
+  });
+  const rt = await OpenAIRealtimeWebSocket.azure(client);
+
+  // access the underlying `ws.WebSocket` instance
+  rt.socket.addEventListener('open', () => {
+    console.log('Connection opened!');
+    rt.send({
+      type: 'session.update',
+      session: {
+        modalities: ['text'],
+        model: 'gpt-4o-realtime-preview',
+      },
+    });
+
+    rt.send({
+      type: 'conversation.item.create',
+      item: {
+        type: 'message',
+        role: 'user',
+        content: [{ type: 'input_text', text: 'Say a couple paragraphs!' }],
+      },
+    });
+
+    rt.send({ type: 'response.create' });
+  });
+
+  rt.on('error', (err) => {
+    // in a real world scenario this should be logged somewhere as you
+    // likely want to continue procesing events regardless of any errors
+    throw err;
+  });
+
+  rt.on('session.created', (event) => {
+    console.log('session created!', event.session);
+    console.log();
+  });
+
+  rt.on('response.text.delta', (event) => process.stdout.write(event.delta));
+  rt.on('response.text.done', () => console.log());
+
+  rt.on('response.done', () => rt.close());
+
+  rt.socket.addEventListener('close', () => console.log('\nConnection closed!'));
+}
+
+main();
diff --git a/examples/azure/realtime/ws.ts b/examples/azure/realtime/ws.ts
new file mode 100644
index 000000000..6ab7b742a
--- /dev/null
+++ examples/azure/realtime/ws.ts
@@ -0,0 +1,60 @@
+import { DefaultAzureCredential, getBearerTokenProvider } from '@azure/identity';
+import { OpenAIRealtimeWS } from 'openai/beta/realtime/ws';
+import { AzureOpenAI } from 'openai';
+import 'dotenv/config';
+
+async function main() {
+  const cred = new DefaultAzureCredential();
+  const scope = 'https://cognitiveservices.azure.com/.default';
+  const deploymentName = 'gpt-4o-realtime-preview-1001';
+  const azureADTokenProvider = getBearerTokenProvider(cred, scope);
+  const client = new AzureOpenAI({
+    azureADTokenProvider,
+    apiVersion: '2024-10-01-preview',
+    deployment: deploymentName,
+  });
+  const rt = await OpenAIRealtimeWS.azure(client);
+
+  // access the underlying `ws.WebSocket` instance
+  rt.socket.on('open', () => {
+    console.log('Connection opened!');
+    rt.send({
+      type: 'session.update',
+      session: {
+        modalities: ['text'],
+        model: 'gpt-4o-realtime-preview',
+      },
+    });
+
+    rt.send({
+      type: 'conversation.item.create',
+      item: {
+        type: 'message',
+        role: 'user',
+        content: [{ type: 'input_text', text: 'Say a couple paragraphs!' }],
+      },
+    });
+
+    rt.send({ type: 'response.create' });
+  });
+
+  rt.on('error', (err) => {
+    // in a real world scenario this should be logged somewhere as you
+    // likely want to continue procesing events regardless of any errors
+    throw err;
+  });
+
+  rt.on('session.created', (event) => {
+    console.log('session created!', event.session);
+    console.log();
+  });
+
+  rt.on('response.text.delta', (event) => process.stdout.write(event.delta));
+  rt.on('response.text.done', () => console.log());
+
+  rt.on('response.done', () => rt.close());
+
+  rt.socket.on('close', () => console.log('\nConnection closed!'));
+}
+
+main();
diff --git examples/package.json examples/package.json
index b8c34ac45..70ec2c523 100644
--- examples/package.json
+++ examples/package.json
@@ -7,6 +7,7 @@
   "private": true,
   "dependencies": {
     "@azure/identity": "^4.2.0",
+    "dotenv": "^16.4.7",
     "express": "^4.18.2",
     "next": "^14.1.1",
     "openai": "file:..",
diff --git examples/realtime/ws.ts examples/realtime/ws.ts
index 4bbe85e5d..08c6fbcb6 100644
--- examples/realtime/ws.ts
+++ examples/realtime/ws.ts
@@ -6,13 +6,6 @@ async function main() {
   // access the underlying `ws.WebSocket` instance
   rt.socket.on('open', () => {
     console.log('Connection opened!');
-    rt.send({
-      type: 'session.update',
-      session: {
-        modalities: ['foo'] as any,
-        model: 'gpt-4o-realtime-preview',
-      },
-    });
     rt.send({
       type: 'session.update',
       session: {
diff --git helpers.md helpers.md
index abf980c82..16bc1f277 100644
--- helpers.md
+++ helpers.md
@@ -49,7 +49,7 @@ if (message?.parsed) {
 
 The `.parse()` method will also automatically parse `function` tool calls if:
 
-- You use the `zodFunctionTool()` helper method
+- You use the `zodFunction()` helper method
 - You mark your tool schema with `"strict": True`
 
 For example:
@@ -226,7 +226,7 @@ on in the documentation page [Message](https://platform.openai.com/docs/api-refe
 
 ```ts
 .on('textCreated', (content: Text) => ...)
-.on('textDelta', (delta: RunStepDelta, snapshot: Text) => ...)
+.on('textDelta', (delta: TextDelta, snapshot: Text) => ...)
 .on('textDone', (content: Text, snapshot: Message) => ...)

diff --git jsr.json jsr.json
index e6d772116..7569332ce 100644
--- jsr.json
+++ jsr.json
@@ -1,6 +1,6 @@
{
"name": "@openai/openai",

  • "version": "4.79.4",
  • "version": "4.82.0",
    "exports": {
    ".": "./index.ts",
    "./helpers/zod": "./helpers/zod.ts",
    diff --git package.json package.json
    index d7a5555e5..42e00822d 100644
    --- package.json
    +++ package.json
    @@ -1,6 +1,6 @@
    {
    "name": "openai",
  • "version": "4.79.4",
  • "version": "4.82.0",
    "description": "The official TypeScript library for the OpenAI API",
    "author": "OpenAI [email protected]",
    "types": "dist/index.d.ts",
    diff --git src/beta/realtime/internal-base.ts src/beta/realtime/internal-base.ts
    index 391d69911..b704812ee 100644
    --- src/beta/realtime/internal-base.ts
    +++ src/beta/realtime/internal-base.ts
    @@ -1,6 +1,7 @@
    import { RealtimeClientEvent, RealtimeServerEvent, ErrorEvent } from '../../resources/beta/realtime/realtime';
    import { EventEmitter } from '../../lib/EventEmitter';
    import { OpenAIError } from '../../error';
    +import OpenAI, { AzureOpenAI } from '../../index';

export class OpenAIRealtimeError extends OpenAIError {
/**
@@ -73,11 +74,20 @@ export abstract class OpenAIRealtimeEmitter extends EventEmitter
}
}

-export function buildRealtimeURL(props: { baseURL: string; model: string }): URL {

  • const path = '/realtime';
    +export function isAzure(client: Pick<OpenAI, 'apiKey' | 'baseURL'>): client is AzureOpenAI {
  • return client instanceof AzureOpenAI;
    +}
  • const url = new URL(props.baseURL + (props.baseURL.endsWith('/') ? path.slice(1) : path));
    +export function buildRealtimeURL(client: Pick<OpenAI, 'apiKey' | 'baseURL'>, model: string): URL {
  • const path = '/realtime';
  • const baseURL = client.baseURL;
  • const url = new URL(baseURL + (baseURL.endsWith('/') ? path.slice(1) : path));
    url.protocol = 'wss';
  • url.searchParams.set('model', props.model);
  • if (isAzure(client)) {
  • url.searchParams.set('api-version', client.apiVersion);
  • url.searchParams.set('deployment', model);
  • } else {
  • url.searchParams.set('model', model);
  • }
    return url;
    }
    diff --git src/beta/realtime/websocket.ts src/beta/realtime/websocket.ts
    index e0853779d..349cf5760 100644
    --- src/beta/realtime/websocket.ts
    +++ src/beta/realtime/websocket.ts
    @@ -1,8 +1,8 @@
    -import { OpenAI } from '../../index';
    +import { AzureOpenAI, OpenAI } from '../../index';
    import { OpenAIError } from '../../error';
    import * as Core from '../../core';
    import type { RealtimeClientEvent, RealtimeServerEvent } from '../../resources/beta/realtime/realtime';
    -import { OpenAIRealtimeEmitter, buildRealtimeURL } from './internal-base';
    +import { OpenAIRealtimeEmitter, buildRealtimeURL, isAzure } from './internal-base';

interface MessageEvent {
data: string;
@@ -26,6 +26,11 @@ export class OpenAIRealtimeWebSocket extends OpenAIRealtimeEmitter {
props: {
model: string;
dangerouslyAllowBrowser?: boolean;

  •  /**
    
  •   * Callback to mutate the URL, needed for Azure.
    
  •   * @internal
    
  •   */
    
  •  onURL?: (url: URL) => void;
    

    },
    client?: Pick<OpenAI, 'apiKey' | 'baseURL'>,
    ) {
    @@ -44,11 +49,13 @@ export class OpenAIRealtimeWebSocket extends OpenAIRealtimeEmitter {

    client ??= new OpenAI({ dangerouslyAllowBrowser });

  • this.url = buildRealtimeURL({ baseURL: client.baseURL, model: props.model });
  • this.url = buildRealtimeURL(client, props.model);
  • props.onURL?.(this.url);
  • // @ts-ignore
    this.socket = new WebSocket(this.url, [
    'realtime',
  •  `openai-insecure-api-key.${client.apiKey}`,
    
  •  ...(isAzure(client) ? [] : [`openai-insecure-api-key.${client.apiKey}`]),
     'openai-beta.realtime-v1',
    
    ]);

@@ -77,6 +84,45 @@ export class OpenAIRealtimeWebSocket extends OpenAIRealtimeEmitter {
this.socket.addEventListener('error', (event: any) => {
this._onError(null, event.message, null);
});
+

  • if (isAzure(client)) {
  •  if (this.url.searchParams.get('Authorization') !== null) {
    
  •    this.url.searchParams.set('Authorization', '<REDACTED>');
    
  •  } else {
    
  •    this.url.searchParams.set('api-key', '<REDACTED>');
    
  •  }
    
  • }
  • }
  • static async azure(
  • client: AzureOpenAI,
  • options: { deploymentName?: string; dangerouslyAllowBrowser?: boolean } = {},
  • ): Promise {
  • const token = await client._getAzureADToken();
  • function onURL(url: URL) {
  •  if (client.apiKey !== '<Missing Key>') {
    
  •    url.searchParams.set('api-key', client.apiKey);
    
  •  } else {
    
  •    if (token) {
    
  •      url.searchParams.set('Authorization', `Bearer ${token}`);
    
  •    } else {
    
  •      throw new Error('AzureOpenAI is not instantiated correctly. No API key or token provided.');
    
  •    }
    
  •  }
    
  • }
  • const deploymentName = options.deploymentName ?? client.deploymentName;
  • if (!deploymentName) {
  •  throw new Error('No deployment name provided');
    
  • }
  • const { dangerouslyAllowBrowser } = options;
  • return new OpenAIRealtimeWebSocket(
  •  {
    
  •    model: deploymentName,
    
  •    onURL,
    
  •    ...(dangerouslyAllowBrowser ? { dangerouslyAllowBrowser } : {}),
    
  •  },
    
  •  client,
    
  • );
    }

send(event: RealtimeClientEvent) {
diff --git src/beta/realtime/ws.ts src/beta/realtime/ws.ts
index 631a36cd2..51339089c 100644
--- src/beta/realtime/ws.ts
+++ src/beta/realtime/ws.ts
@@ -1,7 +1,7 @@
import * as WS from 'ws';
-import { OpenAI } from '../../index';
+import { AzureOpenAI, OpenAI } from '../../index';
import type { RealtimeClientEvent, RealtimeServerEvent } from '../../resources/beta/realtime/realtime';
-import { OpenAIRealtimeEmitter, buildRealtimeURL } from './internal-base';
+import { OpenAIRealtimeEmitter, buildRealtimeURL, isAzure } from './internal-base';

export class OpenAIRealtimeWS extends OpenAIRealtimeEmitter {
url: URL;
@@ -14,12 +14,12 @@ export class OpenAIRealtimeWS extends OpenAIRealtimeEmitter {
super();
client ??= new OpenAI();

  • this.url = buildRealtimeURL({ baseURL: client.baseURL, model: props.model });
  • this.url = buildRealtimeURL(client, props.model);
    this.socket = new WS.WebSocket(this.url, {
    ...props.options,
    headers: {
    ...props.options?.headers,
  •    Authorization: `Bearer ${client.apiKey}`,
    
  •    ...(isAzure(client) ? {} : { Authorization: `Bearer ${client.apiKey}` }),
       'OpenAI-Beta': 'realtime=v1',
     },
    

    });
    @@ -51,6 +51,20 @@ export class OpenAIRealtimeWS extends OpenAIRealtimeEmitter {
    });
    }

  • static async azure(

  • client: AzureOpenAI,

  • options: { deploymentName?: string; options?: WS.ClientOptions | undefined } = {},

  • ): Promise {

  • const deploymentName = options.deploymentName ?? client.deploymentName;

  • if (!deploymentName) {

  •  throw new Error('No deployment name provided');
    
  • }

  • return new OpenAIRealtimeWS(

  •  { model: deploymentName, options: { headers: await getAzureHeaders(client) } },
    
  •  client,
    
  • );

  • }

  • send(event: RealtimeClientEvent) {
    try {
    this.socket.send(JSON.stringify(event));
    @@ -67,3 +81,16 @@ export class OpenAIRealtimeWS extends OpenAIRealtimeEmitter {
    }
    }
    }

+async function getAzureHeaders(client: AzureOpenAI) {

  • if (client.apiKey !== '') {
  • return { 'api-key': client.apiKey };
  • } else {
  • const token = await client._getAzureADToken();
  • if (token) {
  •  return { Authorization: `Bearer ${token}` };
    
  • } else {
  •  throw new Error('AzureOpenAI is not instantiated correctly. No API key or token provided.');
    
  • }
  • }
    +}
    diff --git src/index.ts src/index.ts
    index cf6aa89e3..f860579d3 100644
    --- src/index.ts
    +++ src/index.ts
    @@ -451,6 +451,7 @@ export declare namespace OpenAI {
    export type ErrorObject = API.ErrorObject;
    export type FunctionDefinition = API.FunctionDefinition;
    export type FunctionParameters = API.FunctionParameters;
  • export type Metadata = API.Metadata;
    export type ResponseFormatJSONObject = API.ResponseFormatJSONObject;
    export type ResponseFormatJSONSchema = API.ResponseFormatJSONSchema;
    export type ResponseFormatText = API.ResponseFormatText;
    @@ -491,7 +492,7 @@ export interface AzureClientOptions extends ClientOptions {
    /** API Client for interfacing with the Azure OpenAI API. */
    export class AzureOpenAI extends OpenAI {
    private _azureADTokenProvider: (() => Promise) | undefined;
  • private _deployment: string | undefined;
  • deploymentName: string | undefined;
    apiVersion: string = '';
    /**

    • API Client for interfacing with the Azure OpenAI API.
      @@ -574,10 +575,13 @@ export class AzureOpenAI extends OpenAI {

    this._azureADTokenProvider = azureADTokenProvider;
    this.apiVersion = apiVersion;

  • this._deployment = deployment;
  • this.deploymentName = deployment;
    }
  • override buildRequest(options: Core.FinalRequestOptions): {
  • override buildRequest(
  • options: Core.FinalRequestOptions,
  • props: { retryCount?: number } = {},
  • ): {
    req: RequestInit;
    url: string;
    timeout: number;
    @@ -586,15 +590,15 @@ export class AzureOpenAI extends OpenAI {
    if (!Core.isObj(options.body)) {
    throw new Error('Expected request body to be an object');
    }
  •  const model = this._deployment || options.body['model'];
    
  •  const model = this.deploymentName || options.body['model'];
     if (model !== undefined && !this.baseURL.includes('/deployments')) {
       options.path = `/deployments/${model}${options.path}`;
     }
    
    }
  • return super.buildRequest(options);
  • return super.buildRequest(options, props);
    }
  • private async _getAzureADToken(): Promise<string | undefined> {
  • async _getAzureADToken(): Promise<string | undefined> {
    if (typeof this._azureADTokenProvider === 'function') {
    const token = await this._azureADTokenProvider();
    if (!token || typeof token !== 'string') {
    diff --git src/resources/audio/speech.ts src/resources/audio/speech.ts
    index bd2ed9f65..35e82c4c1 100644
    --- src/resources/audio/speech.ts
    +++ src/resources/audio/speech.ts
    @@ -33,12 +33,12 @@ export interface SpeechCreateParams {
    model: (string & {}) | SpeechModel;

    /**

    • The voice to use when generating the audio. Supported voices are alloy,
    • echo, fable, onyx, nova, and shimmer. Previews of the voices are
    • available in the
    • The voice to use when generating the audio. Supported voices are alloy, ash,
    • coral, echo, fable, onyx, nova, sage and shimmer. Previews of the
  • voice: 'alloy' | 'echo' | 'fable' | 'onyx' | 'nova' | 'shimmer';
  • voice: 'alloy' | 'ash' | 'coral' | 'echo' | 'fable' | 'onyx' | 'nova' | 'sage' | 'shimmer';

    /**

    • The format to audio in. Supported formats are mp3, opus, aac, flac,
      diff --git src/resources/audio/transcriptions.ts src/resources/audio/transcriptions.ts
      index 0b6da4620..6d0a07e1e 100644
      --- src/resources/audio/transcriptions.ts
      +++ src/resources/audio/transcriptions.ts
      @@ -166,8 +166,8 @@ export interface TranscriptionCreateParams<

    /**

    • The language of the input audio. Supplying the input language in
    • improve accuracy and latency.
    • format will improve accuracy and latency.
      */
      language?: string;

diff --git src/resources/batches.ts src/resources/batches.ts
index ec5ca6331..aadda83a6 100644
--- src/resources/batches.ts
+++ src/resources/batches.ts
@@ -4,6 +4,7 @@ import { APIResource } from '../resource';
import { isRequestOptions } from '../core';
import * as Core from '../core';
import * as BatchesAPI from './batches';
+import * as Shared from './shared';
import { CursorPage, type CursorPageParams } from '../pagination';

export class Batches extends APIResource {
@@ -138,11 +139,13 @@ export interface Batch {

/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful

    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;

    /**

    • The ID of the file containing the outputs of successfully executed requests.
      @@ -237,9 +240,14 @@ export interface BatchCreateParams {
      input_file_id: string;

    /**

    • Optional custom metadata for the batch.
    • Set of 16 key-value pairs that can be attached to an object. This can be useful
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata?: Record<string, string> | null;
  • metadata?: Shared.Metadata | null;
    }

export interface BatchListParams extends CursorPageParams {}
diff --git src/resources/beta/assistants.ts src/resources/beta/assistants.ts
index 0e657b1d4..69a5db520 100644
--- src/resources/beta/assistants.ts
+++ src/resources/beta/assistants.ts
@@ -111,11 +111,13 @@ export interface Assistant {

/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful

    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata: unknown | null;
  • metadata: Shared.Metadata | null;

    /**

    • ID of the model to use. You can use the
      @@ -1118,11 +1120,13 @@ export interface AssistantCreateParams {

    /**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;

    /**

    • The name of the assistant. The maximum length is 256 characters.
      @@ -1242,12 +1246,14 @@ export namespace AssistantCreateParams {
      file_ids?: Array;

      /**

  •     * Set of 16 key-value pairs that can be attached to a vector store. This can be
    
  •     * useful for storing additional information about the vector store in a structured
    
  •     * format. Keys can be a maximum of 64 characters long and values can be a maxium
    
  •     * of 512 characters long.
    
  •     * Set of 16 key-value pairs that can be attached to an object. This can be useful
    
  •     * for storing additional information about the object in a structured format, and
    
  •     * querying for objects via API or the dashboard.
    
  •     *
    
  •     * Keys are strings with a maximum length of 64 characters. Values are strings with
    
  •     * a maximum length of 512 characters.
        */
    
  •    metadata?: unknown;
    
  •    metadata?: Shared.Metadata | null;
     }
    

    }
    }
    @@ -1267,11 +1273,13 @@ export interface AssistantUpdateParams {

    /**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;

    /**

    • ID of the model to use. You can use the
      diff --git src/resources/beta/realtime/realtime.ts src/resources/beta/realtime/realtime.ts
      index 5de06917a..c666221e1 100644
      --- src/resources/beta/realtime/realtime.ts
      +++ src/resources/beta/realtime/realtime.ts
      @@ -2,6 +2,7 @@

import { APIResource } from '../../../resource';
import * as RealtimeAPI from './realtime';
+import * as Shared from '../../shared';
import * as SessionsAPI from './sessions';
import {
Session as SessionsAPISession,
@@ -173,9 +174,10 @@ export interface ConversationItemCreateEvent {

/**
* The ID of the preceding item after which the new item will be inserted. If not

    • set, the new item will be appended to the end of the conversation. If set, it
    • allows an item to be inserted mid-conversation. If the ID cannot be found, an
    • error will be returned and the item will not be added.
    • set, the new item will be appended to the end of the conversation. If set to
    • root, the new item will be added to the beginning of the conversation. If set
    • to an existing ID, it allows an item to be inserted mid-conversation. If the ID
    • cannot be found, an error will be returned and the item will not be added.
      */
      previous_item_id?: string;
      }
      @@ -740,9 +742,38 @@ export interface RealtimeResponse {
      id?: string;

/**

    • Developer-provided string key-value pairs associated with this response.
    • Which conversation the response is added to, determined by the conversation
    • field in the response.create event. If auto, the response will be added to
    • the default conversation and the value of conversation_id will be an id like
    • conv_1234. If none, the response will not be added to any conversation and
    • the value of conversation_id will be null. If responses are being triggered
    • by server VAD, the response will be added to the default conversation, thus the
    • conversation_id will be an id like conv_1234.
      */
  • metadata?: unknown | null;
  • conversation_id?: string;

  • /**

    • Maximum number of output tokens for a single assistant response, inclusive of
    • tool calls, that was used in this response.
  • */

  • max_output_tokens?: number | 'inf';

  • /**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
  • */

  • metadata?: Shared.Metadata | null;

  • /**

    • The set of modalities the model used to respond. If there are multiple
    • modalities, the model will pick one, for example if modalities is
    • ["text", "audio"], the model could be responding in either text or audio.
  • */

  • modalities?: Array<'text' | 'audio'>;

    /**

    • The object type, must be realtime.response.
      @@ -754,6 +785,11 @@ export interface RealtimeResponse {
      */
      output?: Array;
  • /**

    • The format of output audio. Options are pcm16, g711_ulaw, or g711_alaw.
  • */

  • output_audio_format?: 'pcm16' | 'g711_ulaw' | 'g711_alaw';

  • /**

    • The final status of the response (completed, cancelled, failed, or
    • incomplete).
      @@ -765,6 +801,11 @@ export interface RealtimeResponse {
      */
      status_details?: RealtimeResponseStatus;
  • /**

    • Sampling temperature for the model, limited to [0.6, 1.2]. Defaults to 0.8.
  • */

  • temperature?: number;

  • /**

    • Usage statistics for the Response, this will correspond to billing. A Realtime
    • API session will maintain a conversation context and append new Items to the
      @@ -772,6 +813,12 @@ export interface RealtimeResponse {
    • become the input for later turns.
      */
      usage?: RealtimeResponseUsage;
  • /**

    • The voice the model used to respond. Current voice options are alloy, ash,
    • ballad, coral, echo sage, shimmer and verse.
  • */

  • voice?: 'alloy' | 'ash' | 'ballad' | 'coral' | 'echo' | 'sage' | 'shimmer' | 'verse';
    }

/**
@@ -1319,11 +1366,13 @@ export namespace ResponseCreateEvent {

 /**
  * Set of 16 key-value pairs that can be attached to an object. This can be useful
  • * for storing additional information about the object in a structured format. Keys
    
  • * can be a maximum of 64 characters long and values can be a maximum of 512
    
  • * characters long.
    
  • * for storing additional information about the object in a structured format, and
    
  • * querying for objects via API or the dashboard.
    
  • *
    
  • * Keys are strings with a maximum length of 64 characters. Values are strings with
    
  • * a maximum length of 512 characters.
    */
    
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;

    /**

    • The set of modalities the model can respond with. To disable audio, set this to
      @@ -1705,17 +1754,9 @@ export namespace SessionUpdateEvent {
      /
      export interface Session {
      /
      *
  • * The Realtime model used for this session.
    
  • */
    
  • model:
  •  | 'gpt-4o-realtime-preview'
    
  •  | 'gpt-4o-realtime-preview-2024-10-01'
    
  •  | 'gpt-4o-realtime-preview-2024-12-17'
    
  •  | 'gpt-4o-mini-realtime-preview'
    
  •  | 'gpt-4o-mini-realtime-preview-2024-12-17';
    
  • /**
  • * The format of input audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`.
    
  • * The format of input audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`. For
    
  • * `pcm16`, input audio must be 16-bit PCM at a 24kHz sample rate, single channel
    
  • * (mono), and little-endian byte order.
    */
    
    input_audio_format?: 'pcm16' | 'g711_ulaw' | 'g711_alaw';

@@ -1723,8 +1764,11 @@ export namespace SessionUpdateEvent {
* Configuration for input audio transcription, defaults to off and can be set to
* null to turn off once on. Input audio transcription is not native to the
* model, since the model consumes audio directly. Transcription runs

  • * asynchronously through Whisper and should be treated as rough guidance rather
    
  • * than the representation understood by the model.
    
  • * asynchronously through
    
  • * [OpenAI Whisper transcription](https://platform.openai.com/docs/api-reference/audio/createTranscription)
    
  • * and should be treated as rough guidance rather than the representation
    
  • * understood by the model. The client can optionally set the language and prompt
    
  • * for transcription, these fields will be passed to the Whisper API.
    */
    
    input_audio_transcription?: Session.InputAudioTranscription;

@@ -1756,8 +1800,19 @@ export namespace SessionUpdateEvent {
*/
modalities?: Array<'text' | 'audio'>;

  • /**
  • * The Realtime model used for this session.
    
  • */
    
  • model?:
  •  | 'gpt-4o-realtime-preview'
    
  •  | 'gpt-4o-realtime-preview-2024-10-01'
    
  •  | 'gpt-4o-realtime-preview-2024-12-17'
    
  •  | 'gpt-4o-mini-realtime-preview'
    
  •  | 'gpt-4o-mini-realtime-preview-2024-12-17';
    
  • /**
    * The format of output audio. Options are pcm16, g711_ulaw, or g711_alaw.
  • * For `pcm16`, output audio is sampled at a rate of 24kHz.
    */
    
    output_audio_format?: 'pcm16' | 'g711_ulaw' | 'g711_alaw';

@@ -1797,15 +1852,33 @@ export namespace SessionUpdateEvent {
* Configuration for input audio transcription, defaults to off and can be set to
* null to turn off once on. Input audio transcription is not native to the
* model, since the model consumes audio directly. Transcription runs

  • * asynchronously through Whisper and should be treated as rough guidance rather
    
  • * than the representation understood by the model.
    
  • * asynchronously through
    
  • * [OpenAI Whisper transcription](https://platform.openai.com/docs/api-reference/audio/createTranscription)
    
  • * and should be treated as rough guidance rather than the representation
    
  • * understood by the model. The client can optionally set the language and prompt
    
  • * for transcription, these fields will be passed to the Whisper API.
    */
    

    export interface InputAudioTranscription {

  •  /**
    
  •   * The language of the input audio. Supplying the input language in
    
  •   * [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. `en`)
    
  •   * format will improve accuracy and latency.
    
  •   */
    
  •  language?: string;
    
  •  /**
      * The model to use for transcription, `whisper-1` is the only currently supported
      * model.
      */
     model?: string;
    
  •  /**
    
  •   * An optional text to guide the model's style or continue a previous audio
    
  •   * segment. The
    
  •   * [prompt](https://platform.openai.com/docs/guides/speech-to-text#prompting)
    
  •   * should match the audio language.
    
  •   */
    
  •  prompt?: string;
    

    }

    export interface Tool {
    diff --git src/resources/beta/realtime/sessions.ts src/resources/beta/realtime/sessions.ts
    index c1082d236..d2afa25b1 100644
    --- src/resources/beta/realtime/sessions.ts
    +++ src/resources/beta/realtime/sessions.ts
    @@ -32,7 +32,9 @@ export interface Session {
    id?: string;

    /**

    • The format of input audio. Options are pcm16, g711_ulaw, or g711_alaw.
    • The format of input audio. Options are pcm16, g711_ulaw, or g711_alaw. For
    • pcm16, input audio must be 16-bit PCM at a 24kHz sample rate, single channel
    • (mono), and little-endian byte order.
      */
      input_audio_format?: 'pcm16' | 'g711_ulaw' | 'g711_alaw';

@@ -86,6 +88,7 @@ export interface Session {

/**
* The format of output audio. Options are pcm16, g711_ulaw, or g711_alaw.

    • For pcm16, output audio is sampled at a rate of 24kHz.
      */
      output_audio_format?: 'pcm16' | 'g711_ulaw' | 'g711_alaw';

@@ -200,7 +203,7 @@ export interface SessionCreateResponse {
/**
* Ephemeral key returned by the API.
*/

  • client_secret?: SessionCreateResponse.ClientSecret;
  • client_secret: SessionCreateResponse.ClientSecret;

    /**

    • The format of input audio. Options are pcm16, g711_ulaw, or g711_alaw.
      @@ -289,14 +292,14 @@ export namespace SessionCreateResponse {
      • Timestamp for when the token expires. Currently, all tokens expire after one
      • minute.
        */
  • expires_at?: number;
  • expires_at: number;

    /**

    • Ephemeral key usable in client environments to authenticate connections to the
    • Realtime API. Use this in client-side environments rather than a standard API
    • token, which should only be used server-side.
      */
  • value?: string;
  • value: string;
    }

/**
@@ -372,17 +375,9 @@ export namespace SessionCreateResponse {

export interface SessionCreateParams {
/**

    • The Realtime model used for this session.
  • */
  • model:
  • | 'gpt-4o-realtime-preview'
  • | 'gpt-4o-realtime-preview-2024-10-01'
  • | 'gpt-4o-realtime-preview-2024-12-17'
  • | 'gpt-4o-mini-realtime-preview'
  • | 'gpt-4o-mini-realtime-preview-2024-12-17';
  • /**
    • The format of input audio. Options are pcm16, g711_ulaw, or g711_alaw.
    • The format of input audio. Options are pcm16, g711_ulaw, or g711_alaw. For
    • pcm16, input audio must be 16-bit PCM at a 24kHz sample rate, single channel
    • (mono), and little-endian byte order.
      */
      input_audio_format?: 'pcm16' | 'g711_ulaw' | 'g711_alaw';

@@ -390,8 +385,11 @@ export interface SessionCreateParams {
* Configuration for input audio transcription, defaults to off and can be set to
* null to turn off once on. Input audio transcription is not native to the
* model, since the model consumes audio directly. Transcription runs

    • asynchronously through Whisper and should be treated as rough guidance rather
    • than the representation understood by the model.
    • asynchronously through
    • and should be treated as rough guidance rather than the representation
    • understood by the model. The client can optionally set the language and prompt
    • for transcription, these fields will be passed to the Whisper API.
      */
      input_audio_transcription?: SessionCreateParams.InputAudioTranscription;

@@ -423,8 +421,19 @@ export interface SessionCreateParams {
*/
modalities?: Array<'text' | 'audio'>;

  • /**
    • The Realtime model used for this session.
  • */
  • model?:
  • | 'gpt-4o-realtime-preview'
  • | 'gpt-4o-realtime-preview-2024-10-01'
  • | 'gpt-4o-realtime-preview-2024-12-17'
  • | 'gpt-4o-mini-realtime-preview'
  • | 'gpt-4o-mini-realtime-preview-2024-12-17';
  • /**
    • The format of output audio. Options are pcm16, g711_ulaw, or g711_alaw.
    • For pcm16, output audio is sampled at a rate of 24kHz.
      */
      output_audio_format?: 'pcm16' | 'g711_ulaw' | 'g711_alaw';

@@ -464,15 +473,33 @@ export namespace SessionCreateParams {
* Configuration for input audio transcription, defaults to off and can be set to
* null to turn off once on. Input audio transcription is not native to the
* model, since the model consumes audio directly. Transcription runs

    • asynchronously through Whisper and should be treated as rough guidance rather
    • than the representation understood by the model.
    • asynchronously through
    • and should be treated as rough guidance rather than the representation
    • understood by the model. The client can optionally set the language and prompt
    • for transcription, these fields will be passed to the Whisper API.
      */
      export interface InputAudioTranscription {
  • /**
  • * The language of the input audio. Supplying the input language in
    
  • * [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. `en`)
    
  • * format will improve accuracy and latency.
    
  • */
    
  • language?: string;
  • /**
    * The model to use for transcription, whisper-1 is the only currently supported
    * model.
    */
    model?: string;
  • /**
  • * An optional text to guide the model's style or continue a previous audio
    
  • * segment. The
    
  • * [prompt](https://platform.openai.com/docs/guides/speech-to-text#prompting)
    
  • * should match the audio language.
    
  • */
    
  • prompt?: string;
    }

export interface Tool {
diff --git src/resources/beta/threads/messages.ts src/resources/beta/threads/messages.ts
index 8124f56cd..29fd2b29f 100644
--- src/resources/beta/threads/messages.ts
+++ src/resources/beta/threads/messages.ts
@@ -3,6 +3,7 @@
import { APIResource } from '../../../resource';
import { isRequestOptions } from '../../../core';
import * as Core from '../../../core';
+import * as Shared from '../../shared';
import * as AssistantsAPI from '../assistants';
import { CursorPage, type CursorPageParams } from '../../../pagination';

@@ -407,11 +408,13 @@ export interface Message {

/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful

    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata: unknown | null;
  • metadata: Shared.Metadata | null;

    /**

    • The object type, which is always thread.message.
      @@ -660,11 +663,13 @@ export interface MessageCreateParams {

    /**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;
    }

export namespace MessageCreateParams {
@@ -693,11 +698,13 @@ export namespace MessageCreateParams {
export interface MessageUpdateParams {
/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful

    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;
    }

export interface MessageListParams extends CursorPageParams {
diff --git src/resources/beta/threads/runs/runs.ts src/resources/beta/threads/runs/runs.ts
index 814ad3e89..84ba7b63c 100644
--- src/resources/beta/threads/runs/runs.ts
+++ src/resources/beta/threads/runs/runs.ts
@@ -8,6 +8,7 @@ import { AssistantStream, RunCreateParamsBaseStream } from '../../../../lib/Assi
import { sleep } from '../../../../core';
import { RunSubmitToolOutputsParamsStream } from '../../../../lib/AssistantStream';
import * as RunsAPI from './runs';
+import * as Shared from '../../../shared';
import * as AssistantsAPI from '../../assistants';
import * as ChatAPI from '../../../chat/chat';
import * as MessagesAPI from '../messages';
@@ -415,11 +416,13 @@ export interface Run {

/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful

    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata: unknown | null;
  • metadata: Shared.Metadata | null;

    /**

    • The model that the
      @@ -705,10 +708,12 @@ export interface RunCreateParamsBase {
      /**
    • Body param: Set of 16 key-value pairs that can be attached to an object. This
    • can be useful for storing additional information about the object in a
    • structured format. Keys can be a maximum of 64 characters long and values can be
    • a maxium of 512 characters long.
    • structured format, and querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;

    /**

    • Body param: The ID of the
      @@ -823,11 +828,13 @@ export namespace RunCreateParams {

    /**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
  • * for storing additional information about the object in a structured format. Keys
    
  • * can be a maximum of 64 characters long and values can be a maxium of 512
    
  • * characters long.
    
  • * for storing additional information about the object in a structured format, and
    
  • * querying for objects via API or the dashboard.
    
  • *
    
  • * Keys are strings with a maximum length of 64 characters. Values are strings with
    
  • * a maximum length of 512 characters.
    */
    
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;
    }

export namespace AdditionalMessage {
@@ -898,11 +905,13 @@ export interface RunCreateParamsStreaming extends RunCreateParamsBase {
export interface RunUpdateParams {
/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful

    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;
    }

export interface RunListParams extends CursorPageParams {
diff --git src/resources/beta/threads/runs/steps.ts src/resources/beta/threads/runs/steps.ts
index 6c6722b62..c491b4e83 100644
--- src/resources/beta/threads/runs/steps.ts
+++ src/resources/beta/threads/runs/steps.ts
@@ -4,6 +4,7 @@ import { APIResource } from '../../../../resource';
import { isRequestOptions } from '../../../../core';
import * as Core from '../../../../core';
import * as StepsAPI from './steps';
+import * as Shared from '../../../shared';
import { CursorPage, type CursorPageParams } from '../../../../pagination';

export class Steps extends APIResource {
@@ -515,11 +516,13 @@ export interface RunStep {

/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful

    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata: unknown | null;
  • metadata: Shared.Metadata | null;

    /**

    • The object type, which is always thread.run.step.
      diff --git src/resources/beta/threads/threads.ts src/resources/beta/threads/threads.ts
      index 453d8fa10..3f69c6e60 100644
      --- src/resources/beta/threads/threads.ts
      +++ src/resources/beta/threads/threads.ts
      @@ -250,11 +250,13 @@ export interface Thread {

    /**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata: unknown | null;
  • metadata: Shared.Metadata | null;

    /**

    • The object type, which is always thread.
      @@ -322,11 +324,13 @@ export interface ThreadCreateParams {

    /**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;

    /**

    • A set of resources that are made available to the assistant's tools in this
      @@ -361,11 +365,13 @@ export namespace ThreadCreateParams {

    /**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
  • * for storing additional information about the object in a structured format. Keys
    
  • * can be a maximum of 64 characters long and values can be a maxium of 512
    
  • * characters long.
    
  • * for storing additional information about the object in a structured format, and
    
  • * querying for objects via API or the dashboard.
    
  • *
    
  • * Keys are strings with a maximum length of 64 characters. Values are strings with
    
  • * a maximum length of 512 characters.
    */
    
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;
    }

export namespace Message {
@@ -447,12 +453,14 @@ export namespace ThreadCreateParams {
file_ids?: Array;

     /**
  •     * Set of 16 key-value pairs that can be attached to a vector store. This can be
    
  •     * useful for storing additional information about the vector store in a structured
    
  •     * format. Keys can be a maximum of 64 characters long and values can be a maxium
    
  •     * of 512 characters long.
    
  •     * Set of 16 key-value pairs that can be attached to an object. This can be useful
    
  •     * for storing additional information about the object in a structured format, and
    
  •     * querying for objects via API or the dashboard.
    
  •     *
    
  •     * Keys are strings with a maximum length of 64 characters. Values are strings with
    
  •     * a maximum length of 512 characters.
        */
    
  •    metadata?: unknown;
    
  •    metadata?: Shared.Metadata | null;
     }
    
    }
    }
    @@ -461,11 +469,13 @@ export namespace ThreadCreateParams {
    export interface ThreadUpdateParams {
    /**
    • Set of 16 key-value pairs that can be attached to an object. This can be useful
    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;

    /**

    • A set of resources that are made available to the assistant's tools in this
      @@ -549,11 +559,13 @@ export interface ThreadCreateAndRunParamsBase {

    /**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;

    /**

    • The ID of the Model to
      @@ -609,7 +621,8 @@ export interface ThreadCreateAndRunParamsBase {
      temperature?: number | null;

    /**

    • If no thread is provided, an empty thread will be created.
    • Options to create a new thread. If no thread is provided when running a request,
    • an empty thread will be created.
      */
      thread?: ThreadCreateAndRunParams.Thread;

@@ -658,7 +671,8 @@ export interface ThreadCreateAndRunParamsBase {

export namespace ThreadCreateAndRunParams {
/**

    • If no thread is provided, an empty thread will be created.
    • Options to create a new thread. If no thread is provided when running a request,
    • an empty thread will be created.
      /
      export interface Thread {
      /
      *
      @@ -669,11 +683,13 @@ export namespace ThreadCreateAndRunParams {

    /**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
  • * for storing additional information about the object in a structured format. Keys
    
  • * can be a maximum of 64 characters long and values can be a maxium of 512
    
  • * characters long.
    
  • * for storing additional information about the object in a structured format, and
    
  • * querying for objects via API or the dashboard.
    
  • *
    
  • * Keys are strings with a maximum length of 64 characters. Values are strings with
    
  • * a maximum length of 512 characters.
    */
    
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;

    /**

    • A set of resources that are made available to the assistant's tools in this
      @@ -708,11 +724,13 @@ export namespace ThreadCreateAndRunParams {

    /**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
  •   * for storing additional information about the object in a structured format. Keys
    
  •   * can be a maximum of 64 characters long and values can be a maxium of 512
    
  •   * characters long.
    
  •   * for storing additional information about the object in a structured format, and
    
  •   * querying for objects via API or the dashboard.
    
  •   *
    
  •   * Keys are strings with a maximum length of 64 characters. Values are strings with
    
  •   * a maximum length of 512 characters.
      */
    
  •  metadata?: unknown | null;
    
  •  metadata?: Shared.Metadata | null;
    

    }

    export namespace Message {
    @@ -794,12 +812,14 @@ export namespace ThreadCreateAndRunParams {
    file_ids?: Array;

         /**
    
  •       * Set of 16 key-value pairs that can be attached to a vector store. This can be
    
  •       * useful for storing additional information about the vector store in a structured
    
  •       * format. Keys can be a maximum of 64 characters long and values can be a maxium
    
  •       * of 512 characters long.
    
  •       * Set of 16 key-value pairs that can be attached to an object. This can be useful
    
  •       * for storing additional information about the object in a structured format, and
    
  •       * querying for objects via API or the dashboard.
    
  •       *
    
  •       * Keys are strings with a maximum length of 64 characters. Values are strings with
    
  •       * a maximum length of 512 characters.
          */
    
  •      metadata?: unknown;
    
  •      metadata?: Shared.Metadata | null;
       }
     }
    

    }
    diff --git src/resources/beta/vector-stores/vector-stores.ts src/resources/beta/vector-stores/vector-stores.ts
    index cbff2d562..8438b79da 100644
    --- src/resources/beta/vector-stores/vector-stores.ts
    +++ src/resources/beta/vector-stores/vector-stores.ts
    @@ -3,6 +3,7 @@
    import { APIResource } from '../../../resource';
    import { isRequestOptions } from '../../../core';
    import * as Core from '../../../core';
    +import * as Shared from '../../shared';
    import * as FileBatchesAPI from './file-batches';
    import {
    FileBatchCreateParams,
    @@ -187,11 +188,13 @@ export interface VectorStore {

    /**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata: unknown | null;
  • metadata: Shared.Metadata | null;

    /**

    • The name of the vector store.
      @@ -300,11 +303,13 @@ export interface VectorStoreCreateParams {

    /**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;

    /**

    • The name of the vector store.
      @@ -338,11 +343,13 @@ export interface VectorStoreUpdateParams {

    /**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;

    /**

    • The name of the vector store.
      diff --git src/resources/chat/chat.ts src/resources/chat/chat.ts
      index 2230b19bd..d4a18929c 100644
      --- src/resources/chat/chat.ts
      +++ src/resources/chat/chat.ts
      @@ -46,6 +46,8 @@ export class Chat extends APIResource {
      }

export type ChatModel =

  • | 'o3-mini'

  • | 'o3-mini-2025-01-31'
    | 'o1'
    | 'o1-2024-12-17'
    | 'o1-preview'
    diff --git src/resources/chat/completions.ts src/resources/chat/completions.ts
    index 88c778036..d2de11458 100644
    --- src/resources/chat/completions.ts
    +++ src/resources/chat/completions.ts
    @@ -76,8 +76,7 @@ export interface ChatCompletion {
    object: 'chat.completion';

    /**

    • The service tier used for processing the request. This field is only included if
    • the service_tier parameter is specified in the request.
    • The service tier used for processing the request.
      */
      service_tier?: 'scale' | 'default' | null;

@@ -300,8 +299,7 @@ export interface ChatCompletionChunk {
object: 'chat.completion.chunk';

/**

    • The service tier used for processing the request. This field is only included if
    • the service_tier parameter is specified in the request.
    • The service tier used for processing the request.
      */
      service_tier?: 'scale' | 'default' | null;

@@ -1014,10 +1012,14 @@ export interface ChatCompletionCreateParamsBase {
max_tokens?: number | null;

/**

    • Developer-defined tags and values used for filtering completions in the
    • Set of 16 key-value pairs that can be attached to an object. This can be useful
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum ,length of 512 characters.
      */
  • metadata?: Record<string, string> | null;
  • metadata?: Shared.Metadata | null;

    /**

    • Output types that you would like the model to generate for this request. Most
      @@ -1111,13 +1113,10 @@ export interface ChatCompletionCreateParamsBase {
    • utilize scale tier credits until they are exhausted.
      • If set to 'auto', and the Project is not Scale tier enabled, the request will
    • be processed using the default service tier with a lower uptime SLA and no
    • latency guarentee.
    • latency guarantee.
      • If set to 'default', the request will be processed using the default service
    • tier with a lower uptime SLA and no latency guarentee.
    • tier with a lower uptime SLA and no latency guarantee.
      • When not set, the default behavior is 'auto'.
    • When this parameter is set, the response body will include the service_tier
    • utilized.
      */
      service_tier?: 'auto' | 'default' | null;

diff --git src/resources/embeddings.ts src/resources/embeddings.ts
index 4b1644a68..d01ffc807 100644
--- src/resources/embeddings.ts
+++ src/resources/embeddings.ts
@@ -86,7 +86,8 @@ export interface EmbeddingCreateParams {
* text-embedding-ada-002), cannot be an empty string, and any array must be 2048
* dimensions or less.
* Example Python code

    • for counting tokens.
    • for counting tokens. Some models may also impose a limit on total number of
    • tokens summed across inputs.
      */
      input: string | Array | Array | Array<Array>;

diff --git src/resources/shared.ts src/resources/shared.ts
index f44fda8a7..3bb11582f 100644
--- src/resources/shared.ts
+++ src/resources/shared.ts
@@ -55,6 +55,16 @@ export interface FunctionDefinition {
*/
export type FunctionParameters = Record<string, unknown>;

+/**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
  • */
    +export type Metadata = Record<string, string>;

export interface ResponseFormatJSONObject {
/**
* The type of response format being defined: json_object
diff --git src/resources/uploads/uploads.ts src/resources/uploads/uploads.ts
index 8491d0fe2..bfe752cd7 100644
--- src/resources/uploads/uploads.ts
+++ src/resources/uploads/uploads.ts
@@ -113,7 +113,7 @@ export interface Upload {
status: 'pending' | 'completed' | 'cancelled' | 'expired';

/**

    • The ready File object after the Upload is completed.
    • The File object represents a document that has been uploaded to OpenAI.
      */
      file?: FilesAPI.FileObject | null;
      }
      diff --git src/version.ts src/version.ts
      index e8b9601ed..07241a8cf 100644
      --- src/version.ts
      +++ src/version.ts
      @@ -1 +1 @@
      -export const VERSION = '4.79.4'; // x-release-please-version
      +export const VERSION = '4.82.0'; // x-release-please-version
      diff --git tests/api-resources/beta/assistants.test.ts tests/api-resources/beta/assistants.test.ts
      index a64465c77..88a10ba8f 100644
      --- tests/api-resources/beta/assistants.test.ts
      +++ tests/api-resources/beta/assistants.test.ts
      @@ -25,7 +25,7 @@ describe('resource assistants', () => {
      model: 'gpt-4o',
      description: 'description',
      instructions: 'instructions',
  •  metadata: {},
    
  •  metadata: { foo: 'string' },
     name: 'name',
     response_format: 'auto',
     temperature: 1,
    

@@ -33,7 +33,9 @@ describe('resource assistants', () => {
code_interpreter: { file_ids: ['string'] },
file_search: {
vector_store_ids: ['string'],

  •      vector_stores: [{ chunking_strategy: { type: 'auto' }, file_ids: ['string'], metadata: {} }],
    
  •      vector_stores: [
    
  •        { chunking_strategy: { type: 'auto' }, file_ids: ['string'], metadata: { foo: 'string' } },
    
  •      ],
       },
     },
     tools: [{ type: 'code_interpreter' }],
    

diff --git tests/api-resources/beta/realtime/sessions.test.ts tests/api-resources/beta/realtime/sessions.test.ts
index 0ed998c27..dbb92ead3 100644
--- tests/api-resources/beta/realtime/sessions.test.ts
+++ tests/api-resources/beta/realtime/sessions.test.ts
@@ -9,8 +9,8 @@ const client = new OpenAI({
});

describe('resource sessions', () => {

  • test('create: only required params', async () => {
  • const responsePromise = client.beta.realtime.sessions.create({ model: 'gpt-4o-realtime-preview' });
  • test('create', async () => {
  • const responsePromise = client.beta.realtime.sessions.create({});
    const rawResponse = await responsePromise.asResponse();
    expect(rawResponse).toBeInstanceOf(Response);
    const response = await responsePromise;
    @@ -19,27 +19,4 @@ describe('resource sessions', () => {
    expect(dataAndResponse.data).toBe(response);
    expect(dataAndResponse.response).toBe(rawResponse);
    });
  • test('create: required and optional params', async () => {
  • const response = await client.beta.realtime.sessions.create({
  •  model: 'gpt-4o-realtime-preview',
    
  •  input_audio_format: 'pcm16',
    
  •  input_audio_transcription: { model: 'model' },
    
  •  instructions: 'instructions',
    
  •  max_response_output_tokens: 0,
    
  •  modalities: ['text'],
    
  •  output_audio_format: 'pcm16',
    
  •  temperature: 0,
    
  •  tool_choice: 'tool_choice',
    
  •  tools: [{ description: 'description', name: 'name', parameters: {}, type: 'function' }],
    
  •  turn_detection: {
    
  •    create_response: true,
    
  •    prefix_padding_ms: 0,
    
  •    silence_duration_ms: 0,
    
  •    threshold: 0,
    
  •    type: 'type',
    
  •  },
    
  •  voice: 'alloy',
    
  • });
  • });
    });
    diff --git tests/api-resources/beta/threads/messages.test.ts tests/api-resources/beta/threads/messages.test.ts
    index c1f5f7b6e..e125edd84 100644
    --- tests/api-resources/beta/threads/messages.test.ts
    +++ tests/api-resources/beta/threads/messages.test.ts
    @@ -28,7 +28,7 @@ describe('resource messages', () => {
    content: 'string',
    role: 'user',
    attachments: [{ file_id: 'file_id', tools: [{ type: 'code_interpreter' }] }],
  •  metadata: {},
    
  •  metadata: { foo: 'string' },
    
    });
    });

diff --git tests/api-resources/beta/threads/runs/runs.test.ts tests/api-resources/beta/threads/runs/runs.test.ts
index 4fd8261ac..9b728403f 100644
--- tests/api-resources/beta/threads/runs/runs.test.ts
+++ tests/api-resources/beta/threads/runs/runs.test.ts
@@ -30,13 +30,13 @@ describe('resource runs', () => {
content: 'string',
role: 'user',
attachments: [{ file_id: 'file_id', tools: [{ type: 'code_interpreter' }] }],

  •      metadata: {},
    
  •      metadata: { foo: 'string' },
       },
     ],
     instructions: 'instructions',
     max_completion_tokens: 256,
     max_prompt_tokens: 256,
    
  •  metadata: {},
    
  •  metadata: { foo: 'string' },
     model: 'gpt-4o',
     parallel_tool_calls: true,
     response_format: 'auto',
    

diff --git tests/api-resources/beta/threads/threads.test.ts tests/api-resources/beta/threads/threads.test.ts
index aba266316..f26d6ec44 100644
--- tests/api-resources/beta/threads/threads.test.ts
+++ tests/api-resources/beta/threads/threads.test.ts
@@ -37,15 +37,17 @@ describe('resource threads', () => {
content: 'string',
role: 'user',
attachments: [{ file_id: 'file_id', tools: [{ type: 'code_interpreter' }] }],

  •          metadata: {},
    
  •          metadata: { foo: 'string' },
           },
         ],
    
  •      metadata: {},
    
  •      metadata: { foo: 'string' },
         tool_resources: {
           code_interpreter: { file_ids: ['string'] },
           file_search: {
             vector_store_ids: ['string'],
    
  •          vector_stores: [{ chunking_strategy: { type: 'auto' }, file_ids: ['string'], metadata: {} }],
    
  •          vector_stores: [
    
  •            { chunking_strategy: { type: 'auto' }, file_ids: ['string'], metadata: { foo: 'string' } },
    
  •          ],
           },
         },
       },
    

@@ -118,7 +120,7 @@ describe('resource threads', () => {
instructions: 'instructions',
max_completion_tokens: 256,
max_prompt_tokens: 256,

  •  metadata: {},
    
  •  metadata: { foo: 'string' },
     model: 'gpt-4o',
     parallel_tool_calls: true,
     response_format: 'auto',
    

@@ -130,15 +132,17 @@ describe('resource threads', () => {
content: 'string',
role: 'user',
attachments: [{ file_id: 'file_id', tools: [{ type: 'code_interpreter' }] }],

  •        metadata: {},
    
  •        metadata: { foo: 'string' },
         },
       ],
    
  •    metadata: {},
    
  •    metadata: { foo: 'string' },
       tool_resources: {
         code_interpreter: { file_ids: ['string'] },
         file_search: {
           vector_store_ids: ['string'],
    
  •        vector_stores: [{ chunking_strategy: { type: 'auto' }, file_ids: ['string'], metadata: {} }],
    
  •        vector_stores: [
    
  •          { chunking_strategy: { type: 'auto' }, file_ids: ['string'], metadata: { foo: 'string' } },
    
  •        ],
         },
       },
     },
    

diff --git tests/api-resources/chat/completions.test.ts tests/api-resources/chat/completions.test.ts
index dfc09f69b..8f1bc7d4c 100644
--- tests/api-resources/chat/completions.test.ts
+++ tests/api-resources/chat/completions.test.ts
@@ -43,7 +43,7 @@ describe('resource completions', () => {
presence_penalty: -2,
reasoning_effort: 'low',
response_format: { type: 'text' },

  •  seed: -9007199254740991,
    
  •  seed: 0,
     service_tier: 'auto',
     stop: 'string',
     store: true,
    

diff --git tests/api-resources/completions.test.ts tests/api-resources/completions.test.ts
index 82322dc3a..c98501a87 100644
--- tests/api-resources/completions.test.ts
+++ tests/api-resources/completions.test.ts
@@ -32,7 +32,7 @@ describe('resource completions', () => {
max_tokens: 16,
n: 1,
presence_penalty: -2,

  •  seed: -9007199254740991,
    
  •  seed: 0,
     stop: '\n',
     stream: false,
     stream_options: { include_usage: true },
    

diff --git tests/lib/azure.test.ts tests/lib/azure.test.ts
index 064a0098c..0e3c2c5a3 100644
--- tests/lib/azure.test.ts
+++ tests/lib/azure.test.ts
@@ -51,6 +51,18 @@ describe('instantiate azure client', () => {
});
expect(req.headers as Headers).not.toHaveProperty('x-my-default-header');
});
+

  • test('includes retry count', () => {
  •  const { req } = client.buildRequest(
    
  •    {
    
  •      path: '/foo',
    
  •      method: 'post',
    
  •      headers: { 'X-My-Default-Header': null },
    
  •    },
    
  •    { retryCount: 1 },
    
  •  );
    
  •  expect((req.headers as Headers)['x-stainless-retry-count']).toEqual('1');
    
  • });
    });

describe('defaultQuery', () => {


</details>

### Description
This pull request includes several changes aimed at enhancing the SDK's compatibility with Azure's real-time streaming capabilities, expanding the voice options for text-to-speech, improving metadata handling, and fixing minor bugs related to session management and configuration. The updates primarily focus on enhancing the functionality of real-time APIs and Azure integration.

### Possible Issues
1. **Backward Compatibility**: The expansion of options and introduction of new features may impact existing implementations that rely on older configurations and defaults.
2. **Testing Coverage**: The tests for new functionalities like new voice options and updated metadata handling need to be thoroughly verified to ensure they cover all edge cases.

### Security Hotspots
There are no new security hotspots introduced in this pull request.

<details>
<summary><i>Changes</i></summary>

### Changes

#### Configurations and Documentation
- **`.release-please-manifest.json`**: Updated version from `4.79.4` to `4.82.0`.
- **`.stats.yml`**: Updated the `openapi_spec_url`.
- **`CHANGELOG.md`**: Added entries for versions `4.80.0` to `4.82.0`, detailing new features, bug fixes, and documentation improvements.
- **`README.md`**: Updated sections on real-time error handling and Azure client configuration examples including the addition of API version.

#### Real-time API Enhancements
- **New Real-time Examples**: Introduced examples for WebSocket and WS real-time integration under `examples/azure/realtime/`.
- **Expanded API Options**: Updated `src/beta/realtime/websocket.ts` and `src/beta/realtime/ws.ts` to include Azure-specific configurations and new URL query options.
- **Voice Options**: Expanded the supported voices in `src/resources/audio/speech.ts`.

#### Infrastructure Improvements
- **Metadata Handling**: Improved and standardized metadata handling across multiple files such as `src/resources/shared.ts`, `src/resources/batches.ts`, `src/resources/beta/assistants.ts`, etc.
- **Session Management**: Enhanced session attribute configurations, including input/output audio settings and transcription prompts in `src/resources/beta/realtime/sessions.ts`.

#### Bug Fixes
- **Test Fixes**: Corrected metadata types in unit tests, added missing parameters in some tests, and included retry count verification in `tests/lib/azure.test.ts`.
- **Documentation Fixes**: Rectified typos and updated links in various markdown files including `helpers.md`.



This pull request holistically enhances the SDK by introducing additional configuration options, particularly focusing on real-time capabilities with Azure. The improved metadata handling standardizes how data is attached across objects in the SDK, and the new examples provide practical implementations of these new features.```mermaid
sequenceDiagram
    participant User
    participant SDK
    participant Azure
    participant OpenAI
    
    User->>SDK: Configure AzureOpenAI Client
    SDK->>Azure: Retrieve Bearer Token
    Azure-->>SDK: Token Response
    User->>SDK: Initialize Real-time Session
    SDK->>OpenAI: Start Real-time Session
    OpenAI-->>SDK: Session Confirmation
    SDK->>User: Session Started
    User->>SDK: Send Real-time Data
    SDK->>OpenAI: Process Real-time Data
    OpenAI-->>SDK: Return Real-time Responses
    SDK->>User: Display Responses

Copy link

anthropic debug - [puLL-Merge] - openai/[email protected]

Diff
diff --git .release-please-manifest.json .release-please-manifest.json
index b1ab5c7b9..b2ee58e08 100644
--- .release-please-manifest.json
+++ .release-please-manifest.json
@@ -1,3 +1,3 @@
 {
-  ".": "4.79.4"
+  ".": "4.82.0"
 }
diff --git .stats.yml .stats.yml
index 9600edae3..e49b5c56e 100644
--- .stats.yml
+++ .stats.yml
@@ -1,2 +1,2 @@
 configured_endpoints: 69
-openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-b5b0e2c794b012919701c3fd43286af10fa25d33ceb8a881bec2636028f446e0.yml
+openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-6204952a29973265b9c0d66fc67ffaf53c6a90ae4d75cdacf9d147676f5274c9.yml
diff --git CHANGELOG.md CHANGELOG.md
index 4254a9b8f..7565cb01a 100644
--- CHANGELOG.md
+++ CHANGELOG.md
@@ -1,5 +1,50 @@
 # Changelog
 
+## 4.82.0 (2025-01-31)
+
+Full Changelog: [v4.81.0...v4.82.0](https://github.com/openai/openai-node/compare/v4.81.0...v4.82.0)
+
+### Features
+
+* **api:** add o3-mini ([#1295](https://github.com/openai/openai-node/issues/1295)) ([378e2f7](https://github.com/openai/openai-node/commit/378e2f7af62c570adb4c7644a4d49576b698de41))
+
+
+### Bug Fixes
+
+* **examples/realtime:** remove duplicate `session.update` call ([#1293](https://github.com/openai/openai-node/issues/1293)) ([ad800b4](https://github.com/openai/openai-node/commit/ad800b4f9410c6838994c24a3386ea708717f72b))
+* **types:** correct metadata type + other fixes ([378e2f7](https://github.com/openai/openai-node/commit/378e2f7af62c570adb4c7644a4d49576b698de41))
+
+## 4.81.0 (2025-01-29)
+
+Full Changelog: [v4.80.1...v4.81.0](https://github.com/openai/openai-node/compare/v4.80.1...v4.81.0)
+
+### Features
+
+* **azure:** Realtime API support ([#1287](https://github.com/openai/openai-node/issues/1287)) ([fe090c0](https://github.com/openai/openai-node/commit/fe090c0a57570217eb0b431e2cce40bf61de2b75))
+
+## 4.80.1 (2025-01-24)
+
+Full Changelog: [v4.80.0...v4.80.1](https://github.com/openai/openai-node/compare/v4.80.0...v4.80.1)
+
+### Bug Fixes
+
+* **azure:** include retry count header ([3e0ba40](https://github.com/openai/openai-node/commit/3e0ba409e57ce276fb1f95cd11c801e4ccaad572))
+
+
+### Documentation
+
+* fix typo, "zodFunctionTool" -&gt; "zodFunction" ([#1128](https://github.com/openai/openai-node/issues/1128)) ([b7ab6bb](https://github.com/openai/openai-node/commit/b7ab6bb304973ade94830f37eb646e800226d5ef))
+* **helpers:** fix type annotation ([fc019df](https://github.com/openai/openai-node/commit/fc019df1d9cc276e8f8e689742853a09aa94991a))
+* **readme:** fix realtime errors docs link ([#1286](https://github.com/openai/openai-node/issues/1286)) ([d1d50c8](https://github.com/openai/openai-node/commit/d1d50c897c18cefea964e8057fe1acfd766ae2bf))
+
+## 4.80.0 (2025-01-22)
+
+Full Changelog: [v4.79.4...v4.80.0](https://github.com/openai/openai-node/compare/v4.79.4...v4.80.0)
+
+### Features
+
+* **api:** update enum values, comments, and examples ([#1280](https://github.com/openai/openai-node/issues/1280)) ([d38f2c2](https://github.com/openai/openai-node/commit/d38f2c2648b6990f217c3c7d83ca31f3739641d3))
+
 ## 4.79.4 (2025-01-21)
 
 Full Changelog: [v4.79.3...v4.79.4](https://github.com/openai/openai-node/compare/v4.79.3...v4.79.4)
diff --git README.md README.md
index 3bd386e99..a1f4bf760 100644
--- README.md
+++ README.md
@@ -157,7 +157,7 @@ A full example can be found [here](https://github.com/openai/openai-node/blob/ma
 
 ### Realtime error handling
 
-When an error is encountered, either on the client side or returned from the server through the [`error` event](https://platform.openai.com/docs/guides/realtime/realtime-api-beta#handling-errors), the `error` event listener will be fired. However, if you haven't registered an `error` event listener then an `unhandled Promise rejection` error will be thrown.
+When an error is encountered, either on the client side or returned from the server through the [`error` event](https://platform.openai.com/docs/guides/realtime-model-capabilities#error-handling), the `error` event listener will be fired. However, if you haven't registered an `error` event listener then an `unhandled Promise rejection` error will be thrown.
 
 It is **highly recommended** that you register an `error` event listener and handle errors approriately as typically the underlying connection is still usable.
 
@@ -499,7 +499,7 @@ const credential = new DefaultAzureCredential();
 const scope = 'https://cognitiveservices.azure.com/.default';
 const azureADTokenProvider = getBearerTokenProvider(credential, scope);
 
-const openai = new AzureOpenAI({ azureADTokenProvider });
+const openai = new AzureOpenAI({ azureADTokenProvider, apiVersion: "<The API version, e.g. 2024-10-01-preview>" });
 
 const result = await openai.chat.completions.create({
   model: 'gpt-4o',
@@ -509,6 +509,26 @@ const result = await openai.chat.completions.create({
 console.log(result.choices[0]!.message?.content);
 \`\`\`
 
+### Realtime API
+This SDK provides real-time streaming capabilities for Azure OpenAI through the `OpenAIRealtimeWS` and `OpenAIRealtimeWebSocket` clients described previously.
+
+To utilize the real-time features, begin by creating a fully configured `AzureOpenAI` client and passing it into either `OpenAIRealtimeWS.azure` or `OpenAIRealtimeWebSocket.azure`. For example:
+
+```ts
+const cred = new DefaultAzureCredential();
+const scope = 'https://cognitiveservices.azure.com/.default';
+const deploymentName = 'gpt-4o-realtime-preview-1001';
+const azureADTokenProvider = getBearerTokenProvider(cred, scope);
+const client = new AzureOpenAI({
+  azureADTokenProvider,
+  apiVersion: '2024-10-01-preview',
+  deployment: deploymentName,
+});
+const rt = await OpenAIRealtimeWS.azure(client);
+```
+
+Once the instance has been created, you can then begin sending requests and receiving streaming responses in real time.
+
 ### Retries
 
 Certain errors will be automatically retried 2 times by default, with a short exponential backoff.
diff --git api.md api.md
index 33ab95ef6..516188b20 100644
--- api.md
+++ api.md
@@ -5,6 +5,7 @@ Types:
 - <code><a href="./src/resources/shared.ts">ErrorObject</a></code>
 - <code><a href="./src/resources/shared.ts">FunctionDefinition</a></code>
 - <code><a href="./src/resources/shared.ts">FunctionParameters</a></code>
+- <code><a href="./src/resources/shared.ts">Metadata</a></code>
 - <code><a href="./src/resources/shared.ts">ResponseFormatJSONObject</a></code>
 - <code><a href="./src/resources/shared.ts">ResponseFormatJSONSchema</a></code>
 - <code><a href="./src/resources/shared.ts">ResponseFormatText</a></code>
diff --git examples/azure.ts examples/azure/chat.ts
similarity index 91%
rename from examples/azure.ts
rename to examples/azure/chat.ts
index 5fe1718fa..46df820f8 100755
--- examples/azure.ts
+++ examples/azure/chat.ts
@@ -2,6 +2,7 @@
 
 import { AzureOpenAI } from 'openai';
 import { getBearerTokenProvider, DefaultAzureCredential } from '@azure/identity';
+import 'dotenv/config';
 
 // Corresponds to your Model deployment within your OpenAI resource, e.g. gpt-4-1106-preview
 // Navigate to the Azure OpenAI Studio to deploy a model.
@@ -13,7 +14,7 @@ const azureADTokenProvider = getBearerTokenProvider(credential, scope);
 
 // Make sure to set AZURE_OPENAI_ENDPOINT with the endpoint of your Azure resource.
 // You can find it in the Azure Portal.
-const openai = new AzureOpenAI({ azureADTokenProvider });
+const openai = new AzureOpenAI({ azureADTokenProvider, apiVersion: '2024-10-01-preview' });
 
 async function main() {
   console.log('Non-streaming:');
diff --git a/examples/azure/realtime/websocket.ts b/examples/azure/realtime/websocket.ts
new file mode 100644
index 000000000..bec74e654
--- /dev/null
+++ examples/azure/realtime/websocket.ts
@@ -0,0 +1,60 @@
+import { OpenAIRealtimeWebSocket } from 'openai/beta/realtime/websocket';
+import { AzureOpenAI } from 'openai';
+import { DefaultAzureCredential, getBearerTokenProvider } from '@azure/identity';
+import 'dotenv/config';
+
+async function main() {
+  const cred = new DefaultAzureCredential();
+  const scope = 'https://cognitiveservices.azure.com/.default';
+  const deploymentName = 'gpt-4o-realtime-preview-1001';
+  const azureADTokenProvider = getBearerTokenProvider(cred, scope);
+  const client = new AzureOpenAI({
+    azureADTokenProvider,
+    apiVersion: '2024-10-01-preview',
+    deployment: deploymentName,
+  });
+  const rt = await OpenAIRealtimeWebSocket.azure(client);
+
+  // access the underlying `ws.WebSocket` instance
+  rt.socket.addEventListener('open', () => {
+    console.log('Connection opened!');
+    rt.send({
+      type: 'session.update',
+      session: {
+        modalities: ['text'],
+        model: 'gpt-4o-realtime-preview',
+      },
+    });
+
+    rt.send({
+      type: 'conversation.item.create',
+      item: {
+        type: 'message',
+        role: 'user',
+        content: [{ type: 'input_text', text: 'Say a couple paragraphs!' }],
+      },
+    });
+
+    rt.send({ type: 'response.create' });
+  });
+
+  rt.on('error', (err) => {
+    // in a real world scenario this should be logged somewhere as you
+    // likely want to continue procesing events regardless of any errors
+    throw err;
+  });
+
+  rt.on('session.created', (event) => {
+    console.log('session created!', event.session);
+    console.log();
+  });
+
+  rt.on('response.text.delta', (event) => process.stdout.write(event.delta));
+  rt.on('response.text.done', () => console.log());
+
+  rt.on('response.done', () => rt.close());
+
+  rt.socket.addEventListener('close', () => console.log('\nConnection closed!'));
+}
+
+main();
diff --git a/examples/azure/realtime/ws.ts b/examples/azure/realtime/ws.ts
new file mode 100644
index 000000000..6ab7b742a
--- /dev/null
+++ examples/azure/realtime/ws.ts
@@ -0,0 +1,60 @@
+import { DefaultAzureCredential, getBearerTokenProvider } from '@azure/identity';
+import { OpenAIRealtimeWS } from 'openai/beta/realtime/ws';
+import { AzureOpenAI } from 'openai';
+import 'dotenv/config';
+
+async function main() {
+  const cred = new DefaultAzureCredential();
+  const scope = 'https://cognitiveservices.azure.com/.default';
+  const deploymentName = 'gpt-4o-realtime-preview-1001';
+  const azureADTokenProvider = getBearerTokenProvider(cred, scope);
+  const client = new AzureOpenAI({
+    azureADTokenProvider,
+    apiVersion: '2024-10-01-preview',
+    deployment: deploymentName,
+  });
+  const rt = await OpenAIRealtimeWS.azure(client);
+
+  // access the underlying `ws.WebSocket` instance
+  rt.socket.on('open', () => {
+    console.log('Connection opened!');
+    rt.send({
+      type: 'session.update',
+      session: {
+        modalities: ['text'],
+        model: 'gpt-4o-realtime-preview',
+      },
+    });
+
+    rt.send({
+      type: 'conversation.item.create',
+      item: {
+        type: 'message',
+        role: 'user',
+        content: [{ type: 'input_text', text: 'Say a couple paragraphs!' }],
+      },
+    });
+
+    rt.send({ type: 'response.create' });
+  });
+
+  rt.on('error', (err) => {
+    // in a real world scenario this should be logged somewhere as you
+    // likely want to continue procesing events regardless of any errors
+    throw err;
+  });
+
+  rt.on('session.created', (event) => {
+    console.log('session created!', event.session);
+    console.log();
+  });
+
+  rt.on('response.text.delta', (event) => process.stdout.write(event.delta));
+  rt.on('response.text.done', () => console.log());
+
+  rt.on('response.done', () => rt.close());
+
+  rt.socket.on('close', () => console.log('\nConnection closed!'));
+}
+
+main();
diff --git examples/package.json examples/package.json
index b8c34ac45..70ec2c523 100644
--- examples/package.json
+++ examples/package.json
@@ -7,6 +7,7 @@
   "private": true,
   "dependencies": {
     "@azure/identity": "^4.2.0",
+    "dotenv": "^16.4.7",
     "express": "^4.18.2",
     "next": "^14.1.1",
     "openai": "file:..",
diff --git examples/realtime/ws.ts examples/realtime/ws.ts
index 4bbe85e5d..08c6fbcb6 100644
--- examples/realtime/ws.ts
+++ examples/realtime/ws.ts
@@ -6,13 +6,6 @@ async function main() {
   // access the underlying `ws.WebSocket` instance
   rt.socket.on('open', () => {
     console.log('Connection opened!');
-    rt.send({
-      type: 'session.update',
-      session: {
-        modalities: ['foo'] as any,
-        model: 'gpt-4o-realtime-preview',
-      },
-    });
     rt.send({
       type: 'session.update',
       session: {
diff --git helpers.md helpers.md
index abf980c82..16bc1f277 100644
--- helpers.md
+++ helpers.md
@@ -49,7 +49,7 @@ if (message?.parsed) {
 
 The `.parse()` method will also automatically parse `function` tool calls if:
 
-- You use the `zodFunctionTool()` helper method
+- You use the `zodFunction()` helper method
 - You mark your tool schema with `"strict": True`
 
 For example:
@@ -226,7 +226,7 @@ on in the documentation page [Message](https://platform.openai.com/docs/api-refe
 
 ```ts
 .on('textCreated', (content: Text) => ...)
-.on('textDelta', (delta: RunStepDelta, snapshot: Text) => ...)
+.on('textDelta', (delta: TextDelta, snapshot: Text) => ...)
 .on('textDone', (content: Text, snapshot: Message) => ...)

diff --git jsr.json jsr.json
index e6d772116..7569332ce 100644
--- jsr.json
+++ jsr.json
@@ -1,6 +1,6 @@
{
"name": "@openai/openai",

  • "version": "4.79.4",
  • "version": "4.82.0",
    "exports": {
    ".": "./index.ts",
    "./helpers/zod": "./helpers/zod.ts",
    diff --git package.json package.json
    index d7a5555e5..42e00822d 100644
    --- package.json
    +++ package.json
    @@ -1,6 +1,6 @@
    {
    "name": "openai",
  • "version": "4.79.4",
  • "version": "4.82.0",
    "description": "The official TypeScript library for the OpenAI API",
    "author": "OpenAI [email protected]",
    "types": "dist/index.d.ts",
    diff --git src/beta/realtime/internal-base.ts src/beta/realtime/internal-base.ts
    index 391d69911..b704812ee 100644
    --- src/beta/realtime/internal-base.ts
    +++ src/beta/realtime/internal-base.ts
    @@ -1,6 +1,7 @@
    import { RealtimeClientEvent, RealtimeServerEvent, ErrorEvent } from '../../resources/beta/realtime/realtime';
    import { EventEmitter } from '../../lib/EventEmitter';
    import { OpenAIError } from '../../error';
    +import OpenAI, { AzureOpenAI } from '../../index';

export class OpenAIRealtimeError extends OpenAIError {
/**
@@ -73,11 +74,20 @@ export abstract class OpenAIRealtimeEmitter extends EventEmitter
}
}

-export function buildRealtimeURL(props: { baseURL: string; model: string }): URL {

  • const path = '/realtime';
    +export function isAzure(client: Pick<OpenAI, 'apiKey' | 'baseURL'>): client is AzureOpenAI {
  • return client instanceof AzureOpenAI;
    +}
  • const url = new URL(props.baseURL + (props.baseURL.endsWith('/') ? path.slice(1) : path));
    +export function buildRealtimeURL(client: Pick<OpenAI, 'apiKey' | 'baseURL'>, model: string): URL {
  • const path = '/realtime';
  • const baseURL = client.baseURL;
  • const url = new URL(baseURL + (baseURL.endsWith('/') ? path.slice(1) : path));
    url.protocol = 'wss';
  • url.searchParams.set('model', props.model);
  • if (isAzure(client)) {
  • url.searchParams.set('api-version', client.apiVersion);
  • url.searchParams.set('deployment', model);
  • } else {
  • url.searchParams.set('model', model);
  • }
    return url;
    }
    diff --git src/beta/realtime/websocket.ts src/beta/realtime/websocket.ts
    index e0853779d..349cf5760 100644
    --- src/beta/realtime/websocket.ts
    +++ src/beta/realtime/websocket.ts
    @@ -1,8 +1,8 @@
    -import { OpenAI } from '../../index';
    +import { AzureOpenAI, OpenAI } from '../../index';
    import { OpenAIError } from '../../error';
    import * as Core from '../../core';
    import type { RealtimeClientEvent, RealtimeServerEvent } from '../../resources/beta/realtime/realtime';
    -import { OpenAIRealtimeEmitter, buildRealtimeURL } from './internal-base';
    +import { OpenAIRealtimeEmitter, buildRealtimeURL, isAzure } from './internal-base';

interface MessageEvent {
data: string;
@@ -26,6 +26,11 @@ export class OpenAIRealtimeWebSocket extends OpenAIRealtimeEmitter {
props: {
model: string;
dangerouslyAllowBrowser?: boolean;

  •  /**
    
  •   * Callback to mutate the URL, needed for Azure.
    
  •   * @internal
    
  •   */
    
  •  onURL?: (url: URL) => void;
    

    },
    client?: Pick<OpenAI, 'apiKey' | 'baseURL'>,
    ) {
    @@ -44,11 +49,13 @@ export class OpenAIRealtimeWebSocket extends OpenAIRealtimeEmitter {

    client ??= new OpenAI({ dangerouslyAllowBrowser });

  • this.url = buildRealtimeURL({ baseURL: client.baseURL, model: props.model });
  • this.url = buildRealtimeURL(client, props.model);
  • props.onURL?.(this.url);
  • // @ts-ignore
    this.socket = new WebSocket(this.url, [
    'realtime',
  •  `openai-insecure-api-key.${client.apiKey}`,
    
  •  ...(isAzure(client) ? [] : [`openai-insecure-api-key.${client.apiKey}`]),
     'openai-beta.realtime-v1',
    
    ]);

@@ -77,6 +84,45 @@ export class OpenAIRealtimeWebSocket extends OpenAIRealtimeEmitter {
this.socket.addEventListener('error', (event: any) => {
this._onError(null, event.message, null);
});
+

  • if (isAzure(client)) {
  •  if (this.url.searchParams.get('Authorization') !== null) {
    
  •    this.url.searchParams.set('Authorization', '<REDACTED>');
    
  •  } else {
    
  •    this.url.searchParams.set('api-key', '<REDACTED>');
    
  •  }
    
  • }
  • }
  • static async azure(
  • client: AzureOpenAI,
  • options: { deploymentName?: string; dangerouslyAllowBrowser?: boolean } = {},
  • ): Promise {
  • const token = await client._getAzureADToken();
  • function onURL(url: URL) {
  •  if (client.apiKey !== '<Missing Key>') {
    
  •    url.searchParams.set('api-key', client.apiKey);
    
  •  } else {
    
  •    if (token) {
    
  •      url.searchParams.set('Authorization', `Bearer ${token}`);
    
  •    } else {
    
  •      throw new Error('AzureOpenAI is not instantiated correctly. No API key or token provided.');
    
  •    }
    
  •  }
    
  • }
  • const deploymentName = options.deploymentName ?? client.deploymentName;
  • if (!deploymentName) {
  •  throw new Error('No deployment name provided');
    
  • }
  • const { dangerouslyAllowBrowser } = options;
  • return new OpenAIRealtimeWebSocket(
  •  {
    
  •    model: deploymentName,
    
  •    onURL,
    
  •    ...(dangerouslyAllowBrowser ? { dangerouslyAllowBrowser } : {}),
    
  •  },
    
  •  client,
    
  • );
    }

send(event: RealtimeClientEvent) {
diff --git src/beta/realtime/ws.ts src/beta/realtime/ws.ts
index 631a36cd2..51339089c 100644
--- src/beta/realtime/ws.ts
+++ src/beta/realtime/ws.ts
@@ -1,7 +1,7 @@
import * as WS from 'ws';
-import { OpenAI } from '../../index';
+import { AzureOpenAI, OpenAI } from '../../index';
import type { RealtimeClientEvent, RealtimeServerEvent } from '../../resources/beta/realtime/realtime';
-import { OpenAIRealtimeEmitter, buildRealtimeURL } from './internal-base';
+import { OpenAIRealtimeEmitter, buildRealtimeURL, isAzure } from './internal-base';

export class OpenAIRealtimeWS extends OpenAIRealtimeEmitter {
url: URL;
@@ -14,12 +14,12 @@ export class OpenAIRealtimeWS extends OpenAIRealtimeEmitter {
super();
client ??= new OpenAI();

  • this.url = buildRealtimeURL({ baseURL: client.baseURL, model: props.model });
  • this.url = buildRealtimeURL(client, props.model);
    this.socket = new WS.WebSocket(this.url, {
    ...props.options,
    headers: {
    ...props.options?.headers,
  •    Authorization: `Bearer ${client.apiKey}`,
    
  •    ...(isAzure(client) ? {} : { Authorization: `Bearer ${client.apiKey}` }),
       'OpenAI-Beta': 'realtime=v1',
     },
    

    });
    @@ -51,6 +51,20 @@ export class OpenAIRealtimeWS extends OpenAIRealtimeEmitter {
    });
    }

  • static async azure(

  • client: AzureOpenAI,

  • options: { deploymentName?: string; options?: WS.ClientOptions | undefined } = {},

  • ): Promise {

  • const deploymentName = options.deploymentName ?? client.deploymentName;

  • if (!deploymentName) {

  •  throw new Error('No deployment name provided');
    
  • }

  • return new OpenAIRealtimeWS(

  •  { model: deploymentName, options: { headers: await getAzureHeaders(client) } },
    
  •  client,
    
  • );

  • }

  • send(event: RealtimeClientEvent) {
    try {
    this.socket.send(JSON.stringify(event));
    @@ -67,3 +81,16 @@ export class OpenAIRealtimeWS extends OpenAIRealtimeEmitter {
    }
    }
    }

+async function getAzureHeaders(client: AzureOpenAI) {

  • if (client.apiKey !== '') {
  • return { 'api-key': client.apiKey };
  • } else {
  • const token = await client._getAzureADToken();
  • if (token) {
  •  return { Authorization: `Bearer ${token}` };
    
  • } else {
  •  throw new Error('AzureOpenAI is not instantiated correctly. No API key or token provided.');
    
  • }
  • }
    +}
    diff --git src/index.ts src/index.ts
    index cf6aa89e3..f860579d3 100644
    --- src/index.ts
    +++ src/index.ts
    @@ -451,6 +451,7 @@ export declare namespace OpenAI {
    export type ErrorObject = API.ErrorObject;
    export type FunctionDefinition = API.FunctionDefinition;
    export type FunctionParameters = API.FunctionParameters;
  • export type Metadata = API.Metadata;
    export type ResponseFormatJSONObject = API.ResponseFormatJSONObject;
    export type ResponseFormatJSONSchema = API.ResponseFormatJSONSchema;
    export type ResponseFormatText = API.ResponseFormatText;
    @@ -491,7 +492,7 @@ export interface AzureClientOptions extends ClientOptions {
    /** API Client for interfacing with the Azure OpenAI API. */
    export class AzureOpenAI extends OpenAI {
    private _azureADTokenProvider: (() => Promise) | undefined;
  • private _deployment: string | undefined;
  • deploymentName: string | undefined;
    apiVersion: string = '';
    /**

    • API Client for interfacing with the Azure OpenAI API.
      @@ -574,10 +575,13 @@ export class AzureOpenAI extends OpenAI {

    this._azureADTokenProvider = azureADTokenProvider;
    this.apiVersion = apiVersion;

  • this._deployment = deployment;
  • this.deploymentName = deployment;
    }
  • override buildRequest(options: Core.FinalRequestOptions): {
  • override buildRequest(
  • options: Core.FinalRequestOptions,
  • props: { retryCount?: number } = {},
  • ): {
    req: RequestInit;
    url: string;
    timeout: number;
    @@ -586,15 +590,15 @@ export class AzureOpenAI extends OpenAI {
    if (!Core.isObj(options.body)) {
    throw new Error('Expected request body to be an object');
    }
  •  const model = this._deployment || options.body['model'];
    
  •  const model = this.deploymentName || options.body['model'];
     if (model !== undefined && !this.baseURL.includes('/deployments')) {
       options.path = `/deployments/${model}${options.path}`;
     }
    
    }
  • return super.buildRequest(options);
  • return super.buildRequest(options, props);
    }
  • private async _getAzureADToken(): Promise<string | undefined> {
  • async _getAzureADToken(): Promise<string | undefined> {
    if (typeof this._azureADTokenProvider === 'function') {
    const token = await this._azureADTokenProvider();
    if (!token || typeof token !== 'string') {
    diff --git src/resources/audio/speech.ts src/resources/audio/speech.ts
    index bd2ed9f65..35e82c4c1 100644
    --- src/resources/audio/speech.ts
    +++ src/resources/audio/speech.ts
    @@ -33,12 +33,12 @@ export interface SpeechCreateParams {
    model: (string & {}) | SpeechModel;

    /**

    • The voice to use when generating the audio. Supported voices are alloy,
    • echo, fable, onyx, nova, and shimmer. Previews of the voices are
    • available in the
    • The voice to use when generating the audio. Supported voices are alloy, ash,
    • coral, echo, fable, onyx, nova, sage and shimmer. Previews of the
  • voice: 'alloy' | 'echo' | 'fable' | 'onyx' | 'nova' | 'shimmer';
  • voice: 'alloy' | 'ash' | 'coral' | 'echo' | 'fable' | 'onyx' | 'nova' | 'sage' | 'shimmer';

    /**

    • The format to audio in. Supported formats are mp3, opus, aac, flac,
      diff --git src/resources/audio/transcriptions.ts src/resources/audio/transcriptions.ts
      index 0b6da4620..6d0a07e1e 100644
      --- src/resources/audio/transcriptions.ts
      +++ src/resources/audio/transcriptions.ts
      @@ -166,8 +166,8 @@ export interface TranscriptionCreateParams<

    /**

    • The language of the input audio. Supplying the input language in
    • improve accuracy and latency.
    • format will improve accuracy and latency.
      */
      language?: string;

diff --git src/resources/batches.ts src/resources/batches.ts
index ec5ca6331..aadda83a6 100644
--- src/resources/batches.ts
+++ src/resources/batches.ts
@@ -4,6 +4,7 @@ import { APIResource } from '../resource';
import { isRequestOptions } from '../core';
import * as Core from '../core';
import * as BatchesAPI from './batches';
+import * as Shared from './shared';
import { CursorPage, type CursorPageParams } from '../pagination';

export class Batches extends APIResource {
@@ -138,11 +139,13 @@ export interface Batch {

/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful

    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;

    /**

    • The ID of the file containing the outputs of successfully executed requests.
      @@ -237,9 +240,14 @@ export interface BatchCreateParams {
      input_file_id: string;

    /**

    • Optional custom metadata for the batch.
    • Set of 16 key-value pairs that can be attached to an object. This can be useful
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata?: Record<string, string> | null;
  • metadata?: Shared.Metadata | null;
    }

export interface BatchListParams extends CursorPageParams {}
diff --git src/resources/beta/assistants.ts src/resources/beta/assistants.ts
index 0e657b1d4..69a5db520 100644
--- src/resources/beta/assistants.ts
+++ src/resources/beta/assistants.ts
@@ -111,11 +111,13 @@ export interface Assistant {

/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful

    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata: unknown | null;
  • metadata: Shared.Metadata | null;

    /**

    • ID of the model to use. You can use the
      @@ -1118,11 +1120,13 @@ export interface AssistantCreateParams {

    /**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;

    /**

    • The name of the assistant. The maximum length is 256 characters.
      @@ -1242,12 +1246,14 @@ export namespace AssistantCreateParams {
      file_ids?: Array;

      /**

  •     * Set of 16 key-value pairs that can be attached to a vector store. This can be
    
  •     * useful for storing additional information about the vector store in a structured
    
  •     * format. Keys can be a maximum of 64 characters long and values can be a maxium
    
  •     * of 512 characters long.
    
  •     * Set of 16 key-value pairs that can be attached to an object. This can be useful
    
  •     * for storing additional information about the object in a structured format, and
    
  •     * querying for objects via API or the dashboard.
    
  •     *
    
  •     * Keys are strings with a maximum length of 64 characters. Values are strings with
    
  •     * a maximum length of 512 characters.
        */
    
  •    metadata?: unknown;
    
  •    metadata?: Shared.Metadata | null;
     }
    

    }
    }
    @@ -1267,11 +1273,13 @@ export interface AssistantUpdateParams {

    /**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;

    /**

    • ID of the model to use. You can use the
      diff --git src/resources/beta/realtime/realtime.ts src/resources/beta/realtime/realtime.ts
      index 5de06917a..c666221e1 100644
      --- src/resources/beta/realtime/realtime.ts
      +++ src/resources/beta/realtime/realtime.ts
      @@ -2,6 +2,7 @@

import { APIResource } from '../../../resource';
import * as RealtimeAPI from './realtime';
+import * as Shared from '../../shared';
import * as SessionsAPI from './sessions';
import {
Session as SessionsAPISession,
@@ -173,9 +174,10 @@ export interface ConversationItemCreateEvent {

/**
* The ID of the preceding item after which the new item will be inserted. If not

    • set, the new item will be appended to the end of the conversation. If set, it
    • allows an item to be inserted mid-conversation. If the ID cannot be found, an
    • error will be returned and the item will not be added.
    • set, the new item will be appended to the end of the conversation. If set to
    • root, the new item will be added to the beginning of the conversation. If set
    • to an existing ID, it allows an item to be inserted mid-conversation. If the ID
    • cannot be found, an error will be returned and the item will not be added.
      */
      previous_item_id?: string;
      }
      @@ -740,9 +742,38 @@ export interface RealtimeResponse {
      id?: string;

/**

    • Developer-provided string key-value pairs associated with this response.
    • Which conversation the response is added to, determined by the conversation
    • field in the response.create event. If auto, the response will be added to
    • the default conversation and the value of conversation_id will be an id like
    • conv_1234. If none, the response will not be added to any conversation and
    • the value of conversation_id will be null. If responses are being triggered
    • by server VAD, the response will be added to the default conversation, thus the
    • conversation_id will be an id like conv_1234.
      */
  • metadata?: unknown | null;
  • conversation_id?: string;

  • /**

    • Maximum number of output tokens for a single assistant response, inclusive of
    • tool calls, that was used in this response.
  • */

  • max_output_tokens?: number | 'inf';

  • /**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
  • */

  • metadata?: Shared.Metadata | null;

  • /**

    • The set of modalities the model used to respond. If there are multiple
    • modalities, the model will pick one, for example if modalities is
    • ["text", "audio"], the model could be responding in either text or audio.
  • */

  • modalities?: Array<'text' | 'audio'>;

    /**

    • The object type, must be realtime.response.
      @@ -754,6 +785,11 @@ export interface RealtimeResponse {
      */
      output?: Array;
  • /**

    • The format of output audio. Options are pcm16, g711_ulaw, or g711_alaw.
  • */

  • output_audio_format?: 'pcm16' | 'g711_ulaw' | 'g711_alaw';

  • /**

    • The final status of the response (completed, cancelled, failed, or
    • incomplete).
      @@ -765,6 +801,11 @@ export interface RealtimeResponse {
      */
      status_details?: RealtimeResponseStatus;
  • /**

    • Sampling temperature for the model, limited to [0.6, 1.2]. Defaults to 0.8.
  • */

  • temperature?: number;

  • /**

    • Usage statistics for the Response, this will correspond to billing. A Realtime
    • API session will maintain a conversation context and append new Items to the
      @@ -772,6 +813,12 @@ export interface RealtimeResponse {
    • become the input for later turns.
      */
      usage?: RealtimeResponseUsage;
  • /**

    • The voice the model used to respond. Current voice options are alloy, ash,
    • ballad, coral, echo sage, shimmer and verse.
  • */

  • voice?: 'alloy' | 'ash' | 'ballad' | 'coral' | 'echo' | 'sage' | 'shimmer' | 'verse';
    }

/**
@@ -1319,11 +1366,13 @@ export namespace ResponseCreateEvent {

 /**
  * Set of 16 key-value pairs that can be attached to an object. This can be useful
  • * for storing additional information about the object in a structured format. Keys
    
  • * can be a maximum of 64 characters long and values can be a maximum of 512
    
  • * characters long.
    
  • * for storing additional information about the object in a structured format, and
    
  • * querying for objects via API or the dashboard.
    
  • *
    
  • * Keys are strings with a maximum length of 64 characters. Values are strings with
    
  • * a maximum length of 512 characters.
    */
    
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;

    /**

    • The set of modalities the model can respond with. To disable audio, set this to
      @@ -1705,17 +1754,9 @@ export namespace SessionUpdateEvent {
      /
      export interface Session {
      /
      *
  • * The Realtime model used for this session.
    
  • */
    
  • model:
  •  | 'gpt-4o-realtime-preview'
    
  •  | 'gpt-4o-realtime-preview-2024-10-01'
    
  •  | 'gpt-4o-realtime-preview-2024-12-17'
    
  •  | 'gpt-4o-mini-realtime-preview'
    
  •  | 'gpt-4o-mini-realtime-preview-2024-12-17';
    
  • /**
  • * The format of input audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`.
    
  • * The format of input audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`. For
    
  • * `pcm16`, input audio must be 16-bit PCM at a 24kHz sample rate, single channel
    
  • * (mono), and little-endian byte order.
    */
    
    input_audio_format?: 'pcm16' | 'g711_ulaw' | 'g711_alaw';

@@ -1723,8 +1764,11 @@ export namespace SessionUpdateEvent {
* Configuration for input audio transcription, defaults to off and can be set to
* null to turn off once on. Input audio transcription is not native to the
* model, since the model consumes audio directly. Transcription runs

  • * asynchronously through Whisper and should be treated as rough guidance rather
    
  • * than the representation understood by the model.
    
  • * asynchronously through
    
  • * [OpenAI Whisper transcription](https://platform.openai.com/docs/api-reference/audio/createTranscription)
    
  • * and should be treated as rough guidance rather than the representation
    
  • * understood by the model. The client can optionally set the language and prompt
    
  • * for transcription, these fields will be passed to the Whisper API.
    */
    
    input_audio_transcription?: Session.InputAudioTranscription;

@@ -1756,8 +1800,19 @@ export namespace SessionUpdateEvent {
*/
modalities?: Array<'text' | 'audio'>;

  • /**
  • * The Realtime model used for this session.
    
  • */
    
  • model?:
  •  | 'gpt-4o-realtime-preview'
    
  •  | 'gpt-4o-realtime-preview-2024-10-01'
    
  •  | 'gpt-4o-realtime-preview-2024-12-17'
    
  •  | 'gpt-4o-mini-realtime-preview'
    
  •  | 'gpt-4o-mini-realtime-preview-2024-12-17';
    
  • /**
    * The format of output audio. Options are pcm16, g711_ulaw, or g711_alaw.
  • * For `pcm16`, output audio is sampled at a rate of 24kHz.
    */
    
    output_audio_format?: 'pcm16' | 'g711_ulaw' | 'g711_alaw';

@@ -1797,15 +1852,33 @@ export namespace SessionUpdateEvent {
* Configuration for input audio transcription, defaults to off and can be set to
* null to turn off once on. Input audio transcription is not native to the
* model, since the model consumes audio directly. Transcription runs

  • * asynchronously through Whisper and should be treated as rough guidance rather
    
  • * than the representation understood by the model.
    
  • * asynchronously through
    
  • * [OpenAI Whisper transcription](https://platform.openai.com/docs/api-reference/audio/createTranscription)
    
  • * and should be treated as rough guidance rather than the representation
    
  • * understood by the model. The client can optionally set the language and prompt
    
  • * for transcription, these fields will be passed to the Whisper API.
    */
    

    export interface InputAudioTranscription {

  •  /**
    
  •   * The language of the input audio. Supplying the input language in
    
  •   * [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. `en`)
    
  •   * format will improve accuracy and latency.
    
  •   */
    
  •  language?: string;
    
  •  /**
      * The model to use for transcription, `whisper-1` is the only currently supported
      * model.
      */
     model?: string;
    
  •  /**
    
  •   * An optional text to guide the model's style or continue a previous audio
    
  •   * segment. The
    
  •   * [prompt](https://platform.openai.com/docs/guides/speech-to-text#prompting)
    
  •   * should match the audio language.
    
  •   */
    
  •  prompt?: string;
    

    }

    export interface Tool {
    diff --git src/resources/beta/realtime/sessions.ts src/resources/beta/realtime/sessions.ts
    index c1082d236..d2afa25b1 100644
    --- src/resources/beta/realtime/sessions.ts
    +++ src/resources/beta/realtime/sessions.ts
    @@ -32,7 +32,9 @@ export interface Session {
    id?: string;

    /**

    • The format of input audio. Options are pcm16, g711_ulaw, or g711_alaw.
    • The format of input audio. Options are pcm16, g711_ulaw, or g711_alaw. For
    • pcm16, input audio must be 16-bit PCM at a 24kHz sample rate, single channel
    • (mono), and little-endian byte order.
      */
      input_audio_format?: 'pcm16' | 'g711_ulaw' | 'g711_alaw';

@@ -86,6 +88,7 @@ export interface Session {

/**
* The format of output audio. Options are pcm16, g711_ulaw, or g711_alaw.

    • For pcm16, output audio is sampled at a rate of 24kHz.
      */
      output_audio_format?: 'pcm16' | 'g711_ulaw' | 'g711_alaw';

@@ -200,7 +203,7 @@ export interface SessionCreateResponse {
/**
* Ephemeral key returned by the API.
*/

  • client_secret?: SessionCreateResponse.ClientSecret;
  • client_secret: SessionCreateResponse.ClientSecret;

    /**

    • The format of input audio. Options are pcm16, g711_ulaw, or g711_alaw.
      @@ -289,14 +292,14 @@ export namespace SessionCreateResponse {
      • Timestamp for when the token expires. Currently, all tokens expire after one
      • minute.
        */
  • expires_at?: number;
  • expires_at: number;

    /**

    • Ephemeral key usable in client environments to authenticate connections to the
    • Realtime API. Use this in client-side environments rather than a standard API
    • token, which should only be used server-side.
      */
  • value?: string;
  • value: string;
    }

/**
@@ -372,17 +375,9 @@ export namespace SessionCreateResponse {

export interface SessionCreateParams {
/**

    • The Realtime model used for this session.
  • */
  • model:
  • | 'gpt-4o-realtime-preview'
  • | 'gpt-4o-realtime-preview-2024-10-01'
  • | 'gpt-4o-realtime-preview-2024-12-17'
  • | 'gpt-4o-mini-realtime-preview'
  • | 'gpt-4o-mini-realtime-preview-2024-12-17';
  • /**
    • The format of input audio. Options are pcm16, g711_ulaw, or g711_alaw.
    • The format of input audio. Options are pcm16, g711_ulaw, or g711_alaw. For
    • pcm16, input audio must be 16-bit PCM at a 24kHz sample rate, single channel
    • (mono), and little-endian byte order.
      */
      input_audio_format?: 'pcm16' | 'g711_ulaw' | 'g711_alaw';

@@ -390,8 +385,11 @@ export interface SessionCreateParams {
* Configuration for input audio transcription, defaults to off and can be set to
* null to turn off once on. Input audio transcription is not native to the
* model, since the model consumes audio directly. Transcription runs

    • asynchronously through Whisper and should be treated as rough guidance rather
    • than the representation understood by the model.
    • asynchronously through
    • and should be treated as rough guidance rather than the representation
    • understood by the model. The client can optionally set the language and prompt
    • for transcription, these fields will be passed to the Whisper API.
      */
      input_audio_transcription?: SessionCreateParams.InputAudioTranscription;

@@ -423,8 +421,19 @@ export interface SessionCreateParams {
*/
modalities?: Array<'text' | 'audio'>;

  • /**
    • The Realtime model used for this session.
  • */
  • model?:
  • | 'gpt-4o-realtime-preview'
  • | 'gpt-4o-realtime-preview-2024-10-01'
  • | 'gpt-4o-realtime-preview-2024-12-17'
  • | 'gpt-4o-mini-realtime-preview'
  • | 'gpt-4o-mini-realtime-preview-2024-12-17';
  • /**
    • The format of output audio. Options are pcm16, g711_ulaw, or g711_alaw.
    • For pcm16, output audio is sampled at a rate of 24kHz.
      */
      output_audio_format?: 'pcm16' | 'g711_ulaw' | 'g711_alaw';

@@ -464,15 +473,33 @@ export namespace SessionCreateParams {
* Configuration for input audio transcription, defaults to off and can be set to
* null to turn off once on. Input audio transcription is not native to the
* model, since the model consumes audio directly. Transcription runs

    • asynchronously through Whisper and should be treated as rough guidance rather
    • than the representation understood by the model.
    • asynchronously through
    • and should be treated as rough guidance rather than the representation
    • understood by the model. The client can optionally set the language and prompt
    • for transcription, these fields will be passed to the Whisper API.
      */
      export interface InputAudioTranscription {
  • /**
  • * The language of the input audio. Supplying the input language in
    
  • * [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. `en`)
    
  • * format will improve accuracy and latency.
    
  • */
    
  • language?: string;
  • /**
    * The model to use for transcription, whisper-1 is the only currently supported
    * model.
    */
    model?: string;
  • /**
  • * An optional text to guide the model's style or continue a previous audio
    
  • * segment. The
    
  • * [prompt](https://platform.openai.com/docs/guides/speech-to-text#prompting)
    
  • * should match the audio language.
    
  • */
    
  • prompt?: string;
    }

export interface Tool {
diff --git src/resources/beta/threads/messages.ts src/resources/beta/threads/messages.ts
index 8124f56cd..29fd2b29f 100644
--- src/resources/beta/threads/messages.ts
+++ src/resources/beta/threads/messages.ts
@@ -3,6 +3,7 @@
import { APIResource } from '../../../resource';
import { isRequestOptions } from '../../../core';
import * as Core from '../../../core';
+import * as Shared from '../../shared';
import * as AssistantsAPI from '../assistants';
import { CursorPage, type CursorPageParams } from '../../../pagination';

@@ -407,11 +408,13 @@ export interface Message {

/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful

    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata: unknown | null;
  • metadata: Shared.Metadata | null;

    /**

    • The object type, which is always thread.message.
      @@ -660,11 +663,13 @@ export interface MessageCreateParams {

    /**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;
    }

export namespace MessageCreateParams {
@@ -693,11 +698,13 @@ export namespace MessageCreateParams {
export interface MessageUpdateParams {
/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful

    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;
    }

export interface MessageListParams extends CursorPageParams {
diff --git src/resources/beta/threads/runs/runs.ts src/resources/beta/threads/runs/runs.ts
index 814ad3e89..84ba7b63c 100644
--- src/resources/beta/threads/runs/runs.ts
+++ src/resources/beta/threads/runs/runs.ts
@@ -8,6 +8,7 @@ import { AssistantStream, RunCreateParamsBaseStream } from '../../../../lib/Assi
import { sleep } from '../../../../core';
import { RunSubmitToolOutputsParamsStream } from '../../../../lib/AssistantStream';
import * as RunsAPI from './runs';
+import * as Shared from '../../../shared';
import * as AssistantsAPI from '../../assistants';
import * as ChatAPI from '../../../chat/chat';
import * as MessagesAPI from '../messages';
@@ -415,11 +416,13 @@ export interface Run {

/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful

    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata: unknown | null;
  • metadata: Shared.Metadata | null;

    /**

    • The model that the
      @@ -705,10 +708,12 @@ export interface RunCreateParamsBase {
      /**
    • Body param: Set of 16 key-value pairs that can be attached to an object. This
    • can be useful for storing additional information about the object in a
    • structured format. Keys can be a maximum of 64 characters long and values can be
    • a maxium of 512 characters long.
    • structured format, and querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;

    /**

    • Body param: The ID of the
      @@ -823,11 +828,13 @@ export namespace RunCreateParams {

    /**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
  • * for storing additional information about the object in a structured format. Keys
    
  • * can be a maximum of 64 characters long and values can be a maxium of 512
    
  • * characters long.
    
  • * for storing additional information about the object in a structured format, and
    
  • * querying for objects via API or the dashboard.
    
  • *
    
  • * Keys are strings with a maximum length of 64 characters. Values are strings with
    
  • * a maximum length of 512 characters.
    */
    
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;
    }

export namespace AdditionalMessage {
@@ -898,11 +905,13 @@ export interface RunCreateParamsStreaming extends RunCreateParamsBase {
export interface RunUpdateParams {
/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful

    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;
    }

export interface RunListParams extends CursorPageParams {
diff --git src/resources/beta/threads/runs/steps.ts src/resources/beta/threads/runs/steps.ts
index 6c6722b62..c491b4e83 100644
--- src/resources/beta/threads/runs/steps.ts
+++ src/resources/beta/threads/runs/steps.ts
@@ -4,6 +4,7 @@ import { APIResource } from '../../../../resource';
import { isRequestOptions } from '../../../../core';
import * as Core from '../../../../core';
import * as StepsAPI from './steps';
+import * as Shared from '../../../shared';
import { CursorPage, type CursorPageParams } from '../../../../pagination';

export class Steps extends APIResource {
@@ -515,11 +516,13 @@ export interface RunStep {

/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful

    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata: unknown | null;
  • metadata: Shared.Metadata | null;

    /**

    • The object type, which is always thread.run.step.
      diff --git src/resources/beta/threads/threads.ts src/resources/beta/threads/threads.ts
      index 453d8fa10..3f69c6e60 100644
      --- src/resources/beta/threads/threads.ts
      +++ src/resources/beta/threads/threads.ts
      @@ -250,11 +250,13 @@ export interface Thread {

    /**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata: unknown | null;
  • metadata: Shared.Metadata | null;

    /**

    • The object type, which is always thread.
      @@ -322,11 +324,13 @@ export interface ThreadCreateParams {

    /**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;

    /**

    • A set of resources that are made available to the assistant's tools in this
      @@ -361,11 +365,13 @@ export namespace ThreadCreateParams {

    /**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
  • * for storing additional information about the object in a structured format. Keys
    
  • * can be a maximum of 64 characters long and values can be a maxium of 512
    
  • * characters long.
    
  • * for storing additional information about the object in a structured format, and
    
  • * querying for objects via API or the dashboard.
    
  • *
    
  • * Keys are strings with a maximum length of 64 characters. Values are strings with
    
  • * a maximum length of 512 characters.
    */
    
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;
    }

export namespace Message {
@@ -447,12 +453,14 @@ export namespace ThreadCreateParams {
file_ids?: Array;

     /**
  •     * Set of 16 key-value pairs that can be attached to a vector store. This can be
    
  •     * useful for storing additional information about the vector store in a structured
    
  •     * format. Keys can be a maximum of 64 characters long and values can be a maxium
    
  •     * of 512 characters long.
    
  •     * Set of 16 key-value pairs that can be attached to an object. This can be useful
    
  •     * for storing additional information about the object in a structured format, and
    
  •     * querying for objects via API or the dashboard.
    
  •     *
    
  •     * Keys are strings with a maximum length of 64 characters. Values are strings with
    
  •     * a maximum length of 512 characters.
        */
    
  •    metadata?: unknown;
    
  •    metadata?: Shared.Metadata | null;
     }
    
    }
    }
    @@ -461,11 +469,13 @@ export namespace ThreadCreateParams {
    export interface ThreadUpdateParams {
    /**
    • Set of 16 key-value pairs that can be attached to an object. This can be useful
    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;

    /**

    • A set of resources that are made available to the assistant's tools in this
      @@ -549,11 +559,13 @@ export interface ThreadCreateAndRunParamsBase {

    /**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;

    /**

    • The ID of the Model to
      @@ -609,7 +621,8 @@ export interface ThreadCreateAndRunParamsBase {
      temperature?: number | null;

    /**

    • If no thread is provided, an empty thread will be created.
    • Options to create a new thread. If no thread is provided when running a request,
    • an empty thread will be created.
      */
      thread?: ThreadCreateAndRunParams.Thread;

@@ -658,7 +671,8 @@ export interface ThreadCreateAndRunParamsBase {

export namespace ThreadCreateAndRunParams {
/**

    • If no thread is provided, an empty thread will be created.
    • Options to create a new thread. If no thread is provided when running a request,
    • an empty thread will be created.
      /
      export interface Thread {
      /
      *
      @@ -669,11 +683,13 @@ export namespace ThreadCreateAndRunParams {

    /**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
  • * for storing additional information about the object in a structured format. Keys
    
  • * can be a maximum of 64 characters long and values can be a maxium of 512
    
  • * characters long.
    
  • * for storing additional information about the object in a structured format, and
    
  • * querying for objects via API or the dashboard.
    
  • *
    
  • * Keys are strings with a maximum length of 64 characters. Values are strings with
    
  • * a maximum length of 512 characters.
    */
    
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;

    /**

    • A set of resources that are made available to the assistant's tools in this
      @@ -708,11 +724,13 @@ export namespace ThreadCreateAndRunParams {

    /**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
  •   * for storing additional information about the object in a structured format. Keys
    
  •   * can be a maximum of 64 characters long and values can be a maxium of 512
    
  •   * characters long.
    
  •   * for storing additional information about the object in a structured format, and
    
  •   * querying for objects via API or the dashboard.
    
  •   *
    
  •   * Keys are strings with a maximum length of 64 characters. Values are strings with
    
  •   * a maximum length of 512 characters.
      */
    
  •  metadata?: unknown | null;
    
  •  metadata?: Shared.Metadata | null;
    

    }

    export namespace Message {
    @@ -794,12 +812,14 @@ export namespace ThreadCreateAndRunParams {
    file_ids?: Array;

         /**
    
  •       * Set of 16 key-value pairs that can be attached to a vector store. This can be
    
  •       * useful for storing additional information about the vector store in a structured
    
  •       * format. Keys can be a maximum of 64 characters long and values can be a maxium
    
  •       * of 512 characters long.
    
  •       * Set of 16 key-value pairs that can be attached to an object. This can be useful
    
  •       * for storing additional information about the object in a structured format, and
    
  •       * querying for objects via API or the dashboard.
    
  •       *
    
  •       * Keys are strings with a maximum length of 64 characters. Values are strings with
    
  •       * a maximum length of 512 characters.
          */
    
  •      metadata?: unknown;
    
  •      metadata?: Shared.Metadata | null;
       }
     }
    

    }
    diff --git src/resources/beta/vector-stores/vector-stores.ts src/resources/beta/vector-stores/vector-stores.ts
    index cbff2d562..8438b79da 100644
    --- src/resources/beta/vector-stores/vector-stores.ts
    +++ src/resources/beta/vector-stores/vector-stores.ts
    @@ -3,6 +3,7 @@
    import { APIResource } from '../../../resource';
    import { isRequestOptions } from '../../../core';
    import * as Core from '../../../core';
    +import * as Shared from '../../shared';
    import * as FileBatchesAPI from './file-batches';
    import {
    FileBatchCreateParams,
    @@ -187,11 +188,13 @@ export interface VectorStore {

    /**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata: unknown | null;
  • metadata: Shared.Metadata | null;

    /**

    • The name of the vector store.
      @@ -300,11 +303,13 @@ export interface VectorStoreCreateParams {

    /**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;

    /**

    • The name of the vector store.
      @@ -338,11 +343,13 @@ export interface VectorStoreUpdateParams {

    /**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;

    /**

    • The name of the vector store.
      diff --git src/resources/chat/chat.ts src/resources/chat/chat.ts
      index 2230b19bd..d4a18929c 100644
      --- src/resources/chat/chat.ts
      +++ src/resources/chat/chat.ts
      @@ -46,6 +46,8 @@ export class Chat extends APIResource {
      }

export type ChatModel =

  • | 'o3-mini'

  • | 'o3-mini-2025-01-31'
    | 'o1'
    | 'o1-2024-12-17'
    | 'o1-preview'
    diff --git src/resources/chat/completions.ts src/resources/chat/completions.ts
    index 88c778036..d2de11458 100644
    --- src/resources/chat/completions.ts
    +++ src/resources/chat/completions.ts
    @@ -76,8 +76,7 @@ export interface ChatCompletion {
    object: 'chat.completion';

    /**

    • The service tier used for processing the request. This field is only included if
    • the service_tier parameter is specified in the request.
    • The service tier used for processing the request.
      */
      service_tier?: 'scale' | 'default' | null;

@@ -300,8 +299,7 @@ export interface ChatCompletionChunk {
object: 'chat.completion.chunk';

/**

    • The service tier used for processing the request. This field is only included if
    • the service_tier parameter is specified in the request.
    • The service tier used for processing the request.
      */
      service_tier?: 'scale' | 'default' | null;

@@ -1014,10 +1012,14 @@ export interface ChatCompletionCreateParamsBase {
max_tokens?: number | null;

/**

    • Developer-defined tags and values used for filtering completions in the
    • Set of 16 key-value pairs that can be attached to an object. This can be useful
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum ,length of 512 characters.
      */
  • metadata?: Record<string, string> | null;
  • metadata?: Shared.Metadata | null;

    /**

    • Output types that you would like the model to generate for this request. Most
      @@ -1111,13 +1113,10 @@ export interface ChatCompletionCreateParamsBase {
    • utilize scale tier credits until they are exhausted.
      • If set to 'auto', and the Project is not Scale tier enabled, the request will
    • be processed using the default service tier with a lower uptime SLA and no
    • latency guarentee.
    • latency guarantee.
      • If set to 'default', the request will be processed using the default service
    • tier with a lower uptime SLA and no latency guarentee.
    • tier with a lower uptime SLA and no latency guarantee.
      • When not set, the default behavior is 'auto'.
    • When this parameter is set, the response body will include the service_tier
    • utilized.
      */
      service_tier?: 'auto' | 'default' | null;

diff --git src/resources/embeddings.ts src/resources/embeddings.ts
index 4b1644a68..d01ffc807 100644
--- src/resources/embeddings.ts
+++ src/resources/embeddings.ts
@@ -86,7 +86,8 @@ export interface EmbeddingCreateParams {
* text-embedding-ada-002), cannot be an empty string, and any array must be 2048
* dimensions or less.
* Example Python code

    • for counting tokens.
    • for counting tokens. Some models may also impose a limit on total number of
    • tokens summed across inputs.
      */
      input: string | Array | Array | Array<Array>;

diff --git src/resources/shared.ts src/resources/shared.ts
index f44fda8a7..3bb11582f 100644
--- src/resources/shared.ts
+++ src/resources/shared.ts
@@ -55,6 +55,16 @@ export interface FunctionDefinition {
*/
export type FunctionParameters = Record<string, unknown>;

+/**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
  • */
    +export type Metadata = Record<string, string>;

export interface ResponseFormatJSONObject {
/**
* The type of response format being defined: json_object
diff --git src/resources/uploads/uploads.ts src/resources/uploads/uploads.ts
index 8491d0fe2..bfe752cd7 100644
--- src/resources/uploads/uploads.ts
+++ src/resources/uploads/uploads.ts
@@ -113,7 +113,7 @@ export interface Upload {
status: 'pending' | 'completed' | 'cancelled' | 'expired';

/**

    • The ready File object after the Upload is completed.
    • The File object represents a document that has been uploaded to OpenAI.
      */
      file?: FilesAPI.FileObject | null;
      }
      diff --git src/version.ts src/version.ts
      index e8b9601ed..07241a8cf 100644
      --- src/version.ts
      +++ src/version.ts
      @@ -1 +1 @@
      -export const VERSION = '4.79.4'; // x-release-please-version
      +export const VERSION = '4.82.0'; // x-release-please-version
      diff --git tests/api-resources/beta/assistants.test.ts tests/api-resources/beta/assistants.test.ts
      index a64465c77..88a10ba8f 100644
      --- tests/api-resources/beta/assistants.test.ts
      +++ tests/api-resources/beta/assistants.test.ts
      @@ -25,7 +25,7 @@ describe('resource assistants', () => {
      model: 'gpt-4o',
      description: 'description',
      instructions: 'instructions',
  •  metadata: {},
    
  •  metadata: { foo: 'string' },
     name: 'name',
     response_format: 'auto',
     temperature: 1,
    

@@ -33,7 +33,9 @@ describe('resource assistants', () => {
code_interpreter: { file_ids: ['string'] },
file_search: {
vector_store_ids: ['string'],

  •      vector_stores: [{ chunking_strategy: { type: 'auto' }, file_ids: ['string'], metadata: {} }],
    
  •      vector_stores: [
    
  •        { chunking_strategy: { type: 'auto' }, file_ids: ['string'], metadata: { foo: 'string' } },
    
  •      ],
       },
     },
     tools: [{ type: 'code_interpreter' }],
    

diff --git tests/api-resources/beta/realtime/sessions.test.ts tests/api-resources/beta/realtime/sessions.test.ts
index 0ed998c27..dbb92ead3 100644
--- tests/api-resources/beta/realtime/sessions.test.ts
+++ tests/api-resources/beta/realtime/sessions.test.ts
@@ -9,8 +9,8 @@ const client = new OpenAI({
});

describe('resource sessions', () => {

  • test('create: only required params', async () => {
  • const responsePromise = client.beta.realtime.sessions.create({ model: 'gpt-4o-realtime-preview' });
  • test('create', async () => {
  • const responsePromise = client.beta.realtime.sessions.create({});
    const rawResponse = await responsePromise.asResponse();
    expect(rawResponse).toBeInstanceOf(Response);
    const response = await responsePromise;
    @@ -19,27 +19,4 @@ describe('resource sessions', () => {
    expect(dataAndResponse.data).toBe(response);
    expect(dataAndResponse.response).toBe(rawResponse);
    });
  • test('create: required and optional params', async () => {
  • const response = await client.beta.realtime.sessions.create({
  •  model: 'gpt-4o-realtime-preview',
    
  •  input_audio_format: 'pcm16',
    
  •  input_audio_transcription: { model: 'model' },
    
  •  instructions: 'instructions',
    
  •  max_response_output_tokens: 0,
    
  •  modalities: ['text'],
    
  •  output_audio_format: 'pcm16',
    
  •  temperature: 0,
    
  •  tool_choice: 'tool_choice',
    
  •  tools: [{ description: 'description', name: 'name', parameters: {}, type: 'function' }],
    
  •  turn_detection: {
    
  •    create_response: true,
    
  •    prefix_padding_ms: 0,
    
  •    silence_duration_ms: 0,
    
  •    threshold: 0,
    
  •    type: 'type',
    
  •  },
    
  •  voice: 'alloy',
    
  • });
  • });
    });
    diff --git tests/api-resources/beta/threads/messages.test.ts tests/api-resources/beta/threads/messages.test.ts
    index c1f5f7b6e..e125edd84 100644
    --- tests/api-resources/beta/threads/messages.test.ts
    +++ tests/api-resources/beta/threads/messages.test.ts
    @@ -28,7 +28,7 @@ describe('resource messages', () => {
    content: 'string',
    role: 'user',
    attachments: [{ file_id: 'file_id', tools: [{ type: 'code_interpreter' }] }],
  •  metadata: {},
    
  •  metadata: { foo: 'string' },
    
    });
    });

diff --git tests/api-resources/beta/threads/runs/runs.test.ts tests/api-resources/beta/threads/runs/runs.test.ts
index 4fd8261ac..9b728403f 100644
--- tests/api-resources/beta/threads/runs/runs.test.ts
+++ tests/api-resources/beta/threads/runs/runs.test.ts
@@ -30,13 +30,13 @@ describe('resource runs', () => {
content: 'string',
role: 'user',
attachments: [{ file_id: 'file_id', tools: [{ type: 'code_interpreter' }] }],

  •      metadata: {},
    
  •      metadata: { foo: 'string' },
       },
     ],
     instructions: 'instructions',
     max_completion_tokens: 256,
     max_prompt_tokens: 256,
    
  •  metadata: {},
    
  •  metadata: { foo: 'string' },
     model: 'gpt-4o',
     parallel_tool_calls: true,
     response_format: 'auto',
    

diff --git tests/api-resources/beta/threads/threads.test.ts tests/api-resources/beta/threads/threads.test.ts
index aba266316..f26d6ec44 100644
--- tests/api-resources/beta/threads/threads.test.ts
+++ tests/api-resources/beta/threads/threads.test.ts
@@ -37,15 +37,17 @@ describe('resource threads', () => {
content: 'string',
role: 'user',
attachments: [{ file_id: 'file_id', tools: [{ type: 'code_interpreter' }] }],

  •          metadata: {},
    
  •          metadata: { foo: 'string' },
           },
         ],
    
  •      metadata: {},
    
  •      metadata: { foo: 'string' },
         tool_resources: {
           code_interpreter: { file_ids: ['string'] },
           file_search: {
             vector_store_ids: ['string'],
    
  •          vector_stores: [{ chunking_strategy: { type: 'auto' }, file_ids: ['string'], metadata: {} }],
    
  •          vector_stores: [
    
  •            { chunking_strategy: { type: 'auto' }, file_ids: ['string'], metadata: { foo: 'string' } },
    
  •          ],
           },
         },
       },
    

@@ -118,7 +120,7 @@ describe('resource threads', () => {
instructions: 'instructions',
max_completion_tokens: 256,
max_prompt_tokens: 256,

  •  metadata: {},
    
  •  metadata: { foo: 'string' },
     model: 'gpt-4o',
     parallel_tool_calls: true,
     response_format: 'auto',
    

@@ -130,15 +132,17 @@ describe('resource threads', () => {
content: 'string',
role: 'user',
attachments: [{ file_id: 'file_id', tools: [{ type: 'code_interpreter' }] }],

  •        metadata: {},
    
  •        metadata: { foo: 'string' },
         },
       ],
    
  •    metadata: {},
    
  •    metadata: { foo: 'string' },
       tool_resources: {
         code_interpreter: { file_ids: ['string'] },
         file_search: {
           vector_store_ids: ['string'],
    
  •        vector_stores: [{ chunking_strategy: { type: 'auto' }, file_ids: ['string'], metadata: {} }],
    
  •        vector_stores: [
    
  •          { chunking_strategy: { type: 'auto' }, file_ids: ['string'], metadata: { foo: 'string' } },
    
  •        ],
         },
       },
     },
    

diff --git tests/api-resources/chat/completions.test.ts tests/api-resources/chat/completions.test.ts
index dfc09f69b..8f1bc7d4c 100644
--- tests/api-resources/chat/completions.test.ts
+++ tests/api-resources/chat/completions.test.ts
@@ -43,7 +43,7 @@ describe('resource completions', () => {
presence_penalty: -2,
reasoning_effort: 'low',
response_format: { type: 'text' },

  •  seed: -9007199254740991,
    
  •  seed: 0,
     service_tier: 'auto',
     stop: 'string',
     store: true,
    

diff --git tests/api-resources/completions.test.ts tests/api-resources/completions.test.ts
index 82322dc3a..c98501a87 100644
--- tests/api-resources/completions.test.ts
+++ tests/api-resources/completions.test.ts
@@ -32,7 +32,7 @@ describe('resource completions', () => {
max_tokens: 16,
n: 1,
presence_penalty: -2,

  •  seed: -9007199254740991,
    
  •  seed: 0,
     stop: '\n',
     stream: false,
     stream_options: { include_usage: true },
    

diff --git tests/lib/azure.test.ts tests/lib/azure.test.ts
index 064a0098c..0e3c2c5a3 100644
--- tests/lib/azure.test.ts
+++ tests/lib/azure.test.ts
@@ -51,6 +51,18 @@ describe('instantiate azure client', () => {
});
expect(req.headers as Headers).not.toHaveProperty('x-my-default-header');
});
+

  • test('includes retry count', () => {
  •  const { req } = client.buildRequest(
    
  •    {
    
  •      path: '/foo',
    
  •      method: 'post',
    
  •      headers: { 'X-My-Default-Header': null },
    
  •    },
    
  •    { retryCount: 1 },
    
  •  );
    
  •  expect((req.headers as Headers)['x-stainless-retry-count']).toEqual('1');
    
  • });
    });

describe('defaultQuery', () => {


</details>

### Description
This PR implements several significant updates to the OpenAI Node.js SDK, including:
1. Azure Realtime API support
2. Introduction of a new model (o3-mini)
3. Metadata type standardization
4. Bug fixes and documentation improvements

<details>
<summary><i>Changes</i></summary>

### Changes
By filename:

#### Azure Support
- `src/beta/realtime/internal-base.ts`: Added Azure URL building support
- `src/beta/realtime/websocket.ts` & `src/beta/realtime/ws.ts`: Added Azure-specific client implementations
- `examples/azure/`: Added new Azure examples including chat and realtime functionality

#### API Updates
- `src/resources/chat/chat.ts`: Added new model `o3-mini`
- `src/resources/shared.ts`: Added standardized `Metadata` type
- Multiple resource files: Updated metadata type definitions to use the new standardized type
- `src/resources/audio/speech.ts`: Added new voices (ash, coral, sage)

#### Documentation
- `README.md`: Updated Azure documentation and realtime error handling docs
- `helpers.md`: Fixed typo and improved type annotations
- `CHANGELOG.md`: Added entries for versions 4.80.0 through 4.82.0

#### Testing
- Added/updated tests for Azure functionality and new API features
- Updated test cases to use the new standardized metadata type



```mermaid
sequenceDiagram
    participant Client
    participant AzureOpenAI
    participant WebSocket
    participant OpenAI API

    Client->>AzureOpenAI: Create client
    AzureOpenAI->>AzureOpenAI: Configure authentication
    Client->>WebSocket: Connect to realtime API
    WebSocket->>AzureOpenAI: Get Azure AD token
    AzureOpenAI-->>WebSocket: Return token
    WebSocket->>OpenAI API: Establish WebSocket connection
    OpenAI API-->>WebSocket: Connection established
    Client->>WebSocket: Send realtime events
    WebSocket->>OpenAI API: Forward events
    OpenAI API-->>WebSocket: Stream responses
    WebSocket-->>Client: Forward responses

Possible Issues

  1. The new Azure realtime implementation might require additional error handling for specific Azure-related edge cases
  2. The standardization of metadata types could potentially break existing implementations that were using non-string values

Security Hotspots

  1. The Azure token handling in buildRealtimeURL method needs careful review to ensure tokens are properly sanitized and not leaked in logs or error messages
  2. WebSocket connection setup for Azure should be reviewed to ensure proper security headers and authentication are maintained throughout the session

Copy link

bedrock debug - [puLL-Merge] - openai/[email protected]

Diff
diff --git .release-please-manifest.json .release-please-manifest.json
index b1ab5c7b9..b2ee58e08 100644
--- .release-please-manifest.json
+++ .release-please-manifest.json
@@ -1,3 +1,3 @@
 {
-  ".": "4.79.4"
+  ".": "4.82.0"
 }
diff --git .stats.yml .stats.yml
index 9600edae3..e49b5c56e 100644
--- .stats.yml
+++ .stats.yml
@@ -1,2 +1,2 @@
 configured_endpoints: 69
-openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-b5b0e2c794b012919701c3fd43286af10fa25d33ceb8a881bec2636028f446e0.yml
+openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-6204952a29973265b9c0d66fc67ffaf53c6a90ae4d75cdacf9d147676f5274c9.yml
diff --git CHANGELOG.md CHANGELOG.md
index 4254a9b8f..7565cb01a 100644
--- CHANGELOG.md
+++ CHANGELOG.md
@@ -1,5 +1,50 @@
 # Changelog
 
+## 4.82.0 (2025-01-31)
+
+Full Changelog: [v4.81.0...v4.82.0](https://github.com/openai/openai-node/compare/v4.81.0...v4.82.0)
+
+### Features
+
+* **api:** add o3-mini ([#1295](https://github.com/openai/openai-node/issues/1295)) ([378e2f7](https://github.com/openai/openai-node/commit/378e2f7af62c570adb4c7644a4d49576b698de41))
+
+
+### Bug Fixes
+
+* **examples/realtime:** remove duplicate `session.update` call ([#1293](https://github.com/openai/openai-node/issues/1293)) ([ad800b4](https://github.com/openai/openai-node/commit/ad800b4f9410c6838994c24a3386ea708717f72b))
+* **types:** correct metadata type + other fixes ([378e2f7](https://github.com/openai/openai-node/commit/378e2f7af62c570adb4c7644a4d49576b698de41))
+
+## 4.81.0 (2025-01-29)
+
+Full Changelog: [v4.80.1...v4.81.0](https://github.com/openai/openai-node/compare/v4.80.1...v4.81.0)
+
+### Features
+
+* **azure:** Realtime API support ([#1287](https://github.com/openai/openai-node/issues/1287)) ([fe090c0](https://github.com/openai/openai-node/commit/fe090c0a57570217eb0b431e2cce40bf61de2b75))
+
+## 4.80.1 (2025-01-24)
+
+Full Changelog: [v4.80.0...v4.80.1](https://github.com/openai/openai-node/compare/v4.80.0...v4.80.1)
+
+### Bug Fixes
+
+* **azure:** include retry count header ([3e0ba40](https://github.com/openai/openai-node/commit/3e0ba409e57ce276fb1f95cd11c801e4ccaad572))
+
+
+### Documentation
+
+* fix typo, "zodFunctionTool" -&gt; "zodFunction" ([#1128](https://github.com/openai/openai-node/issues/1128)) ([b7ab6bb](https://github.com/openai/openai-node/commit/b7ab6bb304973ade94830f37eb646e800226d5ef))
+* **helpers:** fix type annotation ([fc019df](https://github.com/openai/openai-node/commit/fc019df1d9cc276e8f8e689742853a09aa94991a))
+* **readme:** fix realtime errors docs link ([#1286](https://github.com/openai/openai-node/issues/1286)) ([d1d50c8](https://github.com/openai/openai-node/commit/d1d50c897c18cefea964e8057fe1acfd766ae2bf))
+
+## 4.80.0 (2025-01-22)
+
+Full Changelog: [v4.79.4...v4.80.0](https://github.com/openai/openai-node/compare/v4.79.4...v4.80.0)
+
+### Features
+
+* **api:** update enum values, comments, and examples ([#1280](https://github.com/openai/openai-node/issues/1280)) ([d38f2c2](https://github.com/openai/openai-node/commit/d38f2c2648b6990f217c3c7d83ca31f3739641d3))
+
 ## 4.79.4 (2025-01-21)
 
 Full Changelog: [v4.79.3...v4.79.4](https://github.com/openai/openai-node/compare/v4.79.3...v4.79.4)
diff --git README.md README.md
index 3bd386e99..a1f4bf760 100644
--- README.md
+++ README.md
@@ -157,7 +157,7 @@ A full example can be found [here](https://github.com/openai/openai-node/blob/ma
 
 ### Realtime error handling
 
-When an error is encountered, either on the client side or returned from the server through the [`error` event](https://platform.openai.com/docs/guides/realtime/realtime-api-beta#handling-errors), the `error` event listener will be fired. However, if you haven't registered an `error` event listener then an `unhandled Promise rejection` error will be thrown.
+When an error is encountered, either on the client side or returned from the server through the [`error` event](https://platform.openai.com/docs/guides/realtime-model-capabilities#error-handling), the `error` event listener will be fired. However, if you haven't registered an `error` event listener then an `unhandled Promise rejection` error will be thrown.
 
 It is **highly recommended** that you register an `error` event listener and handle errors approriately as typically the underlying connection is still usable.
 
@@ -499,7 +499,7 @@ const credential = new DefaultAzureCredential();
 const scope = 'https://cognitiveservices.azure.com/.default';
 const azureADTokenProvider = getBearerTokenProvider(credential, scope);
 
-const openai = new AzureOpenAI({ azureADTokenProvider });
+const openai = new AzureOpenAI({ azureADTokenProvider, apiVersion: "<The API version, e.g. 2024-10-01-preview>" });
 
 const result = await openai.chat.completions.create({
   model: 'gpt-4o',
@@ -509,6 +509,26 @@ const result = await openai.chat.completions.create({
 console.log(result.choices[0]!.message?.content);
 \`\`\`
 
+### Realtime API
+This SDK provides real-time streaming capabilities for Azure OpenAI through the `OpenAIRealtimeWS` and `OpenAIRealtimeWebSocket` clients described previously.
+
+To utilize the real-time features, begin by creating a fully configured `AzureOpenAI` client and passing it into either `OpenAIRealtimeWS.azure` or `OpenAIRealtimeWebSocket.azure`. For example:
+
+```ts
+const cred = new DefaultAzureCredential();
+const scope = 'https://cognitiveservices.azure.com/.default';
+const deploymentName = 'gpt-4o-realtime-preview-1001';
+const azureADTokenProvider = getBearerTokenProvider(cred, scope);
+const client = new AzureOpenAI({
+  azureADTokenProvider,
+  apiVersion: '2024-10-01-preview',
+  deployment: deploymentName,
+});
+const rt = await OpenAIRealtimeWS.azure(client);
+```
+
+Once the instance has been created, you can then begin sending requests and receiving streaming responses in real time.
+
 ### Retries
 
 Certain errors will be automatically retried 2 times by default, with a short exponential backoff.
diff --git api.md api.md
index 33ab95ef6..516188b20 100644
--- api.md
+++ api.md
@@ -5,6 +5,7 @@ Types:
 - <code><a href="./src/resources/shared.ts">ErrorObject</a></code>
 - <code><a href="./src/resources/shared.ts">FunctionDefinition</a></code>
 - <code><a href="./src/resources/shared.ts">FunctionParameters</a></code>
+- <code><a href="./src/resources/shared.ts">Metadata</a></code>
 - <code><a href="./src/resources/shared.ts">ResponseFormatJSONObject</a></code>
 - <code><a href="./src/resources/shared.ts">ResponseFormatJSONSchema</a></code>
 - <code><a href="./src/resources/shared.ts">ResponseFormatText</a></code>
diff --git examples/azure.ts examples/azure/chat.ts
similarity index 91%
rename from examples/azure.ts
rename to examples/azure/chat.ts
index 5fe1718fa..46df820f8 100755
--- examples/azure.ts
+++ examples/azure/chat.ts
@@ -2,6 +2,7 @@
 
 import { AzureOpenAI } from 'openai';
 import { getBearerTokenProvider, DefaultAzureCredential } from '@azure/identity';
+import 'dotenv/config';
 
 // Corresponds to your Model deployment within your OpenAI resource, e.g. gpt-4-1106-preview
 // Navigate to the Azure OpenAI Studio to deploy a model.
@@ -13,7 +14,7 @@ const azureADTokenProvider = getBearerTokenProvider(credential, scope);
 
 // Make sure to set AZURE_OPENAI_ENDPOINT with the endpoint of your Azure resource.
 // You can find it in the Azure Portal.
-const openai = new AzureOpenAI({ azureADTokenProvider });
+const openai = new AzureOpenAI({ azureADTokenProvider, apiVersion: '2024-10-01-preview' });
 
 async function main() {
   console.log('Non-streaming:');
diff --git a/examples/azure/realtime/websocket.ts b/examples/azure/realtime/websocket.ts
new file mode 100644
index 000000000..bec74e654
--- /dev/null
+++ examples/azure/realtime/websocket.ts
@@ -0,0 +1,60 @@
+import { OpenAIRealtimeWebSocket } from 'openai/beta/realtime/websocket';
+import { AzureOpenAI } from 'openai';
+import { DefaultAzureCredential, getBearerTokenProvider } from '@azure/identity';
+import 'dotenv/config';
+
+async function main() {
+  const cred = new DefaultAzureCredential();
+  const scope = 'https://cognitiveservices.azure.com/.default';
+  const deploymentName = 'gpt-4o-realtime-preview-1001';
+  const azureADTokenProvider = getBearerTokenProvider(cred, scope);
+  const client = new AzureOpenAI({
+    azureADTokenProvider,
+    apiVersion: '2024-10-01-preview',
+    deployment: deploymentName,
+  });
+  const rt = await OpenAIRealtimeWebSocket.azure(client);
+
+  // access the underlying `ws.WebSocket` instance
+  rt.socket.addEventListener('open', () => {
+    console.log('Connection opened!');
+    rt.send({
+      type: 'session.update',
+      session: {
+        modalities: ['text'],
+        model: 'gpt-4o-realtime-preview',
+      },
+    });
+
+    rt.send({
+      type: 'conversation.item.create',
+      item: {
+        type: 'message',
+        role: 'user',
+        content: [{ type: 'input_text', text: 'Say a couple paragraphs!' }],
+      },
+    });
+
+    rt.send({ type: 'response.create' });
+  });
+
+  rt.on('error', (err) => {
+    // in a real world scenario this should be logged somewhere as you
+    // likely want to continue procesing events regardless of any errors
+    throw err;
+  });
+
+  rt.on('session.created', (event) => {
+    console.log('session created!', event.session);
+    console.log();
+  });
+
+  rt.on('response.text.delta', (event) => process.stdout.write(event.delta));
+  rt.on('response.text.done', () => console.log());
+
+  rt.on('response.done', () => rt.close());
+
+  rt.socket.addEventListener('close', () => console.log('\nConnection closed!'));
+}
+
+main();
diff --git a/examples/azure/realtime/ws.ts b/examples/azure/realtime/ws.ts
new file mode 100644
index 000000000..6ab7b742a
--- /dev/null
+++ examples/azure/realtime/ws.ts
@@ -0,0 +1,60 @@
+import { DefaultAzureCredential, getBearerTokenProvider } from '@azure/identity';
+import { OpenAIRealtimeWS } from 'openai/beta/realtime/ws';
+import { AzureOpenAI } from 'openai';
+import 'dotenv/config';
+
+async function main() {
+  const cred = new DefaultAzureCredential();
+  const scope = 'https://cognitiveservices.azure.com/.default';
+  const deploymentName = 'gpt-4o-realtime-preview-1001';
+  const azureADTokenProvider = getBearerTokenProvider(cred, scope);
+  const client = new AzureOpenAI({
+    azureADTokenProvider,
+    apiVersion: '2024-10-01-preview',
+    deployment: deploymentName,
+  });
+  const rt = await OpenAIRealtimeWS.azure(client);
+
+  // access the underlying `ws.WebSocket` instance
+  rt.socket.on('open', () => {
+    console.log('Connection opened!');
+    rt.send({
+      type: 'session.update',
+      session: {
+        modalities: ['text'],
+        model: 'gpt-4o-realtime-preview',
+      },
+    });
+
+    rt.send({
+      type: 'conversation.item.create',
+      item: {
+        type: 'message',
+        role: 'user',
+        content: [{ type: 'input_text', text: 'Say a couple paragraphs!' }],
+      },
+    });
+
+    rt.send({ type: 'response.create' });
+  });
+
+  rt.on('error', (err) => {
+    // in a real world scenario this should be logged somewhere as you
+    // likely want to continue procesing events regardless of any errors
+    throw err;
+  });
+
+  rt.on('session.created', (event) => {
+    console.log('session created!', event.session);
+    console.log();
+  });
+
+  rt.on('response.text.delta', (event) => process.stdout.write(event.delta));
+  rt.on('response.text.done', () => console.log());
+
+  rt.on('response.done', () => rt.close());
+
+  rt.socket.on('close', () => console.log('\nConnection closed!'));
+}
+
+main();
diff --git examples/package.json examples/package.json
index b8c34ac45..70ec2c523 100644
--- examples/package.json
+++ examples/package.json
@@ -7,6 +7,7 @@
   "private": true,
   "dependencies": {
     "@azure/identity": "^4.2.0",
+    "dotenv": "^16.4.7",
     "express": "^4.18.2",
     "next": "^14.1.1",
     "openai": "file:..",
diff --git examples/realtime/ws.ts examples/realtime/ws.ts
index 4bbe85e5d..08c6fbcb6 100644
--- examples/realtime/ws.ts
+++ examples/realtime/ws.ts
@@ -6,13 +6,6 @@ async function main() {
   // access the underlying `ws.WebSocket` instance
   rt.socket.on('open', () => {
     console.log('Connection opened!');
-    rt.send({
-      type: 'session.update',
-      session: {
-        modalities: ['foo'] as any,
-        model: 'gpt-4o-realtime-preview',
-      },
-    });
     rt.send({
       type: 'session.update',
       session: {
diff --git helpers.md helpers.md
index abf980c82..16bc1f277 100644
--- helpers.md
+++ helpers.md
@@ -49,7 +49,7 @@ if (message?.parsed) {
 
 The `.parse()` method will also automatically parse `function` tool calls if:
 
-- You use the `zodFunctionTool()` helper method
+- You use the `zodFunction()` helper method
 - You mark your tool schema with `"strict": True`
 
 For example:
@@ -226,7 +226,7 @@ on in the documentation page [Message](https://platform.openai.com/docs/api-refe
 
 ```ts
 .on('textCreated', (content: Text) => ...)
-.on('textDelta', (delta: RunStepDelta, snapshot: Text) => ...)
+.on('textDelta', (delta: TextDelta, snapshot: Text) => ...)
 .on('textDone', (content: Text, snapshot: Message) => ...)

diff --git jsr.json jsr.json
index e6d772116..7569332ce 100644
--- jsr.json
+++ jsr.json
@@ -1,6 +1,6 @@
{
"name": "@openai/openai",

  • "version": "4.79.4",
  • "version": "4.82.0",
    "exports": {
    ".": "./index.ts",
    "./helpers/zod": "./helpers/zod.ts",
    diff --git package.json package.json
    index d7a5555e5..42e00822d 100644
    --- package.json
    +++ package.json
    @@ -1,6 +1,6 @@
    {
    "name": "openai",
  • "version": "4.79.4",
  • "version": "4.82.0",
    "description": "The official TypeScript library for the OpenAI API",
    "author": "OpenAI [email protected]",
    "types": "dist/index.d.ts",
    diff --git src/beta/realtime/internal-base.ts src/beta/realtime/internal-base.ts
    index 391d69911..b704812ee 100644
    --- src/beta/realtime/internal-base.ts
    +++ src/beta/realtime/internal-base.ts
    @@ -1,6 +1,7 @@
    import { RealtimeClientEvent, RealtimeServerEvent, ErrorEvent } from '../../resources/beta/realtime/realtime';
    import { EventEmitter } from '../../lib/EventEmitter';
    import { OpenAIError } from '../../error';
    +import OpenAI, { AzureOpenAI } from '../../index';

export class OpenAIRealtimeError extends OpenAIError {
/**
@@ -73,11 +74,20 @@ export abstract class OpenAIRealtimeEmitter extends EventEmitter
}
}

-export function buildRealtimeURL(props: { baseURL: string; model: string }): URL {

  • const path = '/realtime';
    +export function isAzure(client: Pick<OpenAI, 'apiKey' | 'baseURL'>): client is AzureOpenAI {
  • return client instanceof AzureOpenAI;
    +}
  • const url = new URL(props.baseURL + (props.baseURL.endsWith('/') ? path.slice(1) : path));
    +export function buildRealtimeURL(client: Pick<OpenAI, 'apiKey' | 'baseURL'>, model: string): URL {
  • const path = '/realtime';
  • const baseURL = client.baseURL;
  • const url = new URL(baseURL + (baseURL.endsWith('/') ? path.slice(1) : path));
    url.protocol = 'wss';
  • url.searchParams.set('model', props.model);
  • if (isAzure(client)) {
  • url.searchParams.set('api-version', client.apiVersion);
  • url.searchParams.set('deployment', model);
  • } else {
  • url.searchParams.set('model', model);
  • }
    return url;
    }
    diff --git src/beta/realtime/websocket.ts src/beta/realtime/websocket.ts
    index e0853779d..349cf5760 100644
    --- src/beta/realtime/websocket.ts
    +++ src/beta/realtime/websocket.ts
    @@ -1,8 +1,8 @@
    -import { OpenAI } from '../../index';
    +import { AzureOpenAI, OpenAI } from '../../index';
    import { OpenAIError } from '../../error';
    import * as Core from '../../core';
    import type { RealtimeClientEvent, RealtimeServerEvent } from '../../resources/beta/realtime/realtime';
    -import { OpenAIRealtimeEmitter, buildRealtimeURL } from './internal-base';
    +import { OpenAIRealtimeEmitter, buildRealtimeURL, isAzure } from './internal-base';

interface MessageEvent {
data: string;
@@ -26,6 +26,11 @@ export class OpenAIRealtimeWebSocket extends OpenAIRealtimeEmitter {
props: {
model: string;
dangerouslyAllowBrowser?: boolean;

  •  /**
    
  •   * Callback to mutate the URL, needed for Azure.
    
  •   * @internal
    
  •   */
    
  •  onURL?: (url: URL) => void;
    

    },
    client?: Pick<OpenAI, 'apiKey' | 'baseURL'>,
    ) {
    @@ -44,11 +49,13 @@ export class OpenAIRealtimeWebSocket extends OpenAIRealtimeEmitter {

    client ??= new OpenAI({ dangerouslyAllowBrowser });

  • this.url = buildRealtimeURL({ baseURL: client.baseURL, model: props.model });
  • this.url = buildRealtimeURL(client, props.model);
  • props.onURL?.(this.url);
  • // @ts-ignore
    this.socket = new WebSocket(this.url, [
    'realtime',
  •  `openai-insecure-api-key.${client.apiKey}`,
    
  •  ...(isAzure(client) ? [] : [`openai-insecure-api-key.${client.apiKey}`]),
     'openai-beta.realtime-v1',
    
    ]);

@@ -77,6 +84,45 @@ export class OpenAIRealtimeWebSocket extends OpenAIRealtimeEmitter {
this.socket.addEventListener('error', (event: any) => {
this._onError(null, event.message, null);
});
+

  • if (isAzure(client)) {
  •  if (this.url.searchParams.get('Authorization') !== null) {
    
  •    this.url.searchParams.set('Authorization', '<REDACTED>');
    
  •  } else {
    
  •    this.url.searchParams.set('api-key', '<REDACTED>');
    
  •  }
    
  • }
  • }
  • static async azure(
  • client: AzureOpenAI,
  • options: { deploymentName?: string; dangerouslyAllowBrowser?: boolean } = {},
  • ): Promise {
  • const token = await client._getAzureADToken();
  • function onURL(url: URL) {
  •  if (client.apiKey !== '<Missing Key>') {
    
  •    url.searchParams.set('api-key', client.apiKey);
    
  •  } else {
    
  •    if (token) {
    
  •      url.searchParams.set('Authorization', `Bearer ${token}`);
    
  •    } else {
    
  •      throw new Error('AzureOpenAI is not instantiated correctly. No API key or token provided.');
    
  •    }
    
  •  }
    
  • }
  • const deploymentName = options.deploymentName ?? client.deploymentName;
  • if (!deploymentName) {
  •  throw new Error('No deployment name provided');
    
  • }
  • const { dangerouslyAllowBrowser } = options;
  • return new OpenAIRealtimeWebSocket(
  •  {
    
  •    model: deploymentName,
    
  •    onURL,
    
  •    ...(dangerouslyAllowBrowser ? { dangerouslyAllowBrowser } : {}),
    
  •  },
    
  •  client,
    
  • );
    }

send(event: RealtimeClientEvent) {
diff --git src/beta/realtime/ws.ts src/beta/realtime/ws.ts
index 631a36cd2..51339089c 100644
--- src/beta/realtime/ws.ts
+++ src/beta/realtime/ws.ts
@@ -1,7 +1,7 @@
import * as WS from 'ws';
-import { OpenAI } from '../../index';
+import { AzureOpenAI, OpenAI } from '../../index';
import type { RealtimeClientEvent, RealtimeServerEvent } from '../../resources/beta/realtime/realtime';
-import { OpenAIRealtimeEmitter, buildRealtimeURL } from './internal-base';
+import { OpenAIRealtimeEmitter, buildRealtimeURL, isAzure } from './internal-base';

export class OpenAIRealtimeWS extends OpenAIRealtimeEmitter {
url: URL;
@@ -14,12 +14,12 @@ export class OpenAIRealtimeWS extends OpenAIRealtimeEmitter {
super();
client ??= new OpenAI();

  • this.url = buildRealtimeURL({ baseURL: client.baseURL, model: props.model });
  • this.url = buildRealtimeURL(client, props.model);
    this.socket = new WS.WebSocket(this.url, {
    ...props.options,
    headers: {
    ...props.options?.headers,
  •    Authorization: `Bearer ${client.apiKey}`,
    
  •    ...(isAzure(client) ? {} : { Authorization: `Bearer ${client.apiKey}` }),
       'OpenAI-Beta': 'realtime=v1',
     },
    

    });
    @@ -51,6 +51,20 @@ export class OpenAIRealtimeWS extends OpenAIRealtimeEmitter {
    });
    }

  • static async azure(

  • client: AzureOpenAI,

  • options: { deploymentName?: string; options?: WS.ClientOptions | undefined } = {},

  • ): Promise {

  • const deploymentName = options.deploymentName ?? client.deploymentName;

  • if (!deploymentName) {

  •  throw new Error('No deployment name provided');
    
  • }

  • return new OpenAIRealtimeWS(

  •  { model: deploymentName, options: { headers: await getAzureHeaders(client) } },
    
  •  client,
    
  • );

  • }

  • send(event: RealtimeClientEvent) {
    try {
    this.socket.send(JSON.stringify(event));
    @@ -67,3 +81,16 @@ export class OpenAIRealtimeWS extends OpenAIRealtimeEmitter {
    }
    }
    }

+async function getAzureHeaders(client: AzureOpenAI) {

  • if (client.apiKey !== '') {
  • return { 'api-key': client.apiKey };
  • } else {
  • const token = await client._getAzureADToken();
  • if (token) {
  •  return { Authorization: `Bearer ${token}` };
    
  • } else {
  •  throw new Error('AzureOpenAI is not instantiated correctly. No API key or token provided.');
    
  • }
  • }
    +}
    diff --git src/index.ts src/index.ts
    index cf6aa89e3..f860579d3 100644
    --- src/index.ts
    +++ src/index.ts
    @@ -451,6 +451,7 @@ export declare namespace OpenAI {
    export type ErrorObject = API.ErrorObject;
    export type FunctionDefinition = API.FunctionDefinition;
    export type FunctionParameters = API.FunctionParameters;
  • export type Metadata = API.Metadata;
    export type ResponseFormatJSONObject = API.ResponseFormatJSONObject;
    export type ResponseFormatJSONSchema = API.ResponseFormatJSONSchema;
    export type ResponseFormatText = API.ResponseFormatText;
    @@ -491,7 +492,7 @@ export interface AzureClientOptions extends ClientOptions {
    /** API Client for interfacing with the Azure OpenAI API. */
    export class AzureOpenAI extends OpenAI {
    private _azureADTokenProvider: (() => Promise) | undefined;
  • private _deployment: string | undefined;
  • deploymentName: string | undefined;
    apiVersion: string = '';
    /**

    • API Client for interfacing with the Azure OpenAI API.
      @@ -574,10 +575,13 @@ export class AzureOpenAI extends OpenAI {

    this._azureADTokenProvider = azureADTokenProvider;
    this.apiVersion = apiVersion;

  • this._deployment = deployment;
  • this.deploymentName = deployment;
    }
  • override buildRequest(options: Core.FinalRequestOptions): {
  • override buildRequest(
  • options: Core.FinalRequestOptions,
  • props: { retryCount?: number } = {},
  • ): {
    req: RequestInit;
    url: string;
    timeout: number;
    @@ -586,15 +590,15 @@ export class AzureOpenAI extends OpenAI {
    if (!Core.isObj(options.body)) {
    throw new Error('Expected request body to be an object');
    }
  •  const model = this._deployment || options.body['model'];
    
  •  const model = this.deploymentName || options.body['model'];
     if (model !== undefined && !this.baseURL.includes('/deployments')) {
       options.path = `/deployments/${model}${options.path}`;
     }
    
    }
  • return super.buildRequest(options);
  • return super.buildRequest(options, props);
    }
  • private async _getAzureADToken(): Promise<string | undefined> {
  • async _getAzureADToken(): Promise<string | undefined> {
    if (typeof this._azureADTokenProvider === 'function') {
    const token = await this._azureADTokenProvider();
    if (!token || typeof token !== 'string') {
    diff --git src/resources/audio/speech.ts src/resources/audio/speech.ts
    index bd2ed9f65..35e82c4c1 100644
    --- src/resources/audio/speech.ts
    +++ src/resources/audio/speech.ts
    @@ -33,12 +33,12 @@ export interface SpeechCreateParams {
    model: (string & {}) | SpeechModel;

    /**

    • The voice to use when generating the audio. Supported voices are alloy,
    • echo, fable, onyx, nova, and shimmer. Previews of the voices are
    • available in the
    • The voice to use when generating the audio. Supported voices are alloy, ash,
    • coral, echo, fable, onyx, nova, sage and shimmer. Previews of the
  • voice: 'alloy' | 'echo' | 'fable' | 'onyx' | 'nova' | 'shimmer';
  • voice: 'alloy' | 'ash' | 'coral' | 'echo' | 'fable' | 'onyx' | 'nova' | 'sage' | 'shimmer';

    /**

    • The format to audio in. Supported formats are mp3, opus, aac, flac,
      diff --git src/resources/audio/transcriptions.ts src/resources/audio/transcriptions.ts
      index 0b6da4620..6d0a07e1e 100644
      --- src/resources/audio/transcriptions.ts
      +++ src/resources/audio/transcriptions.ts
      @@ -166,8 +166,8 @@ export interface TranscriptionCreateParams<

    /**

    • The language of the input audio. Supplying the input language in
    • improve accuracy and latency.
    • format will improve accuracy and latency.
      */
      language?: string;

diff --git src/resources/batches.ts src/resources/batches.ts
index ec5ca6331..aadda83a6 100644
--- src/resources/batches.ts
+++ src/resources/batches.ts
@@ -4,6 +4,7 @@ import { APIResource } from '../resource';
import { isRequestOptions } from '../core';
import * as Core from '../core';
import * as BatchesAPI from './batches';
+import * as Shared from './shared';
import { CursorPage, type CursorPageParams } from '../pagination';

export class Batches extends APIResource {
@@ -138,11 +139,13 @@ export interface Batch {

/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful

    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;

    /**

    • The ID of the file containing the outputs of successfully executed requests.
      @@ -237,9 +240,14 @@ export interface BatchCreateParams {
      input_file_id: string;

    /**

    • Optional custom metadata for the batch.
    • Set of 16 key-value pairs that can be attached to an object. This can be useful
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata?: Record<string, string> | null;
  • metadata?: Shared.Metadata | null;
    }

export interface BatchListParams extends CursorPageParams {}
diff --git src/resources/beta/assistants.ts src/resources/beta/assistants.ts
index 0e657b1d4..69a5db520 100644
--- src/resources/beta/assistants.ts
+++ src/resources/beta/assistants.ts
@@ -111,11 +111,13 @@ export interface Assistant {

/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful

    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata: unknown | null;
  • metadata: Shared.Metadata | null;

    /**

    • ID of the model to use. You can use the
      @@ -1118,11 +1120,13 @@ export interface AssistantCreateParams {

    /**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;

    /**

    • The name of the assistant. The maximum length is 256 characters.
      @@ -1242,12 +1246,14 @@ export namespace AssistantCreateParams {
      file_ids?: Array;

      /**

  •     * Set of 16 key-value pairs that can be attached to a vector store. This can be
    
  •     * useful for storing additional information about the vector store in a structured
    
  •     * format. Keys can be a maximum of 64 characters long and values can be a maxium
    
  •     * of 512 characters long.
    
  •     * Set of 16 key-value pairs that can be attached to an object. This can be useful
    
  •     * for storing additional information about the object in a structured format, and
    
  •     * querying for objects via API or the dashboard.
    
  •     *
    
  •     * Keys are strings with a maximum length of 64 characters. Values are strings with
    
  •     * a maximum length of 512 characters.
        */
    
  •    metadata?: unknown;
    
  •    metadata?: Shared.Metadata | null;
     }
    

    }
    }
    @@ -1267,11 +1273,13 @@ export interface AssistantUpdateParams {

    /**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;

    /**

    • ID of the model to use. You can use the
      diff --git src/resources/beta/realtime/realtime.ts src/resources/beta/realtime/realtime.ts
      index 5de06917a..c666221e1 100644
      --- src/resources/beta/realtime/realtime.ts
      +++ src/resources/beta/realtime/realtime.ts
      @@ -2,6 +2,7 @@

import { APIResource } from '../../../resource';
import * as RealtimeAPI from './realtime';
+import * as Shared from '../../shared';
import * as SessionsAPI from './sessions';
import {
Session as SessionsAPISession,
@@ -173,9 +174,10 @@ export interface ConversationItemCreateEvent {

/**
* The ID of the preceding item after which the new item will be inserted. If not

    • set, the new item will be appended to the end of the conversation. If set, it
    • allows an item to be inserted mid-conversation. If the ID cannot be found, an
    • error will be returned and the item will not be added.
    • set, the new item will be appended to the end of the conversation. If set to
    • root, the new item will be added to the beginning of the conversation. If set
    • to an existing ID, it allows an item to be inserted mid-conversation. If the ID
    • cannot be found, an error will be returned and the item will not be added.
      */
      previous_item_id?: string;
      }
      @@ -740,9 +742,38 @@ export interface RealtimeResponse {
      id?: string;

/**

    • Developer-provided string key-value pairs associated with this response.
    • Which conversation the response is added to, determined by the conversation
    • field in the response.create event. If auto, the response will be added to
    • the default conversation and the value of conversation_id will be an id like
    • conv_1234. If none, the response will not be added to any conversation and
    • the value of conversation_id will be null. If responses are being triggered
    • by server VAD, the response will be added to the default conversation, thus the
    • conversation_id will be an id like conv_1234.
      */
  • metadata?: unknown | null;
  • conversation_id?: string;

  • /**

    • Maximum number of output tokens for a single assistant response, inclusive of
    • tool calls, that was used in this response.
  • */

  • max_output_tokens?: number | 'inf';

  • /**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
  • */

  • metadata?: Shared.Metadata | null;

  • /**

    • The set of modalities the model used to respond. If there are multiple
    • modalities, the model will pick one, for example if modalities is
    • ["text", "audio"], the model could be responding in either text or audio.
  • */

  • modalities?: Array<'text' | 'audio'>;

    /**

    • The object type, must be realtime.response.
      @@ -754,6 +785,11 @@ export interface RealtimeResponse {
      */
      output?: Array;
  • /**

    • The format of output audio. Options are pcm16, g711_ulaw, or g711_alaw.
  • */

  • output_audio_format?: 'pcm16' | 'g711_ulaw' | 'g711_alaw';

  • /**

    • The final status of the response (completed, cancelled, failed, or
    • incomplete).
      @@ -765,6 +801,11 @@ export interface RealtimeResponse {
      */
      status_details?: RealtimeResponseStatus;
  • /**

    • Sampling temperature for the model, limited to [0.6, 1.2]. Defaults to 0.8.
  • */

  • temperature?: number;

  • /**

    • Usage statistics for the Response, this will correspond to billing. A Realtime
    • API session will maintain a conversation context and append new Items to the
      @@ -772,6 +813,12 @@ export interface RealtimeResponse {
    • become the input for later turns.
      */
      usage?: RealtimeResponseUsage;
  • /**

    • The voice the model used to respond. Current voice options are alloy, ash,
    • ballad, coral, echo sage, shimmer and verse.
  • */

  • voice?: 'alloy' | 'ash' | 'ballad' | 'coral' | 'echo' | 'sage' | 'shimmer' | 'verse';
    }

/**
@@ -1319,11 +1366,13 @@ export namespace ResponseCreateEvent {

 /**
  * Set of 16 key-value pairs that can be attached to an object. This can be useful
  • * for storing additional information about the object in a structured format. Keys
    
  • * can be a maximum of 64 characters long and values can be a maximum of 512
    
  • * characters long.
    
  • * for storing additional information about the object in a structured format, and
    
  • * querying for objects via API or the dashboard.
    
  • *
    
  • * Keys are strings with a maximum length of 64 characters. Values are strings with
    
  • * a maximum length of 512 characters.
    */
    
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;

    /**

    • The set of modalities the model can respond with. To disable audio, set this to
      @@ -1705,17 +1754,9 @@ export namespace SessionUpdateEvent {
      /
      export interface Session {
      /
      *
  • * The Realtime model used for this session.
    
  • */
    
  • model:
  •  | 'gpt-4o-realtime-preview'
    
  •  | 'gpt-4o-realtime-preview-2024-10-01'
    
  •  | 'gpt-4o-realtime-preview-2024-12-17'
    
  •  | 'gpt-4o-mini-realtime-preview'
    
  •  | 'gpt-4o-mini-realtime-preview-2024-12-17';
    
  • /**
  • * The format of input audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`.
    
  • * The format of input audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`. For
    
  • * `pcm16`, input audio must be 16-bit PCM at a 24kHz sample rate, single channel
    
  • * (mono), and little-endian byte order.
    */
    
    input_audio_format?: 'pcm16' | 'g711_ulaw' | 'g711_alaw';

@@ -1723,8 +1764,11 @@ export namespace SessionUpdateEvent {
* Configuration for input audio transcription, defaults to off and can be set to
* null to turn off once on. Input audio transcription is not native to the
* model, since the model consumes audio directly. Transcription runs

  • * asynchronously through Whisper and should be treated as rough guidance rather
    
  • * than the representation understood by the model.
    
  • * asynchronously through
    
  • * [OpenAI Whisper transcription](https://platform.openai.com/docs/api-reference/audio/createTranscription)
    
  • * and should be treated as rough guidance rather than the representation
    
  • * understood by the model. The client can optionally set the language and prompt
    
  • * for transcription, these fields will be passed to the Whisper API.
    */
    
    input_audio_transcription?: Session.InputAudioTranscription;

@@ -1756,8 +1800,19 @@ export namespace SessionUpdateEvent {
*/
modalities?: Array<'text' | 'audio'>;

  • /**
  • * The Realtime model used for this session.
    
  • */
    
  • model?:
  •  | 'gpt-4o-realtime-preview'
    
  •  | 'gpt-4o-realtime-preview-2024-10-01'
    
  •  | 'gpt-4o-realtime-preview-2024-12-17'
    
  •  | 'gpt-4o-mini-realtime-preview'
    
  •  | 'gpt-4o-mini-realtime-preview-2024-12-17';
    
  • /**
    * The format of output audio. Options are pcm16, g711_ulaw, or g711_alaw.
  • * For `pcm16`, output audio is sampled at a rate of 24kHz.
    */
    
    output_audio_format?: 'pcm16' | 'g711_ulaw' | 'g711_alaw';

@@ -1797,15 +1852,33 @@ export namespace SessionUpdateEvent {
* Configuration for input audio transcription, defaults to off and can be set to
* null to turn off once on. Input audio transcription is not native to the
* model, since the model consumes audio directly. Transcription runs

  • * asynchronously through Whisper and should be treated as rough guidance rather
    
  • * than the representation understood by the model.
    
  • * asynchronously through
    
  • * [OpenAI Whisper transcription](https://platform.openai.com/docs/api-reference/audio/createTranscription)
    
  • * and should be treated as rough guidance rather than the representation
    
  • * understood by the model. The client can optionally set the language and prompt
    
  • * for transcription, these fields will be passed to the Whisper API.
    */
    

    export interface InputAudioTranscription {

  •  /**
    
  •   * The language of the input audio. Supplying the input language in
    
  •   * [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. `en`)
    
  •   * format will improve accuracy and latency.
    
  •   */
    
  •  language?: string;
    
  •  /**
      * The model to use for transcription, `whisper-1` is the only currently supported
      * model.
      */
     model?: string;
    
  •  /**
    
  •   * An optional text to guide the model's style or continue a previous audio
    
  •   * segment. The
    
  •   * [prompt](https://platform.openai.com/docs/guides/speech-to-text#prompting)
    
  •   * should match the audio language.
    
  •   */
    
  •  prompt?: string;
    

    }

    export interface Tool {
    diff --git src/resources/beta/realtime/sessions.ts src/resources/beta/realtime/sessions.ts
    index c1082d236..d2afa25b1 100644
    --- src/resources/beta/realtime/sessions.ts
    +++ src/resources/beta/realtime/sessions.ts
    @@ -32,7 +32,9 @@ export interface Session {
    id?: string;

    /**

    • The format of input audio. Options are pcm16, g711_ulaw, or g711_alaw.
    • The format of input audio. Options are pcm16, g711_ulaw, or g711_alaw. For
    • pcm16, input audio must be 16-bit PCM at a 24kHz sample rate, single channel
    • (mono), and little-endian byte order.
      */
      input_audio_format?: 'pcm16' | 'g711_ulaw' | 'g711_alaw';

@@ -86,6 +88,7 @@ export interface Session {

/**
* The format of output audio. Options are pcm16, g711_ulaw, or g711_alaw.

    • For pcm16, output audio is sampled at a rate of 24kHz.
      */
      output_audio_format?: 'pcm16' | 'g711_ulaw' | 'g711_alaw';

@@ -200,7 +203,7 @@ export interface SessionCreateResponse {
/**
* Ephemeral key returned by the API.
*/

  • client_secret?: SessionCreateResponse.ClientSecret;
  • client_secret: SessionCreateResponse.ClientSecret;

    /**

    • The format of input audio. Options are pcm16, g711_ulaw, or g711_alaw.
      @@ -289,14 +292,14 @@ export namespace SessionCreateResponse {
      • Timestamp for when the token expires. Currently, all tokens expire after one
      • minute.
        */
  • expires_at?: number;
  • expires_at: number;

    /**

    • Ephemeral key usable in client environments to authenticate connections to the
    • Realtime API. Use this in client-side environments rather than a standard API
    • token, which should only be used server-side.
      */
  • value?: string;
  • value: string;
    }

/**
@@ -372,17 +375,9 @@ export namespace SessionCreateResponse {

export interface SessionCreateParams {
/**

    • The Realtime model used for this session.
  • */
  • model:
  • | 'gpt-4o-realtime-preview'
  • | 'gpt-4o-realtime-preview-2024-10-01'
  • | 'gpt-4o-realtime-preview-2024-12-17'
  • | 'gpt-4o-mini-realtime-preview'
  • | 'gpt-4o-mini-realtime-preview-2024-12-17';
  • /**
    • The format of input audio. Options are pcm16, g711_ulaw, or g711_alaw.
    • The format of input audio. Options are pcm16, g711_ulaw, or g711_alaw. For
    • pcm16, input audio must be 16-bit PCM at a 24kHz sample rate, single channel
    • (mono), and little-endian byte order.
      */
      input_audio_format?: 'pcm16' | 'g711_ulaw' | 'g711_alaw';

@@ -390,8 +385,11 @@ export interface SessionCreateParams {
* Configuration for input audio transcription, defaults to off and can be set to
* null to turn off once on. Input audio transcription is not native to the
* model, since the model consumes audio directly. Transcription runs

    • asynchronously through Whisper and should be treated as rough guidance rather
    • than the representation understood by the model.
    • asynchronously through
    • and should be treated as rough guidance rather than the representation
    • understood by the model. The client can optionally set the language and prompt
    • for transcription, these fields will be passed to the Whisper API.
      */
      input_audio_transcription?: SessionCreateParams.InputAudioTranscription;

@@ -423,8 +421,19 @@ export interface SessionCreateParams {
*/
modalities?: Array<'text' | 'audio'>;

  • /**
    • The Realtime model used for this session.
  • */
  • model?:
  • | 'gpt-4o-realtime-preview'
  • | 'gpt-4o-realtime-preview-2024-10-01'
  • | 'gpt-4o-realtime-preview-2024-12-17'
  • | 'gpt-4o-mini-realtime-preview'
  • | 'gpt-4o-mini-realtime-preview-2024-12-17';
  • /**
    • The format of output audio. Options are pcm16, g711_ulaw, or g711_alaw.
    • For pcm16, output audio is sampled at a rate of 24kHz.
      */
      output_audio_format?: 'pcm16' | 'g711_ulaw' | 'g711_alaw';

@@ -464,15 +473,33 @@ export namespace SessionCreateParams {
* Configuration for input audio transcription, defaults to off and can be set to
* null to turn off once on. Input audio transcription is not native to the
* model, since the model consumes audio directly. Transcription runs

    • asynchronously through Whisper and should be treated as rough guidance rather
    • than the representation understood by the model.
    • asynchronously through
    • and should be treated as rough guidance rather than the representation
    • understood by the model. The client can optionally set the language and prompt
    • for transcription, these fields will be passed to the Whisper API.
      */
      export interface InputAudioTranscription {
  • /**
  • * The language of the input audio. Supplying the input language in
    
  • * [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. `en`)
    
  • * format will improve accuracy and latency.
    
  • */
    
  • language?: string;
  • /**
    * The model to use for transcription, whisper-1 is the only currently supported
    * model.
    */
    model?: string;
  • /**
  • * An optional text to guide the model's style or continue a previous audio
    
  • * segment. The
    
  • * [prompt](https://platform.openai.com/docs/guides/speech-to-text#prompting)
    
  • * should match the audio language.
    
  • */
    
  • prompt?: string;
    }

export interface Tool {
diff --git src/resources/beta/threads/messages.ts src/resources/beta/threads/messages.ts
index 8124f56cd..29fd2b29f 100644
--- src/resources/beta/threads/messages.ts
+++ src/resources/beta/threads/messages.ts
@@ -3,6 +3,7 @@
import { APIResource } from '../../../resource';
import { isRequestOptions } from '../../../core';
import * as Core from '../../../core';
+import * as Shared from '../../shared';
import * as AssistantsAPI from '../assistants';
import { CursorPage, type CursorPageParams } from '../../../pagination';

@@ -407,11 +408,13 @@ export interface Message {

/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful

    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata: unknown | null;
  • metadata: Shared.Metadata | null;

    /**

    • The object type, which is always thread.message.
      @@ -660,11 +663,13 @@ export interface MessageCreateParams {

    /**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;
    }

export namespace MessageCreateParams {
@@ -693,11 +698,13 @@ export namespace MessageCreateParams {
export interface MessageUpdateParams {
/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful

    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;
    }

export interface MessageListParams extends CursorPageParams {
diff --git src/resources/beta/threads/runs/runs.ts src/resources/beta/threads/runs/runs.ts
index 814ad3e89..84ba7b63c 100644
--- src/resources/beta/threads/runs/runs.ts
+++ src/resources/beta/threads/runs/runs.ts
@@ -8,6 +8,7 @@ import { AssistantStream, RunCreateParamsBaseStream } from '../../../../lib/Assi
import { sleep } from '../../../../core';
import { RunSubmitToolOutputsParamsStream } from '../../../../lib/AssistantStream';
import * as RunsAPI from './runs';
+import * as Shared from '../../../shared';
import * as AssistantsAPI from '../../assistants';
import * as ChatAPI from '../../../chat/chat';
import * as MessagesAPI from '../messages';
@@ -415,11 +416,13 @@ export interface Run {

/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful

    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata: unknown | null;
  • metadata: Shared.Metadata | null;

    /**

    • The model that the
      @@ -705,10 +708,12 @@ export interface RunCreateParamsBase {
      /**
    • Body param: Set of 16 key-value pairs that can be attached to an object. This
    • can be useful for storing additional information about the object in a
    • structured format. Keys can be a maximum of 64 characters long and values can be
    • a maxium of 512 characters long.
    • structured format, and querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;

    /**

    • Body param: The ID of the
      @@ -823,11 +828,13 @@ export namespace RunCreateParams {

    /**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
  • * for storing additional information about the object in a structured format. Keys
    
  • * can be a maximum of 64 characters long and values can be a maxium of 512
    
  • * characters long.
    
  • * for storing additional information about the object in a structured format, and
    
  • * querying for objects via API or the dashboard.
    
  • *
    
  • * Keys are strings with a maximum length of 64 characters. Values are strings with
    
  • * a maximum length of 512 characters.
    */
    
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;
    }

export namespace AdditionalMessage {
@@ -898,11 +905,13 @@ export interface RunCreateParamsStreaming extends RunCreateParamsBase {
export interface RunUpdateParams {
/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful

    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;
    }

export interface RunListParams extends CursorPageParams {
diff --git src/resources/beta/threads/runs/steps.ts src/resources/beta/threads/runs/steps.ts
index 6c6722b62..c491b4e83 100644
--- src/resources/beta/threads/runs/steps.ts
+++ src/resources/beta/threads/runs/steps.ts
@@ -4,6 +4,7 @@ import { APIResource } from '../../../../resource';
import { isRequestOptions } from '../../../../core';
import * as Core from '../../../../core';
import * as StepsAPI from './steps';
+import * as Shared from '../../../shared';
import { CursorPage, type CursorPageParams } from '../../../../pagination';

export class Steps extends APIResource {
@@ -515,11 +516,13 @@ export interface RunStep {

/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful

    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata: unknown | null;
  • metadata: Shared.Metadata | null;

    /**

    • The object type, which is always thread.run.step.
      diff --git src/resources/beta/threads/threads.ts src/resources/beta/threads/threads.ts
      index 453d8fa10..3f69c6e60 100644
      --- src/resources/beta/threads/threads.ts
      +++ src/resources/beta/threads/threads.ts
      @@ -250,11 +250,13 @@ export interface Thread {

    /**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata: unknown | null;
  • metadata: Shared.Metadata | null;

    /**

    • The object type, which is always thread.
      @@ -322,11 +324,13 @@ export interface ThreadCreateParams {

    /**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;

    /**

    • A set of resources that are made available to the assistant's tools in this
      @@ -361,11 +365,13 @@ export namespace ThreadCreateParams {

    /**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
  • * for storing additional information about the object in a structured format. Keys
    
  • * can be a maximum of 64 characters long and values can be a maxium of 512
    
  • * characters long.
    
  • * for storing additional information about the object in a structured format, and
    
  • * querying for objects via API or the dashboard.
    
  • *
    
  • * Keys are strings with a maximum length of 64 characters. Values are strings with
    
  • * a maximum length of 512 characters.
    */
    
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;
    }

export namespace Message {
@@ -447,12 +453,14 @@ export namespace ThreadCreateParams {
file_ids?: Array;

     /**
  •     * Set of 16 key-value pairs that can be attached to a vector store. This can be
    
  •     * useful for storing additional information about the vector store in a structured
    
  •     * format. Keys can be a maximum of 64 characters long and values can be a maxium
    
  •     * of 512 characters long.
    
  •     * Set of 16 key-value pairs that can be attached to an object. This can be useful
    
  •     * for storing additional information about the object in a structured format, and
    
  •     * querying for objects via API or the dashboard.
    
  •     *
    
  •     * Keys are strings with a maximum length of 64 characters. Values are strings with
    
  •     * a maximum length of 512 characters.
        */
    
  •    metadata?: unknown;
    
  •    metadata?: Shared.Metadata | null;
     }
    
    }
    }
    @@ -461,11 +469,13 @@ export namespace ThreadCreateParams {
    export interface ThreadUpdateParams {
    /**
    • Set of 16 key-value pairs that can be attached to an object. This can be useful
    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;

    /**

    • A set of resources that are made available to the assistant's tools in this
      @@ -549,11 +559,13 @@ export interface ThreadCreateAndRunParamsBase {

    /**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;

    /**

    • The ID of the Model to
      @@ -609,7 +621,8 @@ export interface ThreadCreateAndRunParamsBase {
      temperature?: number | null;

    /**

    • If no thread is provided, an empty thread will be created.
    • Options to create a new thread. If no thread is provided when running a request,
    • an empty thread will be created.
      */
      thread?: ThreadCreateAndRunParams.Thread;

@@ -658,7 +671,8 @@ export interface ThreadCreateAndRunParamsBase {

export namespace ThreadCreateAndRunParams {
/**

    • If no thread is provided, an empty thread will be created.
    • Options to create a new thread. If no thread is provided when running a request,
    • an empty thread will be created.
      /
      export interface Thread {
      /
      *
      @@ -669,11 +683,13 @@ export namespace ThreadCreateAndRunParams {

    /**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
  • * for storing additional information about the object in a structured format. Keys
    
  • * can be a maximum of 64 characters long and values can be a maxium of 512
    
  • * characters long.
    
  • * for storing additional information about the object in a structured format, and
    
  • * querying for objects via API or the dashboard.
    
  • *
    
  • * Keys are strings with a maximum length of 64 characters. Values are strings with
    
  • * a maximum length of 512 characters.
    */
    
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;

    /**

    • A set of resources that are made available to the assistant's tools in this
      @@ -708,11 +724,13 @@ export namespace ThreadCreateAndRunParams {

    /**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
  •   * for storing additional information about the object in a structured format. Keys
    
  •   * can be a maximum of 64 characters long and values can be a maxium of 512
    
  •   * characters long.
    
  •   * for storing additional information about the object in a structured format, and
    
  •   * querying for objects via API or the dashboard.
    
  •   *
    
  •   * Keys are strings with a maximum length of 64 characters. Values are strings with
    
  •   * a maximum length of 512 characters.
      */
    
  •  metadata?: unknown | null;
    
  •  metadata?: Shared.Metadata | null;
    

    }

    export namespace Message {
    @@ -794,12 +812,14 @@ export namespace ThreadCreateAndRunParams {
    file_ids?: Array;

         /**
    
  •       * Set of 16 key-value pairs that can be attached to a vector store. This can be
    
  •       * useful for storing additional information about the vector store in a structured
    
  •       * format. Keys can be a maximum of 64 characters long and values can be a maxium
    
  •       * of 512 characters long.
    
  •       * Set of 16 key-value pairs that can be attached to an object. This can be useful
    
  •       * for storing additional information about the object in a structured format, and
    
  •       * querying for objects via API or the dashboard.
    
  •       *
    
  •       * Keys are strings with a maximum length of 64 characters. Values are strings with
    
  •       * a maximum length of 512 characters.
          */
    
  •      metadata?: unknown;
    
  •      metadata?: Shared.Metadata | null;
       }
     }
    

    }
    diff --git src/resources/beta/vector-stores/vector-stores.ts src/resources/beta/vector-stores/vector-stores.ts
    index cbff2d562..8438b79da 100644
    --- src/resources/beta/vector-stores/vector-stores.ts
    +++ src/resources/beta/vector-stores/vector-stores.ts
    @@ -3,6 +3,7 @@
    import { APIResource } from '../../../resource';
    import { isRequestOptions } from '../../../core';
    import * as Core from '../../../core';
    +import * as Shared from '../../shared';
    import * as FileBatchesAPI from './file-batches';
    import {
    FileBatchCreateParams,
    @@ -187,11 +188,13 @@ export interface VectorStore {

    /**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata: unknown | null;
  • metadata: Shared.Metadata | null;

    /**

    • The name of the vector store.
      @@ -300,11 +303,13 @@ export interface VectorStoreCreateParams {

    /**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;

    /**

    • The name of the vector store.
      @@ -338,11 +343,13 @@ export interface VectorStoreUpdateParams {

    /**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;

    /**

    • The name of the vector store.
      diff --git src/resources/chat/chat.ts src/resources/chat/chat.ts
      index 2230b19bd..d4a18929c 100644
      --- src/resources/chat/chat.ts
      +++ src/resources/chat/chat.ts
      @@ -46,6 +46,8 @@ export class Chat extends APIResource {
      }

export type ChatModel =

  • | 'o3-mini'

  • | 'o3-mini-2025-01-31'
    | 'o1'
    | 'o1-2024-12-17'
    | 'o1-preview'
    diff --git src/resources/chat/completions.ts src/resources/chat/completions.ts
    index 88c778036..d2de11458 100644
    --- src/resources/chat/completions.ts
    +++ src/resources/chat/completions.ts
    @@ -76,8 +76,7 @@ export interface ChatCompletion {
    object: 'chat.completion';

    /**

    • The service tier used for processing the request. This field is only included if
    • the service_tier parameter is specified in the request.
    • The service tier used for processing the request.
      */
      service_tier?: 'scale' | 'default' | null;

@@ -300,8 +299,7 @@ export interface ChatCompletionChunk {
object: 'chat.completion.chunk';

/**

    • The service tier used for processing the request. This field is only included if
    • the service_tier parameter is specified in the request.
    • The service tier used for processing the request.
      */
      service_tier?: 'scale' | 'default' | null;

@@ -1014,10 +1012,14 @@ export interface ChatCompletionCreateParamsBase {
max_tokens?: number | null;

/**

    • Developer-defined tags and values used for filtering completions in the
    • Set of 16 key-value pairs that can be attached to an object. This can be useful
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum ,length of 512 characters.
      */
  • metadata?: Record<string, string> | null;
  • metadata?: Shared.Metadata | null;

    /**

    • Output types that you would like the model to generate for this request. Most
      @@ -1111,13 +1113,10 @@ export interface ChatCompletionCreateParamsBase {
    • utilize scale tier credits until they are exhausted.
      • If set to 'auto', and the Project is not Scale tier enabled, the request will
    • be processed using the default service tier with a lower uptime SLA and no
    • latency guarentee.
    • latency guarantee.
      • If set to 'default', the request will be processed using the default service
    • tier with a lower uptime SLA and no latency guarentee.
    • tier with a lower uptime SLA and no latency guarantee.
      • When not set, the default behavior is 'auto'.
    • When this parameter is set, the response body will include the service_tier
    • utilized.
      */
      service_tier?: 'auto' | 'default' | null;

diff --git src/resources/embeddings.ts src/resources/embeddings.ts
index 4b1644a68..d01ffc807 100644
--- src/resources/embeddings.ts
+++ src/resources/embeddings.ts
@@ -86,7 +86,8 @@ export interface EmbeddingCreateParams {
* text-embedding-ada-002), cannot be an empty string, and any array must be 2048
* dimensions or less.
* Example Python code

    • for counting tokens.
    • for counting tokens. Some models may also impose a limit on total number of
    • tokens summed across inputs.
      */
      input: string | Array | Array | Array<Array>;

diff --git src/resources/shared.ts src/resources/shared.ts
index f44fda8a7..3bb11582f 100644
--- src/resources/shared.ts
+++ src/resources/shared.ts
@@ -55,6 +55,16 @@ export interface FunctionDefinition {
*/
export type FunctionParameters = Record<string, unknown>;

+/**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
  • */
    +export type Metadata = Record<string, string>;

export interface ResponseFormatJSONObject {
/**
* The type of response format being defined: json_object
diff --git src/resources/uploads/uploads.ts src/resources/uploads/uploads.ts
index 8491d0fe2..bfe752cd7 100644
--- src/resources/uploads/uploads.ts
+++ src/resources/uploads/uploads.ts
@@ -113,7 +113,7 @@ export interface Upload {
status: 'pending' | 'completed' | 'cancelled' | 'expired';

/**

    • The ready File object after the Upload is completed.
    • The File object represents a document that has been uploaded to OpenAI.
      */
      file?: FilesAPI.FileObject | null;
      }
      diff --git src/version.ts src/version.ts
      index e8b9601ed..07241a8cf 100644
      --- src/version.ts
      +++ src/version.ts
      @@ -1 +1 @@
      -export const VERSION = '4.79.4'; // x-release-please-version
      +export const VERSION = '4.82.0'; // x-release-please-version
      diff --git tests/api-resources/beta/assistants.test.ts tests/api-resources/beta/assistants.test.ts
      index a64465c77..88a10ba8f 100644
      --- tests/api-resources/beta/assistants.test.ts
      +++ tests/api-resources/beta/assistants.test.ts
      @@ -25,7 +25,7 @@ describe('resource assistants', () => {
      model: 'gpt-4o',
      description: 'description',
      instructions: 'instructions',
  •  metadata: {},
    
  •  metadata: { foo: 'string' },
     name: 'name',
     response_format: 'auto',
     temperature: 1,
    

@@ -33,7 +33,9 @@ describe('resource assistants', () => {
code_interpreter: { file_ids: ['string'] },
file_search: {
vector_store_ids: ['string'],

  •      vector_stores: [{ chunking_strategy: { type: 'auto' }, file_ids: ['string'], metadata: {} }],
    
  •      vector_stores: [
    
  •        { chunking_strategy: { type: 'auto' }, file_ids: ['string'], metadata: { foo: 'string' } },
    
  •      ],
       },
     },
     tools: [{ type: 'code_interpreter' }],
    

diff --git tests/api-resources/beta/realtime/sessions.test.ts tests/api-resources/beta/realtime/sessions.test.ts
index 0ed998c27..dbb92ead3 100644
--- tests/api-resources/beta/realtime/sessions.test.ts
+++ tests/api-resources/beta/realtime/sessions.test.ts
@@ -9,8 +9,8 @@ const client = new OpenAI({
});

describe('resource sessions', () => {

  • test('create: only required params', async () => {
  • const responsePromise = client.beta.realtime.sessions.create({ model: 'gpt-4o-realtime-preview' });
  • test('create', async () => {
  • const responsePromise = client.beta.realtime.sessions.create({});
    const rawResponse = await responsePromise.asResponse();
    expect(rawResponse).toBeInstanceOf(Response);
    const response = await responsePromise;
    @@ -19,27 +19,4 @@ describe('resource sessions', () => {
    expect(dataAndResponse.data).toBe(response);
    expect(dataAndResponse.response).toBe(rawResponse);
    });
  • test('create: required and optional params', async () => {
  • const response = await client.beta.realtime.sessions.create({
  •  model: 'gpt-4o-realtime-preview',
    
  •  input_audio_format: 'pcm16',
    
  •  input_audio_transcription: { model: 'model' },
    
  •  instructions: 'instructions',
    
  •  max_response_output_tokens: 0,
    
  •  modalities: ['text'],
    
  •  output_audio_format: 'pcm16',
    
  •  temperature: 0,
    
  •  tool_choice: 'tool_choice',
    
  •  tools: [{ description: 'description', name: 'name', parameters: {}, type: 'function' }],
    
  •  turn_detection: {
    
  •    create_response: true,
    
  •    prefix_padding_ms: 0,
    
  •    silence_duration_ms: 0,
    
  •    threshold: 0,
    
  •    type: 'type',
    
  •  },
    
  •  voice: 'alloy',
    
  • });
  • });
    });
    diff --git tests/api-resources/beta/threads/messages.test.ts tests/api-resources/beta/threads/messages.test.ts
    index c1f5f7b6e..e125edd84 100644
    --- tests/api-resources/beta/threads/messages.test.ts
    +++ tests/api-resources/beta/threads/messages.test.ts
    @@ -28,7 +28,7 @@ describe('resource messages', () => {
    content: 'string',
    role: 'user',
    attachments: [{ file_id: 'file_id', tools: [{ type: 'code_interpreter' }] }],
  •  metadata: {},
    
  •  metadata: { foo: 'string' },
    
    });
    });

diff --git tests/api-resources/beta/threads/runs/runs.test.ts tests/api-resources/beta/threads/runs/runs.test.ts
index 4fd8261ac..9b728403f 100644
--- tests/api-resources/beta/threads/runs/runs.test.ts
+++ tests/api-resources/beta/threads/runs/runs.test.ts
@@ -30,13 +30,13 @@ describe('resource runs', () => {
content: 'string',
role: 'user',
attachments: [{ file_id: 'file_id', tools: [{ type: 'code_interpreter' }] }],

  •      metadata: {},
    
  •      metadata: { foo: 'string' },
       },
     ],
     instructions: 'instructions',
     max_completion_tokens: 256,
     max_prompt_tokens: 256,
    
  •  metadata: {},
    
  •  metadata: { foo: 'string' },
     model: 'gpt-4o',
     parallel_tool_calls: true,
     response_format: 'auto',
    

diff --git tests/api-resources/beta/threads/threads.test.ts tests/api-resources/beta/threads/threads.test.ts
index aba266316..f26d6ec44 100644
--- tests/api-resources/beta/threads/threads.test.ts
+++ tests/api-resources/beta/threads/threads.test.ts
@@ -37,15 +37,17 @@ describe('resource threads', () => {
content: 'string',
role: 'user',
attachments: [{ file_id: 'file_id', tools: [{ type: 'code_interpreter' }] }],

  •          metadata: {},
    
  •          metadata: { foo: 'string' },
           },
         ],
    
  •      metadata: {},
    
  •      metadata: { foo: 'string' },
         tool_resources: {
           code_interpreter: { file_ids: ['string'] },
           file_search: {
             vector_store_ids: ['string'],
    
  •          vector_stores: [{ chunking_strategy: { type: 'auto' }, file_ids: ['string'], metadata: {} }],
    
  •          vector_stores: [
    
  •            { chunking_strategy: { type: 'auto' }, file_ids: ['string'], metadata: { foo: 'string' } },
    
  •          ],
           },
         },
       },
    

@@ -118,7 +120,7 @@ describe('resource threads', () => {
instructions: 'instructions',
max_completion_tokens: 256,
max_prompt_tokens: 256,

  •  metadata: {},
    
  •  metadata: { foo: 'string' },
     model: 'gpt-4o',
     parallel_tool_calls: true,
     response_format: 'auto',
    

@@ -130,15 +132,17 @@ describe('resource threads', () => {
content: 'string',
role: 'user',
attachments: [{ file_id: 'file_id', tools: [{ type: 'code_interpreter' }] }],

  •        metadata: {},
    
  •        metadata: { foo: 'string' },
         },
       ],
    
  •    metadata: {},
    
  •    metadata: { foo: 'string' },
       tool_resources: {
         code_interpreter: { file_ids: ['string'] },
         file_search: {
           vector_store_ids: ['string'],
    
  •        vector_stores: [{ chunking_strategy: { type: 'auto' }, file_ids: ['string'], metadata: {} }],
    
  •        vector_stores: [
    
  •          { chunking_strategy: { type: 'auto' }, file_ids: ['string'], metadata: { foo: 'string' } },
    
  •        ],
         },
       },
     },
    

diff --git tests/api-resources/chat/completions.test.ts tests/api-resources/chat/completions.test.ts
index dfc09f69b..8f1bc7d4c 100644
--- tests/api-resources/chat/completions.test.ts
+++ tests/api-resources/chat/completions.test.ts
@@ -43,7 +43,7 @@ describe('resource completions', () => {
presence_penalty: -2,
reasoning_effort: 'low',
response_format: { type: 'text' },

  •  seed: -9007199254740991,
    
  •  seed: 0,
     service_tier: 'auto',
     stop: 'string',
     store: true,
    

diff --git tests/api-resources/completions.test.ts tests/api-resources/completions.test.ts
index 82322dc3a..c98501a87 100644
--- tests/api-resources/completions.test.ts
+++ tests/api-resources/completions.test.ts
@@ -32,7 +32,7 @@ describe('resource completions', () => {
max_tokens: 16,
n: 1,
presence_penalty: -2,

  •  seed: -9007199254740991,
    
  •  seed: 0,
     stop: '\n',
     stream: false,
     stream_options: { include_usage: true },
    

diff --git tests/lib/azure.test.ts tests/lib/azure.test.ts
index 064a0098c..0e3c2c5a3 100644
--- tests/lib/azure.test.ts
+++ tests/lib/azure.test.ts
@@ -51,6 +51,18 @@ describe('instantiate azure client', () => {
});
expect(req.headers as Headers).not.toHaveProperty('x-my-default-header');
});
+

  • test('includes retry count', () => {
  •  const { req } = client.buildRequest(
    
  •    {
    
  •      path: '/foo',
    
  •      method: 'post',
    
  •      headers: { 'X-My-Default-Header': null },
    
  •    },
    
  •    { retryCount: 1 },
    
  •  );
    
  •  expect((req.headers as Headers)['x-stainless-retry-count']).toEqual('1');
    
  • });
    });

describe('defaultQuery', () => {


</details>

### Description
This PR implements several significant updates to the OpenAI Node.js SDK, including:
1. Azure Realtime API support with WebSocket connections
2. Updated metadata types and documentation across multiple resources
3. New model support (o3-mini)
4. Bug fixes and documentation improvements

<details>
<summary><i>Changes</i></summary>

### Changes

#### Azure Realtime Support
- Added new Azure realtime examples in `/examples/azure/realtime/`
- Implemented Azure WebSocket connection handling in `/src/beta/realtime/`
- Added Azure-specific authentication for realtime connections

#### API Updates
- Added new `o3-mini` model support
- Added `Metadata` shared type for consistent metadata handling
- Updated voice options for speech API
- Enhanced session and realtime API parameter documentation

#### Documentation
- Updated Azure Realtime API documentation in README.md
- Fixed typos and broken links in documentation
- Improved type annotations and examples

#### Bug Fixes
- Fixed duplicate session update call in realtime examples
- Corrected Azure authentication header handling
- Updated error handling in realtime connections



```mermaid
sequenceDiagram
    participant Client
    participant AzureOpenAI
    participant WebSocket
    participant RealtimeAPI

    Client->>AzureOpenAI: Create client with credentials
    Client->>AzureOpenAI: Request realtime connection
    AzureOpenAI->>AzureOpenAI: Get Azure AD token
    AzureOpenAI->>WebSocket: Initialize connection with auth
    WebSocket-->>Client: Connection established
    
    Client->>WebSocket: Send session.update
    WebSocket->>RealtimeAPI: Update session
    RealtimeAPI-->>Client: Session created
    
    Client->>WebSocket: Send conversation.item.create
    WebSocket->>RealtimeAPI: Create item
    RealtimeAPI-->>Client: Stream response
    
    Client->>WebSocket: Close connection
    WebSocket-->>Client: Connection closed

Security Hotspots

  1. The Azure authentication header is redacted in WebSocket URLs to prevent leaking sensitive information in logs or errors, but care should be taken when handling these URLs in application code.

@renovate renovate bot changed the title fix(deps): update dependency openai to v4.82.0 fix(deps): update dependency openai to v4.83.0 Feb 12, 2025
@renovate renovate bot force-pushed the renovate/openai-4.x-lockfile branch from 9ef032a to 2a0f0f5 Compare February 12, 2025 15:08
Copy link

anthropic debug - [puLL-Merge] - openai/[email protected]

Diff
diff --git .release-please-manifest.json .release-please-manifest.json
index b1ab5c7b9..6eb0f130e 100644
--- .release-please-manifest.json
+++ .release-please-manifest.json
@@ -1,3 +1,3 @@
 {
-  ".": "4.79.4"
+  ".": "4.83.0"
 }
diff --git .stats.yml .stats.yml
index 9600edae3..df7877dfd 100644
--- .stats.yml
+++ .stats.yml
@@ -1,2 +1,2 @@
 configured_endpoints: 69
-openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-b5b0e2c794b012919701c3fd43286af10fa25d33ceb8a881bec2636028f446e0.yml
+openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-fc5dbc19505b0035f9e7f88868619f4fb519b048bde011f6154f3132d4be71fb.yml
diff --git CHANGELOG.md CHANGELOG.md
index 4254a9b8f..f61def5e4 100644
--- CHANGELOG.md
+++ CHANGELOG.md
@@ -1,5 +1,64 @@
 # Changelog
 
+## 4.83.0 (2025-02-05)
+
+Full Changelog: [v4.82.0...v4.83.0](https://github.com/openai/openai-node/compare/v4.82.0...v4.83.0)
+
+### Features
+
+* **client:** send `X-Stainless-Timeout` header ([#1299](https://github.com/openai/openai-node/issues/1299)) ([ddfc686](https://github.com/openai/openai-node/commit/ddfc686f43a3420c3adf8dec2e82b4d10a121eb8))
+
+
+### Bug Fixes
+
+* **api/types:** correct audio duration & role types ([#1300](https://github.com/openai/openai-node/issues/1300)) ([a955ac2](https://github.com/openai/openai-node/commit/a955ac2bf5bee663d530d0c82b0005bf3ce6fc47))
+* **azure/audio:** use model param for deployments ([#1297](https://github.com/openai/openai-node/issues/1297)) ([85de382](https://github.com/openai/openai-node/commit/85de382db17cbe5f112650e79d0fc1cc841efbb2))
+
+## 4.82.0 (2025-01-31)
+
+Full Changelog: [v4.81.0...v4.82.0](https://github.com/openai/openai-node/compare/v4.81.0...v4.82.0)
+
+### Features
+
+* **api:** add o3-mini ([#1295](https://github.com/openai/openai-node/issues/1295)) ([378e2f7](https://github.com/openai/openai-node/commit/378e2f7af62c570adb4c7644a4d49576b698de41))
+
+
+### Bug Fixes
+
+* **examples/realtime:** remove duplicate `session.update` call ([#1293](https://github.com/openai/openai-node/issues/1293)) ([ad800b4](https://github.com/openai/openai-node/commit/ad800b4f9410c6838994c24a3386ea708717f72b))
+* **types:** correct metadata type + other fixes ([378e2f7](https://github.com/openai/openai-node/commit/378e2f7af62c570adb4c7644a4d49576b698de41))
+
+## 4.81.0 (2025-01-29)
+
+Full Changelog: [v4.80.1...v4.81.0](https://github.com/openai/openai-node/compare/v4.80.1...v4.81.0)
+
+### Features
+
+* **azure:** Realtime API support ([#1287](https://github.com/openai/openai-node/issues/1287)) ([fe090c0](https://github.com/openai/openai-node/commit/fe090c0a57570217eb0b431e2cce40bf61de2b75))
+
+## 4.80.1 (2025-01-24)
+
+Full Changelog: [v4.80.0...v4.80.1](https://github.com/openai/openai-node/compare/v4.80.0...v4.80.1)
+
+### Bug Fixes
+
+* **azure:** include retry count header ([3e0ba40](https://github.com/openai/openai-node/commit/3e0ba409e57ce276fb1f95cd11c801e4ccaad572))
+
+
+### Documentation
+
+* fix typo, "zodFunctionTool" -&gt; "zodFunction" ([#1128](https://github.com/openai/openai-node/issues/1128)) ([b7ab6bb](https://github.com/openai/openai-node/commit/b7ab6bb304973ade94830f37eb646e800226d5ef))
+* **helpers:** fix type annotation ([fc019df](https://github.com/openai/openai-node/commit/fc019df1d9cc276e8f8e689742853a09aa94991a))
+* **readme:** fix realtime errors docs link ([#1286](https://github.com/openai/openai-node/issues/1286)) ([d1d50c8](https://github.com/openai/openai-node/commit/d1d50c897c18cefea964e8057fe1acfd766ae2bf))
+
+## 4.80.0 (2025-01-22)
+
+Full Changelog: [v4.79.4...v4.80.0](https://github.com/openai/openai-node/compare/v4.79.4...v4.80.0)
+
+### Features
+
+* **api:** update enum values, comments, and examples ([#1280](https://github.com/openai/openai-node/issues/1280)) ([d38f2c2](https://github.com/openai/openai-node/commit/d38f2c2648b6990f217c3c7d83ca31f3739641d3))
+
 ## 4.79.4 (2025-01-21)
 
 Full Changelog: [v4.79.3...v4.79.4](https://github.com/openai/openai-node/compare/v4.79.3...v4.79.4)
diff --git README.md README.md
index 3bd386e99..a1f4bf760 100644
--- README.md
+++ README.md
@@ -157,7 +157,7 @@ A full example can be found [here](https://github.com/openai/openai-node/blob/ma
 
 ### Realtime error handling
 
-When an error is encountered, either on the client side or returned from the server through the [`error` event](https://platform.openai.com/docs/guides/realtime/realtime-api-beta#handling-errors), the `error` event listener will be fired. However, if you haven't registered an `error` event listener then an `unhandled Promise rejection` error will be thrown.
+When an error is encountered, either on the client side or returned from the server through the [`error` event](https://platform.openai.com/docs/guides/realtime-model-capabilities#error-handling), the `error` event listener will be fired. However, if you haven't registered an `error` event listener then an `unhandled Promise rejection` error will be thrown.
 
 It is **highly recommended** that you register an `error` event listener and handle errors approriately as typically the underlying connection is still usable.
 
@@ -499,7 +499,7 @@ const credential = new DefaultAzureCredential();
 const scope = 'https://cognitiveservices.azure.com/.default';
 const azureADTokenProvider = getBearerTokenProvider(credential, scope);
 
-const openai = new AzureOpenAI({ azureADTokenProvider });
+const openai = new AzureOpenAI({ azureADTokenProvider, apiVersion: "<The API version, e.g. 2024-10-01-preview>" });
 
 const result = await openai.chat.completions.create({
   model: 'gpt-4o',
@@ -509,6 +509,26 @@ const result = await openai.chat.completions.create({
 console.log(result.choices[0]!.message?.content);
 \`\`\`
 
+### Realtime API
+This SDK provides real-time streaming capabilities for Azure OpenAI through the `OpenAIRealtimeWS` and `OpenAIRealtimeWebSocket` clients described previously.
+
+To utilize the real-time features, begin by creating a fully configured `AzureOpenAI` client and passing it into either `OpenAIRealtimeWS.azure` or `OpenAIRealtimeWebSocket.azure`. For example:
+
+```ts
+const cred = new DefaultAzureCredential();
+const scope = 'https://cognitiveservices.azure.com/.default';
+const deploymentName = 'gpt-4o-realtime-preview-1001';
+const azureADTokenProvider = getBearerTokenProvider(cred, scope);
+const client = new AzureOpenAI({
+  azureADTokenProvider,
+  apiVersion: '2024-10-01-preview',
+  deployment: deploymentName,
+});
+const rt = await OpenAIRealtimeWS.azure(client);
+```
+
+Once the instance has been created, you can then begin sending requests and receiving streaming responses in real time.
+
 ### Retries
 
 Certain errors will be automatically retried 2 times by default, with a short exponential backoff.
diff --git api.md api.md
index 33ab95ef6..01854a8e0 100644
--- api.md
+++ api.md
@@ -5,6 +5,7 @@ Types:
 - <code><a href="./src/resources/shared.ts">ErrorObject</a></code>
 - <code><a href="./src/resources/shared.ts">FunctionDefinition</a></code>
 - <code><a href="./src/resources/shared.ts">FunctionParameters</a></code>
+- <code><a href="./src/resources/shared.ts">Metadata</a></code>
 - <code><a href="./src/resources/shared.ts">ResponseFormatJSONObject</a></code>
 - <code><a href="./src/resources/shared.ts">ResponseFormatJSONSchema</a></code>
 - <code><a href="./src/resources/shared.ts">ResponseFormatText</a></code>
@@ -228,6 +229,7 @@ Types:
 - <code><a href="./src/resources/beta/realtime/realtime.ts">ConversationItemInputAudioTranscriptionFailedEvent</a></code>
 - <code><a href="./src/resources/beta/realtime/realtime.ts">ConversationItemTruncateEvent</a></code>
 - <code><a href="./src/resources/beta/realtime/realtime.ts">ConversationItemTruncatedEvent</a></code>
+- <code><a href="./src/resources/beta/realtime/realtime.ts">ConversationItemWithReference</a></code>
 - <code><a href="./src/resources/beta/realtime/realtime.ts">ErrorEvent</a></code>
 - <code><a href="./src/resources/beta/realtime/realtime.ts">InputAudioBufferAppendEvent</a></code>
 - <code><a href="./src/resources/beta/realtime/realtime.ts">InputAudioBufferClearEvent</a></code>
diff --git examples/azure.ts examples/azure/chat.ts
similarity index 91%
rename from examples/azure.ts
rename to examples/azure/chat.ts
index 5fe1718fa..46df820f8 100755
--- examples/azure.ts
+++ examples/azure/chat.ts
@@ -2,6 +2,7 @@
 
 import { AzureOpenAI } from 'openai';
 import { getBearerTokenProvider, DefaultAzureCredential } from '@azure/identity';
+import 'dotenv/config';
 
 // Corresponds to your Model deployment within your OpenAI resource, e.g. gpt-4-1106-preview
 // Navigate to the Azure OpenAI Studio to deploy a model.
@@ -13,7 +14,7 @@ const azureADTokenProvider = getBearerTokenProvider(credential, scope);
 
 // Make sure to set AZURE_OPENAI_ENDPOINT with the endpoint of your Azure resource.
 // You can find it in the Azure Portal.
-const openai = new AzureOpenAI({ azureADTokenProvider });
+const openai = new AzureOpenAI({ azureADTokenProvider, apiVersion: '2024-10-01-preview' });
 
 async function main() {
   console.log('Non-streaming:');
diff --git a/examples/azure/realtime/websocket.ts b/examples/azure/realtime/websocket.ts
new file mode 100644
index 000000000..bec74e654
--- /dev/null
+++ examples/azure/realtime/websocket.ts
@@ -0,0 +1,60 @@
+import { OpenAIRealtimeWebSocket } from 'openai/beta/realtime/websocket';
+import { AzureOpenAI } from 'openai';
+import { DefaultAzureCredential, getBearerTokenProvider } from '@azure/identity';
+import 'dotenv/config';
+
+async function main() {
+  const cred = new DefaultAzureCredential();
+  const scope = 'https://cognitiveservices.azure.com/.default';
+  const deploymentName = 'gpt-4o-realtime-preview-1001';
+  const azureADTokenProvider = getBearerTokenProvider(cred, scope);
+  const client = new AzureOpenAI({
+    azureADTokenProvider,
+    apiVersion: '2024-10-01-preview',
+    deployment: deploymentName,
+  });
+  const rt = await OpenAIRealtimeWebSocket.azure(client);
+
+  // access the underlying `ws.WebSocket` instance
+  rt.socket.addEventListener('open', () => {
+    console.log('Connection opened!');
+    rt.send({
+      type: 'session.update',
+      session: {
+        modalities: ['text'],
+        model: 'gpt-4o-realtime-preview',
+      },
+    });
+
+    rt.send({
+      type: 'conversation.item.create',
+      item: {
+        type: 'message',
+        role: 'user',
+        content: [{ type: 'input_text', text: 'Say a couple paragraphs!' }],
+      },
+    });
+
+    rt.send({ type: 'response.create' });
+  });
+
+  rt.on('error', (err) => {
+    // in a real world scenario this should be logged somewhere as you
+    // likely want to continue procesing events regardless of any errors
+    throw err;
+  });
+
+  rt.on('session.created', (event) => {
+    console.log('session created!', event.session);
+    console.log();
+  });
+
+  rt.on('response.text.delta', (event) => process.stdout.write(event.delta));
+  rt.on('response.text.done', () => console.log());
+
+  rt.on('response.done', () => rt.close());
+
+  rt.socket.addEventListener('close', () => console.log('\nConnection closed!'));
+}
+
+main();
diff --git a/examples/azure/realtime/ws.ts b/examples/azure/realtime/ws.ts
new file mode 100644
index 000000000..6ab7b742a
--- /dev/null
+++ examples/azure/realtime/ws.ts
@@ -0,0 +1,60 @@
+import { DefaultAzureCredential, getBearerTokenProvider } from '@azure/identity';
+import { OpenAIRealtimeWS } from 'openai/beta/realtime/ws';
+import { AzureOpenAI } from 'openai';
+import 'dotenv/config';
+
+async function main() {
+  const cred = new DefaultAzureCredential();
+  const scope = 'https://cognitiveservices.azure.com/.default';
+  const deploymentName = 'gpt-4o-realtime-preview-1001';
+  const azureADTokenProvider = getBearerTokenProvider(cred, scope);
+  const client = new AzureOpenAI({
+    azureADTokenProvider,
+    apiVersion: '2024-10-01-preview',
+    deployment: deploymentName,
+  });
+  const rt = await OpenAIRealtimeWS.azure(client);
+
+  // access the underlying `ws.WebSocket` instance
+  rt.socket.on('open', () => {
+    console.log('Connection opened!');
+    rt.send({
+      type: 'session.update',
+      session: {
+        modalities: ['text'],
+        model: 'gpt-4o-realtime-preview',
+      },
+    });
+
+    rt.send({
+      type: 'conversation.item.create',
+      item: {
+        type: 'message',
+        role: 'user',
+        content: [{ type: 'input_text', text: 'Say a couple paragraphs!' }],
+      },
+    });
+
+    rt.send({ type: 'response.create' });
+  });
+
+  rt.on('error', (err) => {
+    // in a real world scenario this should be logged somewhere as you
+    // likely want to continue procesing events regardless of any errors
+    throw err;
+  });
+
+  rt.on('session.created', (event) => {
+    console.log('session created!', event.session);
+    console.log();
+  });
+
+  rt.on('response.text.delta', (event) => process.stdout.write(event.delta));
+  rt.on('response.text.done', () => console.log());
+
+  rt.on('response.done', () => rt.close());
+
+  rt.socket.on('close', () => console.log('\nConnection closed!'));
+}
+
+main();
diff --git examples/package.json examples/package.json
index b8c34ac45..70ec2c523 100644
--- examples/package.json
+++ examples/package.json
@@ -7,6 +7,7 @@
   "private": true,
   "dependencies": {
     "@azure/identity": "^4.2.0",
+    "dotenv": "^16.4.7",
     "express": "^4.18.2",
     "next": "^14.1.1",
     "openai": "file:..",
diff --git examples/realtime/ws.ts examples/realtime/ws.ts
index 4bbe85e5d..08c6fbcb6 100644
--- examples/realtime/ws.ts
+++ examples/realtime/ws.ts
@@ -6,13 +6,6 @@ async function main() {
   // access the underlying `ws.WebSocket` instance
   rt.socket.on('open', () => {
     console.log('Connection opened!');
-    rt.send({
-      type: 'session.update',
-      session: {
-        modalities: ['foo'] as any,
-        model: 'gpt-4o-realtime-preview',
-      },
-    });
     rt.send({
       type: 'session.update',
       session: {
diff --git helpers.md helpers.md
index abf980c82..16bc1f277 100644
--- helpers.md
+++ helpers.md
@@ -49,7 +49,7 @@ if (message?.parsed) {
 
 The `.parse()` method will also automatically parse `function` tool calls if:
 
-- You use the `zodFunctionTool()` helper method
+- You use the `zodFunction()` helper method
 - You mark your tool schema with `"strict": True`
 
 For example:
@@ -226,7 +226,7 @@ on in the documentation page [Message](https://platform.openai.com/docs/api-refe
 
 ```ts
 .on('textCreated', (content: Text) => ...)
-.on('textDelta', (delta: RunStepDelta, snapshot: Text) => ...)
+.on('textDelta', (delta: TextDelta, snapshot: Text) => ...)
 .on('textDone', (content: Text, snapshot: Message) => ...)

diff --git jsr.json jsr.json
index e6d772116..6fa05e624 100644
--- jsr.json
+++ jsr.json
@@ -1,6 +1,6 @@
{
"name": "@openai/openai",

  • "version": "4.79.4",
  • "version": "4.83.0",
    "exports": {
    ".": "./index.ts",
    "./helpers/zod": "./helpers/zod.ts",
    diff --git package.json package.json
    index d7a5555e5..bd507e9f8 100644
    --- package.json
    +++ package.json
    @@ -1,6 +1,6 @@
    {
    "name": "openai",
  • "version": "4.79.4",
  • "version": "4.83.0",
    "description": "The official TypeScript library for the OpenAI API",
    "author": "OpenAI [email protected]",
    "types": "dist/index.d.ts",
    diff --git src/beta/realtime/internal-base.ts src/beta/realtime/internal-base.ts
    index 391d69911..b704812ee 100644
    --- src/beta/realtime/internal-base.ts
    +++ src/beta/realtime/internal-base.ts
    @@ -1,6 +1,7 @@
    import { RealtimeClientEvent, RealtimeServerEvent, ErrorEvent } from '../../resources/beta/realtime/realtime';
    import { EventEmitter } from '../../lib/EventEmitter';
    import { OpenAIError } from '../../error';
    +import OpenAI, { AzureOpenAI } from '../../index';

export class OpenAIRealtimeError extends OpenAIError {
/**
@@ -73,11 +74,20 @@ export abstract class OpenAIRealtimeEmitter extends EventEmitter
}
}

-export function buildRealtimeURL(props: { baseURL: string; model: string }): URL {

  • const path = '/realtime';
    +export function isAzure(client: Pick<OpenAI, 'apiKey' | 'baseURL'>): client is AzureOpenAI {
  • return client instanceof AzureOpenAI;
    +}
  • const url = new URL(props.baseURL + (props.baseURL.endsWith('/') ? path.slice(1) : path));
    +export function buildRealtimeURL(client: Pick<OpenAI, 'apiKey' | 'baseURL'>, model: string): URL {
  • const path = '/realtime';
  • const baseURL = client.baseURL;
  • const url = new URL(baseURL + (baseURL.endsWith('/') ? path.slice(1) : path));
    url.protocol = 'wss';
  • url.searchParams.set('model', props.model);
  • if (isAzure(client)) {
  • url.searchParams.set('api-version', client.apiVersion);
  • url.searchParams.set('deployment', model);
  • } else {
  • url.searchParams.set('model', model);
  • }
    return url;
    }
    diff --git src/beta/realtime/websocket.ts src/beta/realtime/websocket.ts
    index e0853779d..349cf5760 100644
    --- src/beta/realtime/websocket.ts
    +++ src/beta/realtime/websocket.ts
    @@ -1,8 +1,8 @@
    -import { OpenAI } from '../../index';
    +import { AzureOpenAI, OpenAI } from '../../index';
    import { OpenAIError } from '../../error';
    import * as Core from '../../core';
    import type { RealtimeClientEvent, RealtimeServerEvent } from '../../resources/beta/realtime/realtime';
    -import { OpenAIRealtimeEmitter, buildRealtimeURL } from './internal-base';
    +import { OpenAIRealtimeEmitter, buildRealtimeURL, isAzure } from './internal-base';

interface MessageEvent {
data: string;
@@ -26,6 +26,11 @@ export class OpenAIRealtimeWebSocket extends OpenAIRealtimeEmitter {
props: {
model: string;
dangerouslyAllowBrowser?: boolean;

  •  /**
    
  •   * Callback to mutate the URL, needed for Azure.
    
  •   * @internal
    
  •   */
    
  •  onURL?: (url: URL) => void;
    

    },
    client?: Pick<OpenAI, 'apiKey' | 'baseURL'>,
    ) {
    @@ -44,11 +49,13 @@ export class OpenAIRealtimeWebSocket extends OpenAIRealtimeEmitter {

    client ??= new OpenAI({ dangerouslyAllowBrowser });

  • this.url = buildRealtimeURL({ baseURL: client.baseURL, model: props.model });
  • this.url = buildRealtimeURL(client, props.model);
  • props.onURL?.(this.url);
  • // @ts-ignore
    this.socket = new WebSocket(this.url, [
    'realtime',
  •  `openai-insecure-api-key.${client.apiKey}`,
    
  •  ...(isAzure(client) ? [] : [`openai-insecure-api-key.${client.apiKey}`]),
     'openai-beta.realtime-v1',
    
    ]);

@@ -77,6 +84,45 @@ export class OpenAIRealtimeWebSocket extends OpenAIRealtimeEmitter {
this.socket.addEventListener('error', (event: any) => {
this._onError(null, event.message, null);
});
+

  • if (isAzure(client)) {
  •  if (this.url.searchParams.get('Authorization') !== null) {
    
  •    this.url.searchParams.set('Authorization', '<REDACTED>');
    
  •  } else {
    
  •    this.url.searchParams.set('api-key', '<REDACTED>');
    
  •  }
    
  • }
  • }
  • static async azure(
  • client: AzureOpenAI,
  • options: { deploymentName?: string; dangerouslyAllowBrowser?: boolean } = {},
  • ): Promise {
  • const token = await client._getAzureADToken();
  • function onURL(url: URL) {
  •  if (client.apiKey !== '<Missing Key>') {
    
  •    url.searchParams.set('api-key', client.apiKey);
    
  •  } else {
    
  •    if (token) {
    
  •      url.searchParams.set('Authorization', `Bearer ${token}`);
    
  •    } else {
    
  •      throw new Error('AzureOpenAI is not instantiated correctly. No API key or token provided.');
    
  •    }
    
  •  }
    
  • }
  • const deploymentName = options.deploymentName ?? client.deploymentName;
  • if (!deploymentName) {
  •  throw new Error('No deployment name provided');
    
  • }
  • const { dangerouslyAllowBrowser } = options;
  • return new OpenAIRealtimeWebSocket(
  •  {
    
  •    model: deploymentName,
    
  •    onURL,
    
  •    ...(dangerouslyAllowBrowser ? { dangerouslyAllowBrowser } : {}),
    
  •  },
    
  •  client,
    
  • );
    }

send(event: RealtimeClientEvent) {
diff --git src/beta/realtime/ws.ts src/beta/realtime/ws.ts
index 631a36cd2..51339089c 100644
--- src/beta/realtime/ws.ts
+++ src/beta/realtime/ws.ts
@@ -1,7 +1,7 @@
import * as WS from 'ws';
-import { OpenAI } from '../../index';
+import { AzureOpenAI, OpenAI } from '../../index';
import type { RealtimeClientEvent, RealtimeServerEvent } from '../../resources/beta/realtime/realtime';
-import { OpenAIRealtimeEmitter, buildRealtimeURL } from './internal-base';
+import { OpenAIRealtimeEmitter, buildRealtimeURL, isAzure } from './internal-base';

export class OpenAIRealtimeWS extends OpenAIRealtimeEmitter {
url: URL;
@@ -14,12 +14,12 @@ export class OpenAIRealtimeWS extends OpenAIRealtimeEmitter {
super();
client ??= new OpenAI();

  • this.url = buildRealtimeURL({ baseURL: client.baseURL, model: props.model });
  • this.url = buildRealtimeURL(client, props.model);
    this.socket = new WS.WebSocket(this.url, {
    ...props.options,
    headers: {
    ...props.options?.headers,
  •    Authorization: `Bearer ${client.apiKey}`,
    
  •    ...(isAzure(client) ? {} : { Authorization: `Bearer ${client.apiKey}` }),
       'OpenAI-Beta': 'realtime=v1',
     },
    

    });
    @@ -51,6 +51,20 @@ export class OpenAIRealtimeWS extends OpenAIRealtimeEmitter {
    });
    }

  • static async azure(

  • client: AzureOpenAI,

  • options: { deploymentName?: string; options?: WS.ClientOptions | undefined } = {},

  • ): Promise {

  • const deploymentName = options.deploymentName ?? client.deploymentName;

  • if (!deploymentName) {

  •  throw new Error('No deployment name provided');
    
  • }

  • return new OpenAIRealtimeWS(

  •  { model: deploymentName, options: { headers: await getAzureHeaders(client) } },
    
  •  client,
    
  • );

  • }

  • send(event: RealtimeClientEvent) {
    try {
    this.socket.send(JSON.stringify(event));
    @@ -67,3 +81,16 @@ export class OpenAIRealtimeWS extends OpenAIRealtimeEmitter {
    }
    }
    }

+async function getAzureHeaders(client: AzureOpenAI) {

  • if (client.apiKey !== '') {

  • return { 'api-key': client.apiKey };

  • } else {

  • const token = await client._getAzureADToken();

  • if (token) {

  •  return { Authorization: `Bearer ${token}` };
    
  • } else {

  •  throw new Error('AzureOpenAI is not instantiated correctly. No API key or token provided.');
    
  • }

  • }
    +}
    diff --git src/core.ts src/core.ts
    index 3d2d029a5..6578c0781 100644
    --- src/core.ts
    +++ src/core.ts
    @@ -315,6 +315,7 @@ export abstract class APIClient {
    options: FinalRequestOptions,
    { retryCount = 0 }: { retryCount?: number } = {},
    ): { req: RequestInit; url: string; timeout: number } {

  • options = { ...options };
    const { method, path, query, headers: headers = {} } = options;

    const body =
    @@ -327,9 +328,9 @@ export abstract class APIClient {

    const url = this.buildURL(path!, query);
    if ('timeout' in options) validatePositiveInteger('timeout', options.timeout);

  • const timeout = options.timeout ?? this.timeout;
  • options.timeout = options.timeout ?? this.timeout;
    const httpAgent = options.httpAgent ?? this.httpAgent ?? getDefaultAgent(url);
  • const minAgentTimeout = timeout + 1000;
  • const minAgentTimeout = options.timeout + 1000;
    if (
    typeof (httpAgent as any)?.options?.timeout === 'number' &&
    minAgentTimeout > ((httpAgent as any).options.timeout ?? 0)
    @@ -358,7 +359,7 @@ export abstract class APIClient {
    signal: options.signal ?? null,
    };
  • return { req, url, timeout };
  • return { req, url, timeout: options.timeout };
    }

private buildHeaders({
@@ -386,15 +387,22 @@ export abstract class APIClient {
delete reqHeaders['content-type'];
}

  • // Don't set the retry count header if it was already set or removed through default headers or by the
  • // caller. We check defaultHeaders and headers, which can contain nulls, instead of reqHeaders to
  • // account for the removal case.
  • // Don't set theses headers if they were already set or removed through default headers or by the caller.

  • // We check defaultHeaders and headers, which can contain nulls, instead of reqHeaders to account

  • // for the removal case.
    if (
    getHeader(defaultHeaders, 'x-stainless-retry-count') === undefined &&
    getHeader(headers, 'x-stainless-retry-count') === undefined
    ) {
    reqHeaders['x-stainless-retry-count'] = String(retryCount);
    }

  • if (

  •  getHeader(defaultHeaders, 'x-stainless-timeout') === undefined &&
    
  •  getHeader(headers, 'x-stainless-timeout') === undefined &&
    
  •  options.timeout
    
  • ) {

  •  reqHeaders['x-stainless-timeout'] = String(options.timeout);
    
  • }

    this.validateHeaders(reqHeaders, headers);

@@ -814,6 +822,7 @@ export type RequestOptions<
signal?: AbortSignal | undefined | null;
idempotencyKey?: string;

  • __metadata?: Record<string, unknown>;
    __binaryRequest?: boolean | undefined;
    __binaryResponse?: boolean | undefined;
    __streamClass?: typeof Stream;
    @@ -836,6 +845,7 @@ const requestOptionsKeys: KeysEnum = {
    signal: true,
    idempotencyKey: true,

  • __metadata: true,
    __binaryRequest: true,
    __binaryResponse: true,
    __streamClass: true,
    diff --git src/index.ts src/index.ts
    index cf6aa89e3..f4e940af8 100644
    --- src/index.ts
    +++ src/index.ts
    @@ -451,6 +451,7 @@ export declare namespace OpenAI {
    export type ErrorObject = API.ErrorObject;
    export type FunctionDefinition = API.FunctionDefinition;
    export type FunctionParameters = API.FunctionParameters;

  • export type Metadata = API.Metadata;
    export type ResponseFormatJSONObject = API.ResponseFormatJSONObject;
    export type ResponseFormatJSONSchema = API.ResponseFormatJSONSchema;
    export type ResponseFormatText = API.ResponseFormatText;
    @@ -491,7 +492,7 @@ export interface AzureClientOptions extends ClientOptions {
    /** API Client for interfacing with the Azure OpenAI API. */
    export class AzureOpenAI extends OpenAI {
    private _azureADTokenProvider: (() => Promise) | undefined;

  • private _deployment: string | undefined;
  • deploymentName: string | undefined;
    apiVersion: string = '';
    /**

    • API Client for interfacing with the Azure OpenAI API.
      @@ -574,10 +575,13 @@ export class AzureOpenAI extends OpenAI {

    this._azureADTokenProvider = azureADTokenProvider;
    this.apiVersion = apiVersion;

  • this._deployment = deployment;
  • this.deploymentName = deployment;
    }
  • override buildRequest(options: Core.FinalRequestOptions): {
  • override buildRequest(
  • options: Core.FinalRequestOptions,
  • props: { retryCount?: number } = {},
  • ): {
    req: RequestInit;
    url: string;
    timeout: number;
    @@ -586,15 +590,15 @@ export class AzureOpenAI extends OpenAI {
    if (!Core.isObj(options.body)) {
    throw new Error('Expected request body to be an object');
    }
  •  const model = this._deployment || options.body['model'];
    
  •  const model = this.deploymentName || options.body['model'] || options.__metadata?.['model'];
     if (model !== undefined && !this.baseURL.includes('/deployments')) {
       options.path = `/deployments/${model}${options.path}`;
     }
    
    }
  • return super.buildRequest(options);
  • return super.buildRequest(options, props);
    }
  • private async _getAzureADToken(): Promise<string | undefined> {
  • async _getAzureADToken(): Promise<string | undefined> {
    if (typeof this._azureADTokenProvider === 'function') {
    const token = await this._azureADTokenProvider();
    if (!token || typeof token !== 'string') {
    diff --git src/lib/ChatCompletionStream.ts src/lib/ChatCompletionStream.ts
    index a88f8a23b..6c846f70b 100644
    --- src/lib/ChatCompletionStream.ts
    +++ src/lib/ChatCompletionStream.ts
    @@ -12,6 +12,7 @@ import {
    type ChatCompletionCreateParams,
    type ChatCompletionCreateParamsStreaming,
    type ChatCompletionCreateParamsBase,
  • type ChatCompletionRole,
    } from '../resources/chat/completions';
    import {
    AbstractChatCompletionRunner,
    @@ -797,7 +798,7 @@ export namespace ChatCompletionSnapshot {
    /**
    * The role of the author of this message.
    */
  •  role?: 'system' | 'user' | 'assistant' | 'function' | 'tool';
    
  •  role?: ChatCompletionRole;
    

    }

    export namespace Message {
    diff --git src/resources/audio/speech.ts src/resources/audio/speech.ts
    index bd2ed9f65..35e82c4c1 100644
    --- src/resources/audio/speech.ts
    +++ src/resources/audio/speech.ts
    @@ -33,12 +33,12 @@ export interface SpeechCreateParams {
    model: (string & {}) | SpeechModel;

    /**

    • The voice to use when generating the audio. Supported voices are alloy,
    • echo, fable, onyx, nova, and shimmer. Previews of the voices are
    • available in the
    • The voice to use when generating the audio. Supported voices are alloy, ash,
    • coral, echo, fable, onyx, nova, sage and shimmer. Previews of the
  • voice: 'alloy' | 'echo' | 'fable' | 'onyx' | 'nova' | 'shimmer';
  • voice: 'alloy' | 'ash' | 'coral' | 'echo' | 'fable' | 'onyx' | 'nova' | 'sage' | 'shimmer';

    /**

    • The format to audio in. Supported formats are mp3, opus, aac, flac,
      diff --git src/resources/audio/transcriptions.ts src/resources/audio/transcriptions.ts
      index 0b6da4620..6fbe96b58 100644
      --- src/resources/audio/transcriptions.ts
      +++ src/resources/audio/transcriptions.ts
      @@ -25,7 +25,10 @@ export class Transcriptions extends APIResource {
      body: TranscriptionCreateParams,
      options?: Core.RequestOptions,
      ): Core.APIPromise<TranscriptionCreateResponse | string> {
  • return this._client.post('/audio/transcriptions', Core.multipartFormRequestOptions({ body, ...options }));
  • return this._client.post(
  •  '/audio/transcriptions',
    
  •  Core.multipartFormRequestOptions({ body, ...options, __metadata: { model: body.model } }),
    
  • );
    }
    }

@@ -103,7 +106,7 @@ export interface TranscriptionVerbose {
/**
* The duration of the input audio.
*/

  • duration: string;
  • duration: number;

    /**

    • The language of the input audio.
      @@ -166,8 +169,8 @@ export interface TranscriptionCreateParams<

    /**

    • The language of the input audio. Supplying the input language in
    • improve accuracy and latency.
    • format will improve accuracy and latency.
      */
      language?: string;

diff --git src/resources/audio/translations.ts src/resources/audio/translations.ts
index c6bf7c870..dac519ede 100644
--- src/resources/audio/translations.ts
+++ src/resources/audio/translations.ts
@@ -26,7 +26,10 @@ export class Translations extends APIResource {
body: TranslationCreateParams,
options?: Core.RequestOptions,
): Core.APIPromise<TranslationCreateResponse | string> {

  • return this._client.post('/audio/translations', Core.multipartFormRequestOptions({ body, ...options }));
  • return this._client.post(
  •  '/audio/translations',
    
  •  Core.multipartFormRequestOptions({ body, ...options, __metadata: { model: body.model } }),
    
  • );
    }
    }

@@ -38,7 +41,7 @@ export interface TranslationVerbose {
/**
* The duration of the input audio.
*/

  • duration: string;
  • duration: number;

    /**

    • The language of the output translation (always english).
      diff --git src/resources/batches.ts src/resources/batches.ts
      index ec5ca6331..aadda83a6 100644
      --- src/resources/batches.ts
      +++ src/resources/batches.ts
      @@ -4,6 +4,7 @@ import { APIResource } from '../resource';
      import { isRequestOptions } from '../core';
      import * as Core from '../core';
      import * as BatchesAPI from './batches';
      +import * as Shared from './shared';
      import { CursorPage, type CursorPageParams } from '../pagination';

export class Batches extends APIResource {
@@ -138,11 +139,13 @@ export interface Batch {

/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful

    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;

    /**

    • The ID of the file containing the outputs of successfully executed requests.
      @@ -237,9 +240,14 @@ export interface BatchCreateParams {
      input_file_id: string;

    /**

    • Optional custom metadata for the batch.
    • Set of 16 key-value pairs that can be attached to an object. This can be useful
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata?: Record<string, string> | null;
  • metadata?: Shared.Metadata | null;
    }

export interface BatchListParams extends CursorPageParams {}
diff --git src/resources/beta/assistants.ts src/resources/beta/assistants.ts
index 0e657b1d4..69a5db520 100644
--- src/resources/beta/assistants.ts
+++ src/resources/beta/assistants.ts
@@ -111,11 +111,13 @@ export interface Assistant {

/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful

    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata: unknown | null;
  • metadata: Shared.Metadata | null;

    /**

    • ID of the model to use. You can use the
      @@ -1118,11 +1120,13 @@ export interface AssistantCreateParams {

    /**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;

    /**

    • The name of the assistant. The maximum length is 256 characters.
      @@ -1242,12 +1246,14 @@ export namespace AssistantCreateParams {
      file_ids?: Array;

      /**

  •     * Set of 16 key-value pairs that can be attached to a vector store. This can be
    
  •     * useful for storing additional information about the vector store in a structured
    
  •     * format. Keys can be a maximum of 64 characters long and values can be a maxium
    
  •     * of 512 characters long.
    
  •     * Set of 16 key-value pairs that can be attached to an object. This can be useful
    
  •     * for storing additional information about the object in a structured format, and
    
  •     * querying for objects via API or the dashboard.
    
  •     *
    
  •     * Keys are strings with a maximum length of 64 characters. Values are strings with
    
  •     * a maximum length of 512 characters.
        */
    
  •    metadata?: unknown;
    
  •    metadata?: Shared.Metadata | null;
     }
    

    }
    }
    @@ -1267,11 +1273,13 @@ export interface AssistantUpdateParams {

    /**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;

    /**

    • ID of the model to use. You can use the
      diff --git src/resources/beta/realtime/realtime.ts src/resources/beta/realtime/realtime.ts
      index 5de06917a..e46dcdaaf 100644
      --- src/resources/beta/realtime/realtime.ts
      +++ src/resources/beta/realtime/realtime.ts
      @@ -2,6 +2,7 @@

import { APIResource } from '../../../resource';
import * as RealtimeAPI from './realtime';
+import * as Shared from '../../shared';
import * as SessionsAPI from './sessions';
import {
Session as SessionsAPISession,
@@ -173,9 +174,10 @@ export interface ConversationItemCreateEvent {

/**
* The ID of the preceding item after which the new item will be inserted. If not

    • set, the new item will be appended to the end of the conversation. If set, it
    • allows an item to be inserted mid-conversation. If the ID cannot be found, an
    • error will be returned and the item will not be added.
    • set, the new item will be appended to the end of the conversation. If set to
    • root, the new item will be added to the beginning of the conversation. If set
    • to an existing ID, it allows an item to be inserted mid-conversation. If the ID
    • cannot be found, an error will be returned and the item will not be added.
      */
      previous_item_id?: string;
      }
      @@ -437,6 +439,76 @@ export interface ConversationItemTruncatedEvent {
      type: 'conversation.item.truncated';
      }

+/**

    • The item to add to the conversation.
  • */
    +export interface ConversationItemWithReference {
  • /**
    • For an item of type (message | function_call | function_call_output) this
    • field allows the client to assign the unique ID of the item. It is not required
    • because the server will generate one if not provided.
    • For an item of type item_reference, this field is required and is a reference
    • to any item that has previously existed in the conversation.
  • */
  • id?: string;
  • /**
    • The arguments of the function call (for function_call items).
  • */
  • arguments?: string;
  • /**
    • The ID of the function call (for function_call and function_call_output
    • items). If passed on a function_call_output item, the server will check that a
    • function_call item with the same ID exists in the conversation history.
  • */
  • call_id?: string;
  • /**
    • The content of the message, applicable for message items.
      • Message items of role system support only input_text content
      • Message items of role user support input_text and input_audio content
      • Message items of role assistant support text content.
  • */
  • content?: Array;
  • /**
    • The name of the function being called (for function_call items).
  • */
  • name?: string;
  • /**
    • Identifier for the API object being returned - always realtime.item.
  • */
  • object?: 'realtime.item';
  • /**
    • The output of the function call (for function_call_output items).
  • */
  • output?: string;
  • /**
    • The role of the message sender (user, assistant, system), only applicable
    • for message items.
  • */
  • role?: 'user' | 'assistant' | 'system';
  • /**
    • The status of the item (completed, incomplete). These have no effect on the
    • conversation, but are accepted for consistency with the
    • conversation.item.created event.
  • */
  • status?: 'completed' | 'incomplete';
  • /**
    • The type of the item (message, function_call, function_call_output,
    • item_reference).
  • */
  • type?: 'message' | 'function_call' | 'function_call_output' | 'item_reference';
    +}

/**

  • Returned when an error occurs, which could be a client problem or a server
  • problem. Most errors are recoverable and the session will stay open, we
    @@ -740,9 +812,38 @@ export interface RealtimeResponse {
    id?: string;

/**

    • Developer-provided string key-value pairs associated with this response.
    • Which conversation the response is added to, determined by the conversation
    • field in the response.create event. If auto, the response will be added to
    • the default conversation and the value of conversation_id will be an id like
    • conv_1234. If none, the response will not be added to any conversation and
    • the value of conversation_id will be null. If responses are being triggered
    • by server VAD, the response will be added to the default conversation, thus the
    • conversation_id will be an id like conv_1234.
  • */
  • conversation_id?: string;
  • /**
    • Maximum number of output tokens for a single assistant response, inclusive of
    • tool calls, that was used in this response.
  • */
  • max_output_tokens?: number | 'inf';
  • /**
    • Set of 16 key-value pairs that can be attached to an object. This can be useful
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;

  • /**

    • The set of modalities the model used to respond. If there are multiple
    • modalities, the model will pick one, for example if modalities is
    • ["text", "audio"], the model could be responding in either text or audio.
  • */

  • modalities?: Array<'text' | 'audio'>;

    /**

    • The object type, must be realtime.response.
      @@ -754,6 +855,11 @@ export interface RealtimeResponse {
      */
      output?: Array;
  • /**

    • The format of output audio. Options are pcm16, g711_ulaw, or g711_alaw.
  • */

  • output_audio_format?: 'pcm16' | 'g711_ulaw' | 'g711_alaw';

  • /**

    • The final status of the response (completed, cancelled, failed, or
    • incomplete).
      @@ -765,6 +871,11 @@ export interface RealtimeResponse {
      */
      status_details?: RealtimeResponseStatus;
  • /**

    • Sampling temperature for the model, limited to [0.6, 1.2]. Defaults to 0.8.
  • */

  • temperature?: number;

  • /**

    • Usage statistics for the Response, this will correspond to billing. A Realtime
    • API session will maintain a conversation context and append new Items to the
      @@ -772,6 +883,12 @@ export interface RealtimeResponse {
    • become the input for later turns.
      */
      usage?: RealtimeResponseUsage;
  • /**

    • The voice the model used to respond. Current voice options are alloy, ash,
    • ballad, coral, echo sage, shimmer and verse.
  • */

  • voice?: 'alloy' | 'ash' | 'ballad' | 'coral' | 'echo' | 'sage' | 'shimmer' | 'verse';
    }

/**
@@ -1289,11 +1406,12 @@ export namespace ResponseCreateEvent {
conversation?: (string & {}) | 'auto' | 'none';

 /**
  • * Input items to include in the prompt for the model. Creates a new context for
    
  • * this response, without including the default conversation. Can include
    
  • * references to items from the default conversation.
    
  • * Input items to include in the prompt for the model. Using this field creates a
    
  • * new context for this Response instead of using the default conversation. An
    
  • * empty array `[]` will clear the context for this Response. Note that this can
    
  • * include references to items from the default conversation.
    */
    
  • input?: Array<RealtimeAPI.ConversationItem>;
  • input?: Array<RealtimeAPI.ConversationItemWithReference>;

    /**

    • The default system instructions (i.e. system message) prepended to model calls.
      @@ -1319,11 +1437,13 @@ export namespace ResponseCreateEvent {

    /**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
  • * for storing additional information about the object in a structured format. Keys
    
  • * can be a maximum of 64 characters long and values can be a maximum of 512
    
  • * characters long.
    
  • * for storing additional information about the object in a structured format, and
    
  • * querying for objects via API or the dashboard.
    
  • *
    
  • * Keys are strings with a maximum length of 64 characters. Values are strings with
    
  • * a maximum length of 512 characters.
    */
    
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;

    /**

    • The set of modalities the model can respond with. To disable audio, set this to
      @@ -1705,17 +1825,9 @@ export namespace SessionUpdateEvent {
      /
      export interface Session {
      /
      *
  • * The Realtime model used for this session.
    
  • */
    
  • model:
  •  | 'gpt-4o-realtime-preview'
    
  •  | 'gpt-4o-realtime-preview-2024-10-01'
    
  •  | 'gpt-4o-realtime-preview-2024-12-17'
    
  •  | 'gpt-4o-mini-realtime-preview'
    
  •  | 'gpt-4o-mini-realtime-preview-2024-12-17';
    
  • /**
  • * The format of input audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`.
    
  • * The format of input audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`. For
    
  • * `pcm16`, input audio must be 16-bit PCM at a 24kHz sample rate, single channel
    
  • * (mono), and little-endian byte order.
    */
    
    input_audio_format?: 'pcm16' | 'g711_ulaw' | 'g711_alaw';

@@ -1723,8 +1835,11 @@ export namespace SessionUpdateEvent {
* Configuration for input audio transcription, defaults to off and can be set to
* null to turn off once on. Input audio transcription is not native to the
* model, since the model consumes audio directly. Transcription runs

  • * asynchronously through Whisper and should be treated as rough guidance rather
    
  • * than the representation understood by the model.
    
  • * asynchronously through
    
  • * [OpenAI Whisper transcription](https://platform.openai.com/docs/api-reference/audio/createTranscription)
    
  • * and should be treated as rough guidance rather than the representation
    
  • * understood by the model. The client can optionally set the language and prompt
    
  • * for transcription, these fields will be passed to the Whisper API.
    */
    
    input_audio_transcription?: Session.InputAudioTranscription;

@@ -1756,8 +1871,19 @@ export namespace SessionUpdateEvent {
*/
modalities?: Array<'text' | 'audio'>;

  • /**
  • * The Realtime model used for this session.
    
  • */
    
  • model?:
  •  | 'gpt-4o-realtime-preview'
    
  •  | 'gpt-4o-realtime-preview-2024-10-01'
    
  •  | 'gpt-4o-realtime-preview-2024-12-17'
    
  •  | 'gpt-4o-mini-realtime-preview'
    
  •  | 'gpt-4o-mini-realtime-preview-2024-12-17';
    
  • /**
    * The format of output audio. Options are pcm16, g711_ulaw, or g711_alaw.
  • * For `pcm16`, output audio is sampled at a rate of 24kHz.
    */
    
    output_audio_format?: 'pcm16' | 'g711_ulaw' | 'g711_alaw';

@@ -1797,15 +1923,33 @@ export namespace SessionUpdateEvent {
* Configuration for input audio transcription, defaults to off and can be set to
* null to turn off once on. Input audio transcription is not native to the
* model, since the model consumes audio directly. Transcription runs

  • * asynchronously through Whisper and should be treated as rough guidance rather
    
  • * than the representation understood by the model.
    
  • * asynchronously through
    
  • * [OpenAI Whisper transcription](https://platform.openai.com/docs/api-reference/audio/createTranscription)
    
  • * and should be treated as rough guidance rather than the representation
    
  • * understood by the model. The client can optionally set the language and prompt
    
  • * for transcription, these fields will be passed to the Whisper API.
    */
    

    export interface InputAudioTranscription {

  •  /**
    
  •   * The language of the input audio. Supplying the input language in
    
  •   * [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. `en`)
    
  •   * format will improve accuracy and latency.
    
  •   */
    
  •  language?: string;
    
  •  /**
      * The model to use for transcription, `whisper-1` is the only currently supported
      * model.
      */
     model?: string;
    
  •  /**
    
  •   * An optional text to guide the model's style or continue a previous audio
    
  •   * segment. The
    
  •   * [prompt](https://platform.openai.com/docs/guides/speech-to-text#prompting)
    
  •   * should match the audio language.
    
  •   */
    
  •  prompt?: string;
    

    }

    export interface Tool {
    diff --git src/resources/beta/realtime/sessions.ts src/resources/beta/realtime/sessions.ts
    index c1082d236..d2afa25b1 100644
    --- src/resources/beta/realtime/sessions.ts
    +++ src/resources/beta/realtime/sessions.ts
    @@ -32,7 +32,9 @@ export interface Session {
    id?: string;

    /**

    • The format of input audio. Options are pcm16, g711_ulaw, or g711_alaw.
    • The format of input audio. Options are pcm16, g711_ulaw, or g711_alaw. For
    • pcm16, input audio must be 16-bit PCM at a 24kHz sample rate, single channel
    • (mono), and little-endian byte order.
      */
      input_audio_format?: 'pcm16' | 'g711_ulaw' | 'g711_alaw';

@@ -86,6 +88,7 @@ export interface Session {

/**
* The format of output audio. Options are pcm16, g711_ulaw, or g711_alaw.

    • For pcm16, output audio is sampled at a rate of 24kHz.
      */
      output_audio_format?: 'pcm16' | 'g711_ulaw' | 'g711_alaw';

@@ -200,7 +203,7 @@ export interface SessionCreateResponse {
/**
* Ephemeral key returned by the API.
*/

  • client_secret?: SessionCreateResponse.ClientSecret;
  • client_secret: SessionCreateResponse.ClientSecret;

    /**

    • The format of input audio. Options are pcm16, g711_ulaw, or g711_alaw.
      @@ -289,14 +292,14 @@ export namespace SessionCreateResponse {
      • Timestamp for when the token expires. Currently, all tokens expire after one
      • minute.
        */
  • expires_at?: number;
  • expires_at: number;

    /**

    • Ephemeral key usable in client environments to authenticate connections to the
    • Realtime API. Use this in client-side environments rather than a standard API
    • token, which should only be used server-side.
      */
  • value?: string;
  • value: string;
    }

/**
@@ -372,17 +375,9 @@ export namespace SessionCreateResponse {

export interface SessionCreateParams {
/**

    • The Realtime model used for this session.
  • */
  • model:
  • | 'gpt-4o-realtime-preview'
  • | 'gpt-4o-realtime-preview-2024-10-01'
  • | 'gpt-4o-realtime-preview-2024-12-17'
  • | 'gpt-4o-mini-realtime-preview'
  • | 'gpt-4o-mini-realtime-preview-2024-12-17';
  • /**
    • The format of input audio. Options are pcm16, g711_ulaw, or g711_alaw.
    • The format of input audio. Options are pcm16, g711_ulaw, or g711_alaw. For
    • pcm16, input audio must be 16-bit PCM at a 24kHz sample rate, single channel
    • (mono), and little-endian byte order.
      */
      input_audio_format?: 'pcm16' | 'g711_ulaw' | 'g711_alaw';

@@ -390,8 +385,11 @@ export interface SessionCreateParams {
* Configuration for input audio transcription, defaults to off and can be set to
* null to turn off once on. Input audio transcription is not native to the
* model, since the model consumes audio directly. Transcription runs

    • asynchronously through Whisper and should be treated as rough guidance rather
    • than the representation understood by the model.
    • asynchronously through
    • and should be treated as rough guidance rather than the representation
    • understood by the model. The client can optionally set the language and prompt
    • for transcription, these fields will be passed to the Whisper API.
      */
      input_audio_transcription?: SessionCreateParams.InputAudioTranscription;

@@ -423,8 +421,19 @@ export interface SessionCreateParams {
*/
modalities?: Array<'text' | 'audio'>;

  • /**
    • The Realtime model used for this session.
  • */
  • model?:
  • | 'gpt-4o-realtime-preview'
  • | 'gpt-4o-realtime-preview-2024-10-01'
  • | 'gpt-4o-realtime-preview-2024-12-17'
  • | 'gpt-4o-mini-realtime-preview'
  • | 'gpt-4o-mini-realtime-preview-2024-12-17';
  • /**
    • The format of output audio. Options are pcm16, g711_ulaw, or g711_alaw.
    • For pcm16, output audio is sampled at a rate of 24kHz.
      */
      output_audio_format?: 'pcm16' | 'g711_ulaw' | 'g711_alaw';

@@ -464,15 +473,33 @@ export namespace SessionCreateParams {
* Configuration for input audio transcription, defaults to off and can be set to
* null to turn off once on. Input audio transcription is not native to the
* model, since the model consumes audio directly. Transcription runs

    • asynchronously through Whisper and should be treated as rough guidance rather
    • than the representation understood by the model.
    • asynchronously through
    • and should be treated as rough guidance rather than the representation
    • understood by the model. The client can optionally set the language and prompt
    • for transcription, these fields will be passed to the Whisper API.
      */
      export interface InputAudioTranscription {
  • /**
  • * The language of the input audio. Supplying the input language in
    
  • * [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. `en`)
    
  • * format will improve accuracy and latency.
    
  • */
    
  • language?: string;
  • /**
    * The model to use for transcription, whisper-1 is the only currently supported
    * model.
    */
    model?: string;
  • /**
  • * An optional text to guide the model's style or continue a previous audio
    
  • * segment. The
    
  • * [prompt](https://platform.openai.com/docs/guides/speech-to-text#prompting)
    
  • * should match the audio language.
    
  • */
    
  • prompt?: string;
    }

export interface Tool {
diff --git src/resources/beta/threads/messages.ts src/resources/beta/threads/messages.ts
index 8124f56cd..29fd2b29f 100644
--- src/resources/beta/threads/messages.ts
+++ src/resources/beta/threads/messages.ts
@@ -3,6 +3,7 @@
import { APIResource } from '../../../resource';
import { isRequestOptions } from '../../../core';
import * as Core from '../../../core';
+import * as Shared from '../../shared';
import * as AssistantsAPI from '../assistants';
import { CursorPage, type CursorPageParams } from '../../../pagination';

@@ -407,11 +408,13 @@ export interface Message {

/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful

    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata: unknown | null;
  • metadata: Shared.Metadata | null;

    /**

    • The object type, which is always thread.message.
      @@ -660,11 +663,13 @@ export interface MessageCreateParams {

    /**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;
    }

export namespace MessageCreateParams {
@@ -693,11 +698,13 @@ export namespace MessageCreateParams {
export interface MessageUpdateParams {
/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful

    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;
    }

export interface MessageListParams extends CursorPageParams {
diff --git src/resources/beta/threads/runs/runs.ts src/resources/beta/threads/runs/runs.ts
index 814ad3e89..84ba7b63c 100644
--- src/resources/beta/threads/runs/runs.ts
+++ src/resources/beta/threads/runs/runs.ts
@@ -8,6 +8,7 @@ import { AssistantStream, RunCreateParamsBaseStream } from '../../../../lib/Assi
import { sleep } from '../../../../core';
import { RunSubmitToolOutputsParamsStream } from '../../../../lib/AssistantStream';
import * as RunsAPI from './runs';
+import * as Shared from '../../../shared';
import * as AssistantsAPI from '../../assistants';
import * as ChatAPI from '../../../chat/chat';
import * as MessagesAPI from '../messages';
@@ -415,11 +416,13 @@ export interface Run {

/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful

    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata: unknown | null;
  • metadata: Shared.Metadata | null;

    /**

    • The model that the
      @@ -705,10 +708,12 @@ export interface RunCreateParamsBase {
      /**
    • Body param: Set of 16 key-value pairs that can be attached to an object. This
    • can be useful for storing additional information about the object in a
    • structured format. Keys can be a maximum of 64 characters long and values can be
    • a maxium of 512 characters long.
    • structured format, and querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;

    /**

    • Body param: The ID of the
      @@ -823,11 +828,13 @@ export namespace RunCreateParams {

    /**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
  • * for storing additional information about the object in a structured format. Keys
    
  • * can be a maximum of 64 characters long and values can be a maxium of 512
    
  • * characters long.
    
  • * for storing additional information about the object in a structured format, and
    
  • * querying for objects via API or the dashboard.
    
  • *
    
  • * Keys are strings with a maximum length of 64 characters. Values are strings with
    
  • * a maximum length of 512 characters.
    */
    
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;
    }

export namespace AdditionalMessage {
@@ -898,11 +905,13 @@ export interface RunCreateParamsStreaming extends RunCreateParamsBase {
export interface RunUpdateParams {
/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful

    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;
    }

export interface RunListParams extends CursorPageParams {
diff --git src/resources/beta/threads/runs/steps.ts src/resources/beta/threads/runs/steps.ts
index 6c6722b62..c491b4e83 100644
--- src/resources/beta/threads/runs/steps.ts
+++ src/resources/beta/threads/runs/steps.ts
@@ -4,6 +4,7 @@ import { APIResource } from '../../../../resource';
import { isRequestOptions } from '../../../../core';
import * as Core from '../../../../core';
import * as StepsAPI from './steps';
+import * as Shared from '../../../shared';
import { CursorPage, type CursorPageParams } from '../../../../pagination';

export class Steps extends APIResource {
@@ -515,11 +516,13 @@ export interface RunStep {

/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful

    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata: unknown | null;
  • metadata: Shared.Metadata | null;

    /**

    • The object type, which is always thread.run.step.
      diff --git src/resources/beta/threads/threads.ts src/resources/beta/threads/threads.ts
      index 453d8fa10..3f69c6e60 100644
      --- src/resources/beta/threads/threads.ts
      +++ src/resources/beta/threads/threads.ts
      @@ -250,11 +250,13 @@ export interface Thread {

    /**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata: unknown | null;
  • metadata: Shared.Metadata | null;

    /**

    • The object type, which is always thread.
      @@ -322,11 +324,13 @@ export interface ThreadCreateParams {

    /**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;

    /**

    • A set of resources that are made available to the assistant's tools in this
      @@ -361,11 +365,13 @@ export namespace ThreadCreateParams {

    /**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
  • * for storing additional information about the object in a structured format. Keys
    
  • * can be a maximum of 64 characters long and values can be a maxium of 512
    
  • * characters long.
    
  • * for storing additional information about the object in a structured format, and
    
  • * querying for objects via API or the dashboard.
    
  • *
    
  • * Keys are strings with a maximum length of 64 characters. Values are strings with
    
  • * a maximum length of 512 characters.
    */
    
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;
    }

export namespace Message {
@@ -447,12 +453,14 @@ export namespace ThreadCreateParams {
file_ids?: Array;

     /**
  •     * Set of 16 key-value pairs that can be attached to a vector, store. This can be
    
  •     * useful for storing additional information about the vector store in a structured
    
  •     * format. Keys can be a maximum of 64 characters long and values can be a maxium
    
  •     * of 512 characters long.
    
  •     * Set of 16 key-value pairs that can be attached to an object. This can be useful
    
  •     * for storing additional information about the object in a structured format, and
    
  •     * querying for objects via API or the dashboard.
    
  •     *
    
  •     * Keys are strings with a maximum length of 64 characters. Values are strings with
    
  •     * a maximum length of 512 characters.
        */
    
  •    metadata?: unknown;
    
  •    metadata?: Shared.Metadata | null;
     }
    
    }
    }
    @@ -461,11 +469,13 @@ export namespace ThreadCreateParams {
    export interface ThreadUpdateParams {
    /**
    • Set of 16 key-value pairs that can be attached to an object. This can be useful
    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;

    /**

    • A set of resources that are made available to the assistant's tools in this
      @@ -549,11 +559,13 @@ export interface ThreadCreateAndRunParamsBase {

    /**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;

    /**

    • The ID of the Model to
      @@ -609,7 +621,8 @@ export interface ThreadCreateAndRunParamsBase {
      temperature?: number | null;

    /**

    • If no thread is provided, an empty thread will be created.
    • Options to create a new thread. If no thread is provided when running a request,
    • an empty thread will be created.
      */
      thread?: ThreadCreateAndRunParams.Thread;

@@ -658,7 +671,8 @@ export interface ThreadCreateAndRunParamsBase {

export namespace ThreadCreateAndRunParams {
/**

    • If no thread is provided, an empty thread will be created.
    • Options to create a new thread. If no thread is provided when running a request,
    • an empty thread will be created.
      /
      export interface Thread {
      /
      *
      @@ -669,11 +683,13 @@ export namespace ThreadCreateAndRunParams {

    /**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
  • * for storing additional information about the object in a structured format. Keys
    
  • * can be a maximum of 64 characters long and values can be a maxium of 512
    
  • * characters long.
    
  • * for storing additional information about the object in a structured format, and
    
  • * querying for objects via API or the dashboard.
    
  • *
    
  • * Keys are strings with a maximum length of 64 characters. Values are strings with
    
  • * a maximum length of 512 characters.
    */
    
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;

    /**

    • A set of resources that are made available to the assistant's tools in this
      @@ -708,11 +724,13 @@ export namespace ThreadCreateAndRunParams {

    /**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
  •   * for storing additional information about the object in a structured format. Keys
    
  •   * can be a maximum of 64 characters long and values can be a maxium of 512
    
  •   * characters long.
    
  •   * for storing additional information about the object in a structured format, and
    
  •   * querying for objects via API or the dashboard.
    
  •   *
    
  •   * Keys are strings with a maximum length of 64 characters. Values are strings with
    
  •   * a maximum length of 512 characters.
      */
    
  •  metadata?: unknown | null;
    
  •  metadata?: Shared.Metadata | null;
    

    }

    export namespace Message {
    @@ -794,12 +812,14 @@ export namespace ThreadCreateAndRunParams {
    file_ids?: Array;

         /**
    
  •       * Set of 16 key-value pairs that can be attached to a vector store. This can be
    
  •       * useful for storing additional information about the vector store in a structured
    
  •       * format. Keys can be a maximum of 64 characters long and values can be a maxium
    
  •       * of 512 characters long.
    
  •       * Set of 16 key-value pairs that can be attached to an object. This can be useful
    
  •       * for storing additional information about the object in a structured format, and
    
  •       * querying for objects via API or the dashboard.
    
  •       *
    
  •       * Keys are strings with a maximum length of 64 characters. Values are strings with
    
  •       * a maximum length of 512 characters.
          */
    
  •      metadata?: unknown;
    
  •      metadata?: Shared.Metadata | null;
       }
     }
    

    }
    diff --git src/resources/beta/vector-stores/vector-stores.ts src/resources/beta/vector-stores/vector-stores.ts
    index cbff2d562..8438b79da 100644
    --- src/resources/beta/vector-stores/vector-stores.ts
    +++ src/resources/beta/vector-stores/vector-stores.ts
    @@ -3,6 +3,7 @@
    import { APIResource } from '../../../resource';
    import { isRequestOptions } from '../../../core';
    import * as Core from '../../../core';
    +import * as Shared from '../../shared';
    import * as FileBatchesAPI from './file-batches';
    import {
    FileBatchCreateParams,
    @@ -187,11 +188,13 @@ export interface VectorStore {

    /**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata: unknown | null;
  • metadata: Shared.Metadata | null;

    /**

    • The name of the vector store.
      @@ -300,11 +303,13 @@ export interface VectorStoreCreateParams {

    /**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;

    /**

    • The name of the vector store.
      @@ -338,11 +343,13 @@ export interface VectorStoreUpdateParams {

    /**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;

    /**

    • The name of the vector store.
      diff --git src/resources/chat/chat.ts src/resources/chat/chat.ts
      index 2230b19bd..d4a18929c 100644
      --- src/resources/chat/chat.ts
      +++ src/resources/chat/chat.ts
      @@ -46,6 +46,8 @@ export class Chat extends APIResource {
      }

export type ChatModel =

  • | 'o3-mini'

  • | 'o3-mini-2025-01-31'
    | 'o1'
    | 'o1-2024-12-17'
    | 'o1-preview'
    diff --git src/resources/chat/completions.ts src/resources/chat/completions.ts
    index 88c778036..55b008cf0 100644
    --- src/resources/chat/completions.ts
    +++ src/resources/chat/completions.ts
    @@ -76,8 +76,7 @@ export interface ChatCompletion {
    object: 'chat.completion';

    /**

    • The service tier used for processing the request. This field is only included if
    • the service_tier parameter is specified in the request.
    • The service tier used for processing the request.
      */
      service_tier?: 'scale' | 'default' | null;

@@ -300,8 +299,7 @@ export interface ChatCompletionChunk {
object: 'chat.completion.chunk';

/**

    • The service tier used for processing the request. This field is only included if
    • the service_tier parameter is specified in the request.
    • The service tier used for processing the request.
      */
      service_tier?: 'scale' | 'default' | null;

@@ -373,7 +371,7 @@ export namespace ChatCompletionChunk {
/**
* The role of the author of this message.
*/

  •  role?: 'system' | 'user' | 'assistant' | 'tool';
    
  •  role?: 'developer' | 'system' | 'user' | 'assistant' | 'tool';
    
     tool_calls?: Array<Delta.ToolCall>;
    
    }
    @@ -758,7 +756,7 @@ export type ChatCompletionReasoningEffort = 'low' | 'medium' | 'high';
    /**
    • The role of the author of a message
      */
      -export type ChatCompletionRole = 'system' | 'user' | 'assistant' | 'tool' | 'function';
      +export type ChatCompletionRole = 'developer' | 'system' | 'user' | 'assistant' | 'tool' | 'function';

/**

  • Options for streaming response. Only set this when you set stream: true.
    @@ -1014,10 +1012,14 @@ export interface ChatCompletionCreateParamsBase {
    max_tokens?: number | null;

/**

    • Developer-defined tags and values used for filtering completions in the
    • Set of 16 key-value pairs that can be attached to an object. This can be useful
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata?: Record<string, string> | null;
  • metadata?: Shared.Metadata | null;

    /**

    • Output types that you would like the model to generate for this request. Most
      @@ -1111,13 +1113,10 @@ export interface ChatCompletionCreateParamsBase {
    • utilize scale tier credits until they are exhausted.
      • If set to 'auto', and the Project is not Scale tier enabled, the request will
    • be processed using the default service tier with a lower uptime SLA and no
    • latency guarentee.
    • latency guarantee.
      • If set to 'default', the request will be processed using the default service
    • tier with a lower uptime SLA and no latency guarentee.
    • tier with a lower uptime SLA and no latency guarantee.
      • When not set, the default behavior is 'auto'.
    • When this parameter is set, the response body will include the service_tier
    • utilized.
      */
      service_tier?: 'auto' | 'default' | null;

diff --git src/resources/embeddings.ts src/resources/embeddings.ts
index 4b1644a68..d01ffc807 100644
--- src/resources/embeddings.ts
+++ src/resources/embeddings.ts
@@ -86,7 +86,8 @@ export interface EmbeddingCreateParams {
* text-embedding-ada-002), cannot be an empty string, and any array must be 2048
* dimensions or less.
* Example Python code

    • for counting tokens.
    • for counting tokens. Some models may also impose a limit on total number of
    • tokens summed across inputs.
      */
      input: string | Array | Array | Array<Array>;

diff --git src/resources/shared.ts src/resources/shared.ts
index f44fda8a7..3bb11582f 100644
--- src/resources/shared.ts
+++ src/resources/shared.ts
@@ -55,6 +55,16 @@ export interface FunctionDefinition {
*/
export type FunctionParameters = Record<string, unknown>;

+/**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
  • */
    +export type Metadata = Record<string, string>;

export interface ResponseFormatJSONObject {
/**
* The type of response format being defined: json_object
diff --git src/resources/uploads/uploads.ts src/resources/uploads/uploads.ts
index 8491d0fe2..bfe752cd7 100644
--- src/resources/uploads/uploads.ts
+++ src/resources/uploads/uploads.ts
@@ -113,7 +113,7 @@ export interface Upload {
status: 'pending' | 'completed' | 'cancelled' | 'expired';

/**

    • The ready File object after the Upload is completed.
    • The File object represents a document that has been uploaded to OpenAI.
      */
      file?: FilesAPI.FileObject | null;
      }
      diff --git src/version.ts src/version.ts
      index e8b9601ed..13c764d7d 100644
      --- src/version.ts
      +++ src/version.ts
      @@ -1 +1 @@
      -export const VERSION = '4.79.4'; // x-release-please-version
      +export const VERSION = '4.83.0'; // x-release-please-version
      diff --git tests/api-resources/beta/assistants.test.ts tests/api-resources/beta/assistants.test.ts
      index a64465c77..88a10ba8f 100644
      --- tests/api-resources/beta/assistants.test.ts
      +++ tests/api-resources/beta/assistants.test.ts
      @@ -25,7 +25,7 @@ describe('resource assistants', () => {
      model: 'gpt-4o',
      description: 'description',
      instructions: 'instructions',
  •  metadata: {},
    
  •  metadata: { foo: 'string' },
     name: 'name',
     response_format: 'auto',
     temperature: 1,
    

@@ -33,7 +33,9 @@ describe('resource assistants', () => {
code_interpreter: { file_ids: ['string'] },
file_search: {
vector_store_ids: ['string'],

  •      vector_stores: [{ chunking_strategy: { type: 'auto' }, file_ids: ['string'], metadata: {} }],
    
  •      vector_stores: [
    
  •        { chunking_strategy: { type: 'auto' }, file_ids: ['string'], metadata: { foo: 'string' } },
    
  •      ],
       },
     },
     tools: [{ type: 'code_interpreter' }],
    

diff --git tests/api-resources/beta/realtime/sessions.test.ts tests/api-resources/beta/realtime/sessions.test.ts
index 0ed998c27..dbb92ead3 100644
--- tests/api-resources/beta/realtime/sessions.test.ts
+++ tests/api-resources/beta/realtime/sessions.test.ts
@@ -9,8 +9,8 @@ const client = new OpenAI({
});

describe('resource sessions', () => {

  • test('create: only required params', async () => {
  • const responsePromise = client.beta.realtime.sessions.create({ model: 'gpt-4o-realtime-preview' });
  • test('create', async () => {
  • const responsePromise = client.beta.realtime.sessions.create({});
    const rawResponse = await responsePromise.asResponse();
    expect(rawResponse).toBeInstanceOf(Response);
    const response = await responsePromise;
    @@ -19,27 +19,4 @@ describe('resource sessions', () => {
    expect(dataAndResponse.data).toBe(response);
    expect(dataAndResponse.response).toBe(rawResponse);
    });
  • test('create: required and optional params', async () => {
  • const response = await client.beta.realtime.sessions.create({
  •  model: 'gpt-4o-realtime-preview',
    
  •  input_audio_format: 'pcm16',
    
  •  input_audio_transcription: { model: 'model' },
    
  •  instructions: 'instructions',
    
  •  max_response_output_tokens: 0,
    
  •  modalities: ['text'],
    
  •  output_audio_format: 'pcm16',
    
  •  temperature: 0,
    
  •  tool_choice: 'tool_choice',
    
  •  tools: [{ description: 'description', name: 'name', parameters: {}, type: 'function' }],
    
  •  turn_detection: {
    
  •    create_response: true,
    
  •    prefix_padding_ms: 0,
    
  •    silence_duration_ms: 0,
    
  •    threshold: 0,
    
  •    type: 'type',
    
  •  },
    
  •  voice: 'alloy',
    
  • });
  • });
    });
    diff --git tests/api-resources/beta/threads/messages.test.ts tests/api-resources/beta/threads/messages.test.ts
    index c1f5f7b6e..e125edd84 100644
    --- tests/api-resources/beta/threads/messages.test.ts
    +++ tests/api-resources/beta/threads/messages.test.ts
    @@ -28,7 +28,7 @@ describe('resource messages', () => {
    content: 'string',
    role: 'user',
    attachments: [{ file_id: 'file_id', tools: [{ type: 'code_interpreter' }] }],
  •  metadata: {},
    
  •  metadata: { foo: 'string' },
    
    });
    });

diff --git tests/api-resources/beta/threads/runs/runs.test.ts tests/api-resources/beta/threads/runs/runs.test.ts
index 4fd8261ac..9b728403f 100644
--- tests/api-resources/beta/threads/runs/runs.test.ts
+++ tests/api-resources/beta/threads/runs/runs.test.ts
@@ -30,13 +30,13 @@ describe('resource runs', () => {
content: 'string',
role: 'user',
attachments: [{ file_id: 'file_id', tools: [{ type: 'code_interpreter' }] }],

  •      metadata: {},
    
  •      metadata: { foo: 'string' },
       },
     ],
     instructions: 'instructions',
     max_completion_tokens: 256,
     max_prompt_tokens: 256,
    
  •  metadata: {},
    
  •  metadata: { foo: 'string' },
     model: 'gpt-4o',
     parallel_tool_calls: true,
     response_format: 'auto',
    

diff --git tests/api-resources/beta/threads/threads.test.ts tests/api-resources/beta/threads/threads.test.ts
index aba266316..f26d6ec44 100644
--- tests/api-resources/beta/threads/threads.test.ts
+++ tests/api-resources/beta/threads/threads.test.ts
@@ -37,15 +37,17 @@ describe('resource threads', () => {
content: 'string',
role: 'user',
attachments: [{ file_id: 'file_id', tools: [{ type: 'code_interpreter' }] }],

  •          metadata: {},
    
  •          metadata: { foo: 'string' },
           },
         ],
    
  •      metadata: {},
    
  •      metadata: { foo: 'string' },
         tool_resources: {
           code_interpreter: { file_ids: ['string'] },
           file_search: {
             vector_store_ids: ['string'],
    
  •          vector_stores: [{ chunking_strategy: { type: 'auto' }, file_ids: ['string'], metadata: {} }],
    
  •          vector_stores: [
    
  •            { chunking_strategy: { type: 'auto' }, file_ids: ['string'], metadata: { foo: 'string' } },
    
  •          ],
           },
         },
       },
    

@@ -118,7 +120,7 @@ describe('resource threads', () => {
instructions: 'instructions',
max_completion_tokens: 256,
max_prompt_tokens: 256,

  •  metadata: {},
    
  •  metadata: { foo: 'string' },
     model: 'gpt-4o',
     parallel_tool_calls: true,
     response_format: 'auto',
    

@@ -130,15 +132,17 @@ describe('resource threads', () => {
content: 'string',
role: 'user',
attachments: [{ file_id: 'file_id', tools: [{ type: 'code_interpreter' }] }],

  •        metadata: {},
    
  •        metadata: { foo: 'string' },
         },
       ],
    
  •    metadata: {},
    
  •    metadata: { foo: 'string' },
       tool_resources: {
         code_interpreter: { file_ids: ['string'] },
         file_search: {
           vector_store_ids: ['string'],
    
  •        vector_stores: [{ chunking_strategy: { type: 'auto' }, file_ids: ['string'], metadata: {} }],
    
  •        vector_stores: [
    
  •          { chunking_strategy: { type: 'auto' }, file_ids: ['string'], metadata: { foo: 'string' } },
    
  •        ],
         },
       },
     },
    

diff --git tests/api-resources/chat/completions.test.ts tests/api-resources/chat/completions.test.ts
index dfc09f69b..8f1bc7d4c 100644
--- tests/api-resources/chat/completions.test.ts
+++ tests/api-resources/chat/completions.test.ts
@@ -43,7 +43,7 @@ describe('resource completions', () => {
presence_penalty: -2,
reasoning_effort: 'low',
response_format: { type: 'text' },

  •  seed: -9007199254740991,
    
  •  seed: 0,
     service_tier: 'auto',
     stop: 'string',
     store: true,
    

diff --git tests/api-resources/completions.test.ts tests/api-resources/completions.test.ts
index 82322dc3a..c98501a87 100644
--- tests/api-resources/completions.test.ts
+++ tests/api-resources/completions.test.ts
@@ -32,7 +32,7 @@ describe('resource completions', () => {
max_tokens: 16,
n: 1,
presence_penalty: -2,

  •  seed: -9007199254740991,
    
  •  seed: 0,
     stop: '\n',
     stream: false,
     stream_options: { include_usage: true },
    

diff --git tests/lib/azure.test.ts tests/lib/azure.test.ts
index 064a0098c..430efbe57 100644
--- tests/lib/azure.test.ts
+++ tests/lib/azure.test.ts
@@ -51,6 +51,18 @@ describe('instantiate azure client', () => {
});
expect(req.headers as Headers).not.toHaveProperty('x-my-default-header');
});
+

  • test('includes retry count', () => {
  •  const { req } = client.buildRequest(
    
  •    {
    
  •      path: '/foo',
    
  •      method: 'post',
    
  •      headers: { 'X-My-Default-Header': null },
    
  •    },
    
  •    { retryCount: 1 },
    
  •  );
    
  •  expect((req.headers as Headers)['x-stainless-retry-count']).toEqual('1');
    
  • });
    });

describe('defaultQuery', () => {
@@ -483,21 +495,23 @@ describe('azure request building', () => {
);
});

  •  test('Audio translations is not handled', async () => {
    
  •  test('handles audio translations', async () => {
       const { url } = (await client.audio.translations.create({
         model: deployment,
         file: { url: 'https://example.com', blob: () => 0 as any },
       })) as any;
    
  •    expect(url).toStrictEqual(`https://example.com/openai/audio/translations?api-version=${apiVersion}`);
    
  •    expect(url).toStrictEqual(
    
  •      `https://example.com/openai/deployments/${deployment}/audio/translations?api-version=${apiVersion}`,
    
  •    );
     });
    
  •  test('Audio transcriptions is not handled', async () => {
    
  •  test('handles audio transcriptions', async () => {
       const { url } = (await client.audio.transcriptions.create({
         model: deployment,
         file: { url: 'https://example.com', blob: () => 0 as any },
       })) as any;
       expect(url).toStrictEqual(
    
  •      `https://example.com/openai/audio/transcriptions?api-version=${apiVersion}`,
    
  •      `https://example.com/openai/deployments/${deployment}/audio/transcriptions?api-version=${apiVersion}`,
       );
     });
    

</details>

### Description
This PR updates the openai-node library from version 4.79.4 to 4.83.0, introducing several new features, bug fixes, and API updates. The major changes include Azure Realtime API support, improved error handling, and various type and documentation improvements.

<details>
<summary><i>Changes</i></summary>

### Changes
By filename:

1. **Beta Realtime API**:
- Added Azure Realtime API support
- Added new message role types and metadata structures
- Updated ConversationItem and Session interfaces
- Added new audio transcription options

2. **Core Changes**:
- Added support for `X-Stainless-Timeout` header
- Fixed audio duration and role types
- Added Azure model deployment support for audio endpoints
- Added O3-mini model support

3. **Documentation**:
- Updated README with Azure Realtime API examples
- Fixed typos and documentation links
- Added more detailed audio format specifications

4. **Azure Support**:
- Added new Azure examples for realtime API
- Improved Azure authentication handling
- Added deployment name validation

5. **Testing**:
- Updated test cases for new features
- Added Azure-specific test cases
- Modified session creation tests



```mermaid
sequenceDiagram
    participant Client
    participant Azure
    participant OpenAI

    Client->>Azure: Create Azure OpenAI Client
    Azure-->>Client: Return Configured Client
    
    Client->>Azure: Initialize Realtime Session
    Azure-->>Client: Return Session Token
    
    Client->>Azure: Send Realtime Request
    Azure->>OpenAI: Forward Request
    OpenAI-->>Azure: Stream Response
    Azure-->>Client: Stream Response

    Note over Client,OpenAI: New Azure Realtime Flow

    Client->>Azure: Audio Request
    Azure->>OpenAI: Forward to Model Deployment
    OpenAI-->>Azure: Process Audio
    Azure-->>Client: Return Response

Security Hotspots

  1. Token Handling: The new Azure AD token provider implementation should be carefully reviewed for secure token management and rotation.
  2. WebSocket Connection: The new realtime websocket connections need to ensure proper connection termination and error handling to prevent resource leaks.

Possible Issues

  1. Breaking Change: The metadata type changes might affect existing implementations that use custom metadata structures.
  2. Compatibility: The new Azure deployment handling might require updates to existing Azure OpenAI implementations.
  3. Performance: The addition of the timeout header might affect existing timeout handling implementations.

Copy link

openai debug - [puLL-Merge] - openai/[email protected]

Diff
diff --git .release-please-manifest.json .release-please-manifest.json
index b1ab5c7b9..6eb0f130e 100644
--- .release-please-manifest.json
+++ .release-please-manifest.json
@@ -1,3 +1,3 @@
 {
-  ".": "4.79.4"
+  ".": "4.83.0"
 }
diff --git .stats.yml .stats.yml
index 9600edae3..df7877dfd 100644
--- .stats.yml
+++ .stats.yml
@@ -1,2 +1,2 @@
 configured_endpoints: 69
-openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-b5b0e2c794b012919701c3fd43286af10fa25d33ceb8a881bec2636028f446e0.yml
+openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-fc5dbc19505b0035f9e7f88868619f4fb519b048bde011f6154f3132d4be71fb.yml
diff --git CHANGELOG.md CHANGELOG.md
index 4254a9b8f..f61def5e4 100644
--- CHANGELOG.md
+++ CHANGELOG.md
@@ -1,5 +1,64 @@
 # Changelog
 
+## 4.83.0 (2025-02-05)
+
+Full Changelog: [v4.82.0...v4.83.0](https://github.com/openai/openai-node/compare/v4.82.0...v4.83.0)
+
+### Features
+
+* **client:** send `X-Stainless-Timeout` header ([#1299](https://github.com/openai/openai-node/issues/1299)) ([ddfc686](https://github.com/openai/openai-node/commit/ddfc686f43a3420c3adf8dec2e82b4d10a121eb8))
+
+
+### Bug Fixes
+
+* **api/types:** correct audio duration & role types ([#1300](https://github.com/openai/openai-node/issues/1300)) ([a955ac2](https://github.com/openai/openai-node/commit/a955ac2bf5bee663d530d0c82b0005bf3ce6fc47))
+* **azure/audio:** use model param for deployments ([#1297](https://github.com/openai/openai-node/issues/1297)) ([85de382](https://github.com/openai/openai-node/commit/85de382db17cbe5f112650e79d0fc1cc841efbb2))
+
+## 4.82.0 (2025-01-31)
+
+Full Changelog: [v4.81.0...v4.82.0](https://github.com/openai/openai-node/compare/v4.81.0...v4.82.0)
+
+### Features
+
+* **api:** add o3-mini ([#1295](https://github.com/openai/openai-node/issues/1295)) ([378e2f7](https://github.com/openai/openai-node/commit/378e2f7af62c570adb4c7644a4d49576b698de41))
+
+
+### Bug Fixes
+
+* **examples/realtime:** remove duplicate `session.update` call ([#1293](https://github.com/openai/openai-node/issues/1293)) ([ad800b4](https://github.com/openai/openai-node/commit/ad800b4f9410c6838994c24a3386ea708717f72b))
+* **types:** correct metadata type + other fixes ([378e2f7](https://github.com/openai/openai-node/commit/378e2f7af62c570adb4c7644a4d49576b698de41))
+
+## 4.81.0 (2025-01-29)
+
+Full Changelog: [v4.80.1...v4.81.0](https://github.com/openai/openai-node/compare/v4.80.1...v4.81.0)
+
+### Features
+
+* **azure:** Realtime API support ([#1287](https://github.com/openai/openai-node/issues/1287)) ([fe090c0](https://github.com/openai/openai-node/commit/fe090c0a57570217eb0b431e2cce40bf61de2b75))
+
+## 4.80.1 (2025-01-24)
+
+Full Changelog: [v4.80.0...v4.80.1](https://github.com/openai/openai-node/compare/v4.80.0...v4.80.1)
+
+### Bug Fixes
+
+* **azure:** include retry count header ([3e0ba40](https://github.com/openai/openai-node/commit/3e0ba409e57ce276fb1f95cd11c801e4ccaad572))
+
+
+### Documentation
+
+* fix typo, "zodFunctionTool" -&gt; "zodFunction" ([#1128](https://github.com/openai/openai-node/issues/1128)) ([b7ab6bb](https://github.com/openai/openai-node/commit/b7ab6bb304973ade94830f37eb646e800226d5ef))
+* **helpers:** fix type annotation ([fc019df](https://github.com/openai/openai-node/commit/fc019df1d9cc276e8f8e689742853a09aa94991a))
+* **readme:** fix realtime errors docs link ([#1286](https://github.com/openai/openai-node/issues/1286)) ([d1d50c8](https://github.com/openai/openai-node/commit/d1d50c897c18cefea964e8057fe1acfd766ae2bf))
+
+## 4.80.0 (2025-01-22)
+
+Full Changelog: [v4.79.4...v4.80.0](https://github.com/openai/openai-node/compare/v4.79.4...v4.80.0)
+
+### Features
+
+* **api:** update enum values, comments, and examples ([#1280](https://github.com/openai/openai-node/issues/1280)) ([d38f2c2](https://github.com/openai/openai-node/commit/d38f2c2648b6990f217c3c7d83ca31f3739641d3))
+
 ## 4.79.4 (2025-01-21)
 
 Full Changelog: [v4.79.3...v4.79.4](https://github.com/openai/openai-node/compare/v4.79.3...v4.79.4)
diff --git README.md README.md
index 3bd386e99..a1f4bf760 100644
--- README.md
+++ README.md
@@ -157,7 +157,7 @@ A full example can be found [here](https://github.com/openai/openai-node/blob/ma
 
 ### Realtime error handling
 
-When an error is encountered, either on the client side or returned from the server through the [`error` event](https://platform.openai.com/docs/guides/realtime/realtime-api-beta#handling-errors), the `error` event listener will be fired. However, if you haven't registered an `error` event listener then an `unhandled Promise rejection` error will be thrown.
+When an error is encountered, either on the client side or returned from the server through the [`error` event](https://platform.openai.com/docs/guides/realtime-model-capabilities#error-handling), the `error` event listener will be fired. However, if you haven't registered an `error` event listener then an `unhandled Promise rejection` error will be thrown.
 
 It is **highly recommended** that you register an `error` event listener and handle errors approriately as typically the underlying connection is still usable.
 
@@ -499,7 +499,7 @@ const credential = new DefaultAzureCredential();
 const scope = 'https://cognitiveservices.azure.com/.default';
 const azureADTokenProvider = getBearerTokenProvider(credential, scope);
 
-const openai = new AzureOpenAI({ azureADTokenProvider });
+const openai = new AzureOpenAI({ azureADTokenProvider, apiVersion: "<The API version, e.g. 2024-10-01-preview>" });
 
 const result = await openai.chat.completions.create({
   model: 'gpt-4o',
@@ -509,6 +509,26 @@ const result = await openai.chat.completions.create({
 console.log(result.choices[0]!.message?.content);
 \`\`\`
 
+### Realtime API
+This SDK provides real-time streaming capabilities for Azure OpenAI through the `OpenAIRealtimeWS` and `OpenAIRealtimeWebSocket` clients described previously.
+
+To utilize the real-time features, begin by creating a fully configured `AzureOpenAI` client and passing it into either `OpenAIRealtimeWS.azure` or `OpenAIRealtimeWebSocket.azure`. For example:
+
+```ts
+const cred = new DefaultAzureCredential();
+const scope = 'https://cognitiveservices.azure.com/.default';
+const deploymentName = 'gpt-4o-realtime-preview-1001';
+const azureADTokenProvider = getBearerTokenProvider(cred, scope);
+const client = new AzureOpenAI({
+  azureADTokenProvider,
+  apiVersion: '2024-10-01-preview',
+  deployment: deploymentName,
+});
+const rt = await OpenAIRealtimeWS.azure(client);
+```
+
+Once the instance has been created, you can then begin sending requests and receiving streaming responses in real time.
+
 ### Retries
 
 Certain errors will be automatically retried 2 times by default, with a short exponential backoff.
diff --git api.md api.md
index 33ab95ef6..01854a8e0 100644
--- api.md
+++ api.md
@@ -5,6 +5,7 @@ Types:
 - <code><a href="./src/resources/shared.ts">ErrorObject</a></code>
 - <code><a href="./src/resources/shared.ts">FunctionDefinition</a></code>
 - <code><a href="./src/resources/shared.ts">FunctionParameters</a></code>
+- <code><a href="./src/resources/shared.ts">Metadata</a></code>
 - <code><a href="./src/resources/shared.ts">ResponseFormatJSONObject</a></code>
 - <code><a href="./src/resources/shared.ts">ResponseFormatJSONSchema</a></code>
 - <code><a href="./src/resources/shared.ts">ResponseFormatText</a></code>
@@ -228,6 +229,7 @@ Types:
 - <code><a href="./src/resources/beta/realtime/realtime.ts">ConversationItemInputAudioTranscriptionFailedEvent</a></code>
 - <code><a href="./src/resources/beta/realtime/realtime.ts">ConversationItemTruncateEvent</a></code>
 - <code><a href="./src/resources/beta/realtime/realtime.ts">ConversationItemTruncatedEvent</a></code>
+- <code><a href="./src/resources/beta/realtime/realtime.ts">ConversationItemWithReference</a></code>
 - <code><a href="./src/resources/beta/realtime/realtime.ts">ErrorEvent</a></code>
 - <code><a href="./src/resources/beta/realtime/realtime.ts">InputAudioBufferAppendEvent</a></code>
 - <code><a href="./src/resources/beta/realtime/realtime.ts">InputAudioBufferClearEvent</a></code>
diff --git examples/azure.ts examples/azure/chat.ts
similarity index 91%
rename from examples/azure.ts
rename to examples/azure/chat.ts
index 5fe1718fa..46df820f8 100755
--- examples/azure.ts
+++ examples/azure/chat.ts
@@ -2,6 +2,7 @@
 
 import { AzureOpenAI } from 'openai';
 import { getBearerTokenProvider, DefaultAzureCredential } from '@azure/identity';
+import 'dotenv/config';
 
 // Corresponds to your Model deployment within your OpenAI resource, e.g. gpt-4-1106-preview
 // Navigate to the Azure OpenAI Studio to deploy a model.
@@ -13,7 +14,7 @@ const azureADTokenProvider = getBearerTokenProvider(credential, scope);
 
 // Make sure to set AZURE_OPENAI_ENDPOINT with the endpoint of your Azure resource.
 // You can find it in the Azure Portal.
-const openai = new AzureOpenAI({ azureADTokenProvider });
+const openai = new AzureOpenAI({ azureADTokenProvider, apiVersion: '2024-10-01-preview' });
 
 async function main() {
   console.log('Non-streaming:');
diff --git a/examples/azure/realtime/websocket.ts b/examples/azure/realtime/websocket.ts
new file mode 100644
index 000000000..bec74e654
--- /dev/null
+++ examples/azure/realtime/websocket.ts
@@ -0,0 +1,60 @@
+import { OpenAIRealtimeWebSocket } from 'openai/beta/realtime/websocket';
+import { AzureOpenAI } from 'openai';
+import { DefaultAzureCredential, getBearerTokenProvider } from '@azure/identity';
+import 'dotenv/config';
+
+async function main() {
+  const cred = new DefaultAzureCredential();
+  const scope = 'https://cognitiveservices.azure.com/.default';
+  const deploymentName = 'gpt-4o-realtime-preview-1001';
+  const azureADTokenProvider = getBearerTokenProvider(cred, scope);
+  const client = new AzureOpenAI({
+    azureADTokenProvider,
+    apiVersion: '2024-10-01-preview',
+    deployment: deploymentName,
+  });
+  const rt = await OpenAIRealtimeWebSocket.azure(client);
+
+  // access the underlying `ws.WebSocket` instance
+  rt.socket.addEventListener('open', () => {
+    console.log('Connection opened!');
+    rt.send({
+      type: 'session.update',
+      session: {
+        modalities: ['text'],
+        model: 'gpt-4o-realtime-preview',
+      },
+    });
+
+    rt.send({
+      type: 'conversation.item.create',
+      item: {
+        type: 'message',
+        role: 'user',
+        content: [{ type: 'input_text', text: 'Say a couple paragraphs!' }],
+      },
+    });
+
+    rt.send({ type: 'response.create' });
+  });
+
+  rt.on('error', (err) => {
+    // in a real world scenario this should be logged somewhere as you
+    // likely want to continue procesing events regardless of any errors
+    throw err;
+  });
+
+  rt.on('session.created', (event) => {
+    console.log('session created!', event.session);
+    console.log();
+  });
+
+  rt.on('response.text.delta', (event) => process.stdout.write(event.delta));
+  rt.on('response.text.done', () => console.log());
+
+  rt.on('response.done', () => rt.close());
+
+  rt.socket.addEventListener('close', () => console.log('\nConnection closed!'));
+}
+
+main();
diff --git a/examples/azure/realtime/ws.ts b/examples/azure/realtime/ws.ts
new file mode 100644
index 000000000..6ab7b742a
--- /dev/null
+++ examples/azure/realtime/ws.ts
@@ -0,0 +1,60 @@
+import { DefaultAzureCredential, getBearerTokenProvider } from '@azure/identity';
+import { OpenAIRealtimeWS } from 'openai/beta/realtime/ws';
+import { AzureOpenAI } from 'openai';
+import 'dotenv/config';
+
+async function main() {
+  const cred = new DefaultAzureCredential();
+  const scope = 'https://cognitiveservices.azure.com/.default';
+  const deploymentName = 'gpt-4o-realtime-preview-1001';
+  const azureADTokenProvider = getBearerTokenProvider(cred, scope);
+  const client = new AzureOpenAI({
+    azureADTokenProvider,
+    apiVersion: '2024-10-01-preview',
+    deployment: deploymentName,
+  });
+  const rt = await OpenAIRealtimeWS.azure(client);
+
+  // access the underlying `ws.WebSocket` instance
+  rt.socket.on('open', () => {
+    console.log('Connection opened!');
+    rt.send({
+      type: 'session.update',
+      session: {
+        modalities: ['text'],
+        model: 'gpt-4o-realtime-preview',
+      },
+    });
+
+    rt.send({
+      type: 'conversation.item.create',
+      item: {
+        type: 'message',
+        role: 'user',
+        content: [{ type: 'input_text', text: 'Say a couple paragraphs!' }],
+      },
+    });
+
+    rt.send({ type: 'response.create' });
+  });
+
+  rt.on('error', (err) => {
+    // in a real world scenario this should be logged somewhere as you
+    // likely want to continue procesing events regardless of any errors
+    throw err;
+  });
+
+  rt.on('session.created', (event) => {
+    console.log('session created!', event.session);
+    console.log();
+  });
+
+  rt.on('response.text.delta', (event) => process.stdout.write(event.delta));
+  rt.on('response.text.done', () => console.log());
+
+  rt.on('response.done', () => rt.close());
+
+  rt.socket.on('close', () => console.log('\nConnection closed!'));
+}
+
+main();
diff --git examples/package.json examples/package.json
index b8c34ac45..70ec2c523 100644
--- examples/package.json
+++ examples/package.json
@@ -7,6 +7,7 @@
   "private": true,
   "dependencies": {
     "@azure/identity": "^4.2.0",
+    "dotenv": "^16.4.7",
     "express": "^4.18.2",
     "next": "^14.1.1",
     "openai": "file:..",
diff --git examples/realtime/ws.ts examples/realtime/ws.ts
index 4bbe85e5d..08c6fbcb6 100644
--- examples/realtime/ws.ts
+++ examples/realtime/ws.ts
@@ -6,13 +6,6 @@ async function main() {
   // access the underlying `ws.WebSocket` instance
   rt.socket.on('open', () => {
     console.log('Connection opened!');
-    rt.send({
-      type: 'session.update',
-      session: {
-        modalities: ['foo'] as any,
-        model: 'gpt-4o-realtime-preview',
-      },
-    });
     rt.send({
       type: 'session.update',
       session: {
diff --git helpers.md helpers.md
index abf980c82..16bc1f277 100644
--- helpers.md
+++ helpers.md
@@ -49,7 +49,7 @@ if (message?.parsed) {
 
 The `.parse()` method will also automatically parse `function` tool calls if:
 
-- You use the `zodFunctionTool()` helper method
+- You use the `zodFunction()` helper method
 - You mark your tool schema with `"strict": True`
 
 For example:
@@ -226,7 +226,7 @@ on in the documentation page [Message](https://platform.openai.com/docs/api-refe
 
 ```ts
 .on('textCreated', (content: Text) => ...)
-.on('textDelta', (delta: RunStepDelta, snapshot: Text) => ...)
+.on('textDelta', (delta: TextDelta, snapshot: Text) => ...)
 .on('textDone', (content: Text, snapshot: Message) => ...)

diff --git jsr.json jsr.json
index e6d772116..6fa05e624 100644
--- jsr.json
+++ jsr.json
@@ -1,6 +1,6 @@
{
"name": "@openai/openai",

  • "version": "4.79.4",
  • "version": "4.83.0",
    "exports": {
    ".": "./index.ts",
    "./helpers/zod": "./helpers/zod.ts",
    diff --git package.json package.json
    index d7a5555e5..bd507e9f8 100644
    --- package.json
    +++ package.json
    @@ -1,6 +1,6 @@
    {
    "name": "openai",
  • "version": "4.79.4",
  • "version": "4.83.0",
    "description": "The official TypeScript library for the OpenAI API",
    "author": "OpenAI [email protected]",
    "types": "dist/index.d.ts",
    diff --git src/beta/realtime/internal-base.ts src/beta/realtime/internal-base.ts
    index 391d69911..b704812ee 100644
    --- src/beta/realtime/internal-base.ts
    +++ src/beta/realtime/internal-base.ts
    @@ -1,6 +1,7 @@
    import { RealtimeClientEvent, RealtimeServerEvent, ErrorEvent } from '../../resources/beta/realtime/realtime';
    import { EventEmitter } from '../../lib/EventEmitter';
    import { OpenAIError } from '../../error';
    +import OpenAI, { AzureOpenAI } from '../../index';

export class OpenAIRealtimeError extends OpenAIError {
/**
@@ -73,11 +74,20 @@ export abstract class OpenAIRealtimeEmitter extends EventEmitter
}
}

-export function buildRealtimeURL(props: { baseURL: string; model: string }): URL {

  • const path = '/realtime';
    +export function isAzure(client: Pick<OpenAI, 'apiKey' | 'baseURL'>): client is AzureOpenAI {
  • return client instanceof AzureOpenAI;
    +}
  • const url = new URL(props.baseURL + (props.baseURL.endsWith('/') ? path.slice(1) : path));
    +export function buildRealtimeURL(client: Pick<OpenAI, 'apiKey' | 'baseURL'>, model: string): URL {
  • const path = '/realtime';
  • const baseURL = client.baseURL;
  • const url = new URL(baseURL + (baseURL.endsWith('/') ? path.slice(1) : path));
    url.protocol = 'wss';
  • url.searchParams.set('model', props.model);
  • if (isAzure(client)) {
  • url.searchParams.set('api-version', client.apiVersion);
  • url.searchParams.set('deployment', model);
  • } else {
  • url.searchParams.set('model', model);
  • }
    return url;
    }
    diff --git src/beta/realtime/websocket.ts src/beta/realtime/websocket.ts
    index e0853779d..349cf5760 100644
    --- src/beta/realtime/websocket.ts
    +++ src/beta/realtime/websocket.ts
    @@ -1,8 +1,8 @@
    -import { OpenAI } from '../../index';
    +import { AzureOpenAI, OpenAI } from '../../index';
    import { OpenAIError } from '../../error';
    import * as Core from '../../core';
    import type { RealtimeClientEvent, RealtimeServerEvent } from '../../resources/beta/realtime/realtime';
    -import { OpenAIRealtimeEmitter, buildRealtimeURL } from './internal-base';
    +import { OpenAIRealtimeEmitter, buildRealtimeURL, isAzure } from './internal-base';

interface MessageEvent {
data: string;
@@ -26,6 +26,11 @@ export class OpenAIRealtimeWebSocket extends OpenAIRealtimeEmitter {
props: {
model: string;
dangerouslyAllowBrowser?: boolean;

  •  /**
    
  •   * Callback to mutate the URL, needed for Azure.
    
  •   * @internal
    
  •   */
    
  •  onURL?: (url: URL) => void;
    

    },
    client?: Pick<OpenAI, 'apiKey' | 'baseURL'>,
    ) {
    @@ -44,11 +49,13 @@ export class OpenAIRealtimeWebSocket extends OpenAIRealtimeEmitter {

    client ??= new OpenAI({ dangerouslyAllowBrowser });

  • this.url = buildRealtimeURL({ baseURL: client.baseURL, model: props.model });
  • this.url = buildRealtimeURL(client, props.model);
  • props.onURL?.(this.url);
  • // @ts-ignore
    this.socket = new WebSocket(this.url, [
    'realtime',
  •  `openai-insecure-api-key.${client.apiKey}`,
    
  •  ...(isAzure(client) ? [] : [`openai-insecure-api-key.${client.apiKey}`]),
     'openai-beta.realtime-v1',
    
    ]);

@@ -77,6 +84,45 @@ export class OpenAIRealtimeWebSocket extends OpenAIRealtimeEmitter {
this.socket.addEventListener('error', (event: any) => {
this._onError(null, event.message, null);
});
+

  • if (isAzure(client)) {
  •  if (this.url.searchParams.get('Authorization') !== null) {
    
  •    this.url.searchParams.set('Authorization', '<REDACTED>');
    
  •  } else {
    
  •    this.url.searchParams.set('api-key', '<REDACTED>');
    
  •  }
    
  • }
  • }
  • static async azure(
  • client: AzureOpenAI,
  • options: { deploymentName?: string; dangerouslyAllowBrowser?: boolean } = {},
  • ): Promise {
  • const token = await client._getAzureADToken();
  • function onURL(url: URL) {
  •  if (client.apiKey !== '<Missing Key>') {
    
  •    url.searchParams.set('api-key', client.apiKey);
    
  •  } else {
    
  •    if (token) {
    
  •      url.searchParams.set('Authorization', `Bearer ${token}`);
    
  •    } else {
    
  •      throw new Error('AzureOpenAI is not instantiated correctly. No API key or token provided.');
    
  •    }
    
  •  }
    
  • }
  • const deploymentName = options.deploymentName ?? client.deploymentName;
  • if (!deploymentName) {
  •  throw new Error('No deployment name provided');
    
  • }
  • const { dangerouslyAllowBrowser } = options;
  • return new OpenAIRealtimeWebSocket(
  •  {
    
  •    model: deploymentName,
    
  •    onURL,
    
  •    ...(dangerouslyAllowBrowser ? { dangerouslyAllowBrowser } : {}),
    
  •  },
    
  •  client,
    
  • );
    }

send(event: RealtimeClientEvent) {
diff --git src/beta/realtime/ws.ts src/beta/realtime/ws.ts
index 631a36cd2..51339089c 100644
--- src/beta/realtime/ws.ts
+++ src/beta/realtime/ws.ts
@@ -1,7 +1,7 @@
import * as WS from 'ws';
-import { OpenAI } from '../../index';
+import { AzureOpenAI, OpenAI } from '../../index';
import type { RealtimeClientEvent, RealtimeServerEvent } from '../../resources/beta/realtime/realtime';
-import { OpenAIRealtimeEmitter, buildRealtimeURL } from './internal-base';
+import { OpenAIRealtimeEmitter, buildRealtimeURL, isAzure } from './internal-base';

export class OpenAIRealtimeWS extends OpenAIRealtimeEmitter {
url: URL;
@@ -14,12 +14,12 @@ export class OpenAIRealtimeWS extends OpenAIRealtimeEmitter {
super();
client ??= new OpenAI();

  • this.url = buildRealtimeURL({ baseURL: client.baseURL, model: props.model });
  • this.url = buildRealtimeURL(client, props.model);
    this.socket = new WS.WebSocket(this.url, {
    ...props.options,
    headers: {
    ...props.options?.headers,
  •    Authorization: `Bearer ${client.apiKey}`,
    
  •    ...(isAzure(client) ? {} : { Authorization: `Bearer ${client.apiKey}` }),
       'OpenAI-Beta': 'realtime=v1',
     },
    

    });
    @@ -51,6 +51,20 @@ export class OpenAIRealtimeWS extends OpenAIRealtimeEmitter {
    });
    }

  • static async azure(

  • client: AzureOpenAI,

  • options: { deploymentName?: string; options?: WS.ClientOptions | undefined } = {},

  • ): Promise {

  • const deploymentName = options.deploymentName ?? client.deploymentName;

  • if (!deploymentName) {

  •  throw new Error('No deployment name provided');
    
  • }

  • return new OpenAIRealtimeWS(

  •  { model: deploymentName, options: { headers: await getAzureHeaders(client) } },
    
  •  client,
    
  • );

  • }

  • send(event: RealtimeClientEvent) {
    try {
    this.socket.send(JSON.stringify(event));
    @@ -67,3 +81,16 @@ export class OpenAIRealtimeWS extends OpenAIRealtimeEmitter {
    }
    }
    }

+async function getAzureHeaders(client: AzureOpenAI) {

  • if (client.apiKey !== '') {

  • return { 'api-key': client.apiKey };

  • } else {

  • const token = await client._getAzureADToken();

  • if (token) {

  •  return { Authorization: `Bearer ${token}` };
    
  • } else {

  •  throw new Error('AzureOpenAI is not instantiated correctly. No API key or token provided.');
    
  • }

  • }
    +}
    diff --git src/core.ts src/core.ts
    index 3d2d029a5..6578c0781 100644
    --- src/core.ts
    +++ src/core.ts
    @@ -315,6 +315,7 @@ export abstract class APIClient {
    options: FinalRequestOptions,
    { retryCount = 0 }: { retryCount?: number } = {},
    ): { req: RequestInit; url: string; timeout: number } {

  • options = { ...options };
    const { method, path, query, headers: headers = {} } = options;

    const body =
    @@ -327,9 +328,9 @@ export abstract class APIClient {

    const url = this.buildURL(path!, query);
    if ('timeout' in options) validatePositiveInteger('timeout', options.timeout);

  • const timeout = options.timeout ?? this.timeout;
  • options.timeout = options.timeout ?? this.timeout;
    const httpAgent = options.httpAgent ?? this.httpAgent ?? getDefaultAgent(url);
  • const minAgentTimeout = timeout + 1000;
  • const minAgentTimeout = options.timeout + 1000;
    if (
    typeof (httpAgent as any)?.options?.timeout === 'number' &&
    minAgentTimeout > ((httpAgent as any).options.timeout ?? 0)
    @@ -358,7 +359,7 @@ export abstract class APIClient {
    signal: options.signal ?? null,
    };
  • return { req, url, timeout };
  • return { req, url, timeout: options.timeout };
    }

private buildHeaders({
@@ -386,15 +387,22 @@ export abstract class APIClient {
delete reqHeaders['content-type'];
}

  • // Don't set the retry count header if it was already set or removed through default headers or by the
  • // caller. We check defaultHeaders and headers, which can contain nulls, instead of reqHeaders to
  • // account for the removal case.
  • // Don't set theses headers if they were already set or removed through default headers or by the caller.

  • // We check defaultHeaders and headers, which can contain nulls, instead of reqHeaders to account

  • // for the removal case.
    if (
    getHeader(defaultHeaders, 'x-stainless-retry-count') === undefined &&
    getHeader(headers, 'x-stainless-retry-count') === undefined
    ) {
    reqHeaders['x-stainless-retry-count'] = String(retryCount);
    }

  • if (

  •  getHeader(defaultHeaders, 'x-stainless-timeout') === undefined &&
    
  •  getHeader(headers, 'x-stainless-timeout') === undefined &&
    
  •  options.timeout
    
  • ) {

  •  reqHeaders['x-stainless-timeout'] = String(options.timeout);
    
  • }

    this.validateHeaders(reqHeaders, headers);

@@ -814,6 +822,7 @@ export type RequestOptions<
signal?: AbortSignal | undefined | null;
idempotencyKey?: string;

  • __metadata?: Record<string, unknown>;
    __binaryRequest?: boolean | undefined;
    __binaryResponse?: boolean | undefined;
    __streamClass?: typeof Stream;
    @@ -836,6 +845,7 @@ const requestOptionsKeys: KeysEnum = {
    signal: true,
    idempotencyKey: true,

  • __metadata: true,
    __binaryRequest: true,
    __binaryResponse: true,
    __streamClass: true,
    diff --git src/index.ts src/index.ts
    index cf6aa89e3..f4e940af8 100644
    --- src/index.ts
    +++ src/index.ts
    @@ -451,6 +451,7 @@ export declare namespace OpenAI {
    export type ErrorObject = API.ErrorObject;
    export type FunctionDefinition = API.FunctionDefinition;
    export type FunctionParameters = API.FunctionParameters;

  • export type Metadata = API.Metadata;
    export type ResponseFormatJSONObject = API.ResponseFormatJSONObject;
    export type ResponseFormatJSONSchema = API.ResponseFormatJSONSchema;
    export type ResponseFormatText = API.ResponseFormatText;
    @@ -491,7 +492,7 @@ export interface AzureClientOptions extends ClientOptions {
    /** API Client for interfacing with the Azure OpenAI API. */
    export class AzureOpenAI extends OpenAI {
    private _azureADTokenProvider: (() => Promise) | undefined;

  • private _deployment: string | undefined;
  • deploymentName: string | undefined;
    apiVersion: string = '';
    /**

    • API Client for interfacing with the Azure OpenAI API.
      @@ -574,10 +575,13 @@ export class AzureOpenAI extends OpenAI {

    this._azureADTokenProvider = azureADTokenProvider;
    this.apiVersion = apiVersion;

  • this._deployment = deployment;
  • this.deploymentName = deployment;
    }
  • override buildRequest(options: Core.FinalRequestOptions): {
  • override buildRequest(
  • options: Core.FinalRequestOptions,
  • props: { retryCount?: number } = {},
  • ): {
    req: RequestInit;
    url: string;
    timeout: number;
    @@ -586,15 +590,15 @@ export class AzureOpenAI extends OpenAI {
    if (!Core.isObj(options.body)) {
    throw new Error('Expected request body to be an object');
    }
  •  const model = this._deployment || options.body['model'];
    
  •  const model = this.deploymentName || options.body['model'] || options.__metadata?.['model'];
     if (model !== undefined && !this.baseURL.includes('/deployments')) {
       options.path = `/deployments/${model}${options.path}`;
     }
    
    }
  • return super.buildRequest(options);
  • return super.buildRequest(options, props);
    }
  • private async _getAzureADToken(): Promise<string | undefined> {
  • async _getAzureADToken(): Promise<string | undefined> {
    if (typeof this._azureADTokenProvider === 'function') {
    const token = await this._azureADTokenProvider();
    if (!token || typeof token !== 'string') {
    diff --git src/lib/ChatCompletionStream.ts src/lib/ChatCompletionStream.ts
    index a88f8a23b..6c846f70b 100644
    --- src/lib/ChatCompletionStream.ts
    +++ src/lib/ChatCompletionStream.ts
    @@ -12,6 +12,7 @@ import {
    type ChatCompletionCreateParams,
    type ChatCompletionCreateParamsStreaming,
    type ChatCompletionCreateParamsBase,
  • type ChatCompletionRole,
    } from '../resources/chat/completions';
    import {
    AbstractChatCompletionRunner,
    @@ -797,7 +798,7 @@ export namespace ChatCompletionSnapshot {
    /**
    * The role of the author of this message.
    */
  •  role?: 'system' | 'user' | 'assistant' | 'function' | 'tool';
    
  •  role?: ChatCompletionRole;
    

    }

    export namespace Message {
    diff --git src/resources/audio/speech.ts src/resources/audio/speech.ts
    index bd2ed9f65..35e82c4c1 100644
    --- src/resources/audio/speech.ts
    +++ src/resources/audio/speech.ts
    @@ -33,12 +33,12 @@ export interface SpeechCreateParams {
    model: (string & {}) | SpeechModel;

    /**

    • The voice to use when generating the audio. Supported voices are alloy,
    • echo, fable, onyx, nova, and shimmer. Previews of the voices are
    • available in the
    • The voice to use when generating the audio. Supported voices are alloy, ash,
    • coral, echo, fable, onyx, nova, sage and shimmer. Previews of the
  • voice: 'alloy' | 'echo' | 'fable' | 'onyx' | 'nova' | 'shimmer';
  • voice: 'alloy' | 'ash' | 'coral' | 'echo' | 'fable' | 'onyx' | 'nova' | 'sage' | 'shimmer';

    /**

    • The format to audio in. Supported formats are mp3, opus, aac, flac,
      diff --git src/resources/audio/transcriptions.ts src/resources/audio/transcriptions.ts
      index 0b6da4620..6fbe96b58 100644
      --- src/resources/audio/transcriptions.ts
      +++ src/resources/audio/transcriptions.ts
      @@ -25,7 +25,10 @@ export class Transcriptions extends APIResource {
      body: TranscriptionCreateParams,
      options?: Core.RequestOptions,
      ): Core.APIPromise<TranscriptionCreateResponse | string> {
  • return this._client.post('/audio/transcriptions', Core.multipartFormRequestOptions({ body, ...options }));
  • return this._client.post(
  •  '/audio/transcriptions',
    
  •  Core.multipartFormRequestOptions({ body, ...options, __metadata: { model: body.model } }),
    
  • );
    }
    }

@@ -103,7 +106,7 @@ export interface TranscriptionVerbose {
/**
* The duration of the input audio.
*/

  • duration: string;
  • duration: number;

    /**

    • The language of the input audio.
      @@ -166,8 +169,8 @@ export interface TranscriptionCreateParams<

    /**

    • The language of the input audio. Supplying the input language in
    • improve accuracy and latency.
    • format will improve accuracy and latency.
      */
      language?: string;

diff --git src/resources/audio/translations.ts src/resources/audio/translations.ts
index c6bf7c870..dac519ede 100644
--- src/resources/audio/translations.ts
+++ src/resources/audio/translations.ts
@@ -26,7 +26,10 @@ export class Translations extends APIResource {
body: TranslationCreateParams,
options?: Core.RequestOptions,
): Core.APIPromise<TranslationCreateResponse | string> {

  • return this._client.post('/audio/translations', Core.multipartFormRequestOptions({ body, ...options }));
  • return this._client.post(
  •  '/audio/translations',
    
  •  Core.multipartFormRequestOptions({ body, ...options, __metadata: { model: body.model } }),
    
  • );
    }
    }

@@ -38,7 +41,7 @@ export interface TranslationVerbose {
/**
* The duration of the input audio.
*/

  • duration: string;
  • duration: number;

    /**

    • The language of the output translation (always english).
      diff --git src/resources/batches.ts src/resources/batches.ts
      index ec5ca6331..aadda83a6 100644
      --- src/resources/batches.ts
      +++ src/resources/batches.ts
      @@ -4,6 +4,7 @@ import { APIResource } from '../resource';
      import { isRequestOptions } from '../core';
      import * as Core from '../core';
      import * as BatchesAPI from './batches';
      +import * as Shared from './shared';
      import { CursorPage, type CursorPageParams } from '../pagination';

export class Batches extends APIResource {
@@ -138,11 +139,13 @@ export interface Batch {

/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful

    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;

    /**

    • The ID of the file containing the outputs of successfully executed requests.
      @@ -237,9 +240,14 @@ export interface BatchCreateParams {
      input_file_id: string;

    /**

    • Optional custom metadata for the batch.
    • Set of 16 key-value pairs that can be attached to an object. This can be useful
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata?: Record<string, string> | null;
  • metadata?: Shared.Metadata | null;
    }

export interface BatchListParams extends CursorPageParams {}
diff --git src/resources/beta/assistants.ts src/resources/beta/assistants.ts
index 0e657b1d4..69a5db520 100644
--- src/resources/beta/assistants.ts
+++ src/resources/beta/assistants.ts
@@ -111,11 +111,13 @@ export interface Assistant {

/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful

    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata: unknown | null;
  • metadata: Shared.Metadata | null;

    /**

    • ID of the model to use. You can use the
      @@ -1118,11 +1120,13 @@ export interface AssistantCreateParams {

    /**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;

    /**

    • The name of the assistant. The maximum length is 256 characters.
      @@ -1242,12 +1246,14 @@ export namespace AssistantCreateParams {
      file_ids?: Array;

      /**

  •     * Set of 16 key-value pairs that can be attached to a vector store. This can be
    
  •     * useful for storing additional information about the vector store in a structured
    
  •     * format. Keys can be a maximum of 64 characters long and values can be a maxium
    
  •     * of 512 characters long.
    
  •     * Set of 16 key-value pairs that can be attached to an object. This can be useful
    
  •     * for storing additional information about the object in a structured format, and
    
  •     * querying for objects via API or the dashboard.
    
  •     *
    
  •     * Keys are strings with a maximum length of 64 characters. Values are strings with
    
  •     * a maximum length of 512 characters.
        */
    
  •    metadata?: unknown;
    
  •    metadata?: Shared.Metadata | null;
     }
    

    }
    }
    @@ -1267,11 +1273,13 @@ export interface AssistantUpdateParams {

    /**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;

    /**

    • ID of the model to use. You can use the
      diff --git src/resources/beta/realtime/realtime.ts src/resources/beta/realtime/realtime.ts
      index 5de06917a..e46dcdaaf 100644
      --- src/resources/beta/realtime/realtime.ts
      +++ src/resources/beta/realtime/realtime.ts
      @@ -2,6 +2,7 @@

import { APIResource } from '../../../resource';
import * as RealtimeAPI from './realtime';
+import * as Shared from '../../shared';
import * as SessionsAPI from './sessions';
import {
Session as SessionsAPISession,
@@ -173,9 +174,10 @@ export interface ConversationItemCreateEvent {

/**
* The ID of the preceding item after which the new item will be inserted. If not

    • set, the new item will be appended to the end of the conversation. If set, it
    • allows an item to be inserted mid-conversation. If the ID cannot be found, an
    • error will be returned and the item will not be added.
    • set, the new item will be appended to the end of the conversation. If set to
    • root, the new item will be added to the beginning of the conversation. If set
    • to an existing ID, it allows an item to be inserted mid-conversation. If the ID
    • cannot be found, an error will be returned and the item will not be added.
      */
      previous_item_id?: string;
      }
      @@ -437,6 +439,76 @@ export interface ConversationItemTruncatedEvent {
      type: 'conversation.item.truncated';
      }

+/**

    • The item to add to the conversation.
  • */
    +export interface ConversationItemWithReference {
  • /**
    • For an item of type (message | function_call | function_call_output) this
    • field allows the client to assign the unique ID of the item. It is not required
    • because the server will generate one if not provided.
    • For an item of type item_reference, this field is required and is a reference
    • to any item that has previously existed in the conversation.
  • */
  • id?: string;
  • /**
    • The arguments of the function call (for function_call items).
  • */
  • arguments?: string;
  • /**
    • The ID of the function call (for function_call and function_call_output
    • items). If passed on a function_call_output item, the server will check that a
    • function_call item with the same ID exists in the conversation history.
  • */
  • call_id?: string;
  • /**
    • The content of the message, applicable for message items.
      • Message items of role system support only input_text content
      • Message items of role user support input_text and input_audio content
      • Message items of role assistant support text content.
  • */
  • content?: Array;
  • /**
    • The name of the function being called (for function_call items).
  • */
  • name?: string;
  • /**
    • Identifier for the API object being returned - always realtime.item.
  • */
  • object?: 'realtime.item';
  • /**
    • The output of the function call (for function_call_output items).
  • */
  • output?: string;
  • /**
    • The role of the message sender (user, assistant, system), only applicable
    • for message items.
  • */
  • role?: 'user' | 'assistant' | 'system';
  • /**
    • The status of the item (completed, incomplete). These have no effect on the
    • conversation, but are accepted for consistency with the
    • conversation.item.created event.
  • */
  • status?: 'completed' | 'incomplete';
  • /**
    • The type of the item (message, function_call, function_call_output,
    • item_reference).
  • */
  • type?: 'message' | 'function_call' | 'function_call_output' | 'item_reference';
    +}

/**

  • Returned when an error occurs, which could be a client problem or a server
  • problem. Most errors are recoverable and the session will stay open, we
    @@ -740,9 +812,38 @@ export interface RealtimeResponse {
    id?: string;

/**

    • Developer-provided string key-value pairs associated with this response.
    • Which conversation the response is added to, determined by the conversation
    • field in the response.create event. If auto, the response will be added to
    • the default conversation and the value of conversation_id will be an id like
    • conv_1234. If none, the response will not be added to any conversation and
    • the value of conversation_id will be null. If responses are being triggered
    • by server VAD, the response will be added to the default conversation, thus the
    • conversation_id will be an id like conv_1234.
  • */
  • conversation_id?: string;
  • /**
    • Maximum number of output tokens for a single assistant response, inclusive of
    • tool calls, that was used in this response.
  • */
  • max_output_tokens?: number | 'inf';
  • /**
    • Set of 16 key-value pairs that can be attached to an object. This can be useful
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;

  • /**

    • The set of modalities the model used to respond. If there are multiple
    • modalities, the model will pick one, for example if modalities is
    • ["text", "audio"], the model could be responding in either text or audio.
  • */

  • modalities?: Array<'text' | 'audio'>;

    /**

    • The object type, must be realtime.response.
      @@ -754,6 +855,11 @@ export interface RealtimeResponse {
      */
      output?: Array;
  • /**

    • The format of output audio. Options are pcm16, g711_ulaw, or g711_alaw.
  • */

  • output_audio_format?: 'pcm16' | 'g711_ulaw' | 'g711_alaw';

  • /**

    • The final status of the response (completed, cancelled, failed, or
    • incomplete).
      @@ -765,6 +871,11 @@ export interface RealtimeResponse {
      */
      status_details?: RealtimeResponseStatus;
  • /**

    • Sampling temperature for the model, limited to [0.6, 1.2]. Defaults to 0.8.
  • */

  • temperature?: number;

  • /**

    • Usage statistics for the Response, this will correspond to billing. A Realtime
    • API session will maintain a conversation context and append new Items to the
      @@ -772,6 +883,12 @@ export interface RealtimeResponse {
    • become the input for later turns.
      */
      usage?: RealtimeResponseUsage;
  • /**

    • The voice the model used to respond. Current voice options are alloy, ash,
    • ballad, coral, echo sage, shimmer and verse.
  • */

  • voice?: 'alloy' | 'ash' | 'ballad' | 'coral' | 'echo' | 'sage' | 'shimmer' | 'verse';
    }

/**
@@ -1289,11 +1406,12 @@ export namespace ResponseCreateEvent {
conversation?: (string & {}) | 'auto' | 'none';

 /**
  • * Input items to include in the prompt for the model. Creates a new context for
    
  • * this response, without including the default conversation. Can include
    
  • * references to items from the default conversation.
    
  • * Input items to include in the prompt for the model. Using this field creates a
    
  • * new context for this Response instead of using the default conversation. An
    
  • * empty array `[]` will clear the context for this Response. Note that this can
    
  • * include references to items from the default conversation.
    */
    
  • input?: Array<RealtimeAPI.ConversationItem>;
  • input?: Array<RealtimeAPI.ConversationItemWithReference>;

    /**

    • The default system instructions (i.e. system message) prepended to model calls.
      @@ -1319,11 +1437,13 @@ export namespace ResponseCreateEvent {

    /**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
  • * for storing additional information about the object in a structured format. Keys
    
  • * can be a maximum of 64 characters long and values can be a maximum of 512
    
  • * characters long.
    
  • * for storing additional information about the object in a structured format, and
    
  • * querying for objects via API or the dashboard.
    
  • *
    
  • * Keys are strings with a maximum length of 64 characters. Values are strings with
    
  • * a maximum length of 512 characters.
    */
    
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;

    /**

    • The set of modalities the model can respond with. To disable audio, set this to
      @@ -1705,17 +1825,9 @@ export namespace SessionUpdateEvent {
      /
      export interface Session {
      /
      *
  • * The Realtime model used for this session.
    
  • */
    
  • model:
  •  | 'gpt-4o-realtime-preview'
    
  •  | 'gpt-4o-realtime-preview-2024-10-01'
    
  •  | 'gpt-4o-realtime-preview-2024-12-17'
    
  •  | 'gpt-4o-mini-realtime-preview'
    
  •  | 'gpt-4o-mini-realtime-preview-2024-12-17';
    
  • /**
  • * The format of input audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`.
    
  • * The format of input audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`. For
    
  • * `pcm16`, input audio must be 16-bit PCM at a 24kHz sample rate, single channel
    
  • * (mono), and little-endian byte order.
    */
    
    input_audio_format?: 'pcm16' | 'g711_ulaw' | 'g711_alaw';

@@ -1723,8 +1835,11 @@ export namespace SessionUpdateEvent {
* Configuration for input audio transcription, defaults to off and can be set to
* null to turn off once on. Input audio transcription is not native to the
* model, since the model consumes audio directly. Transcription runs

  • * asynchronously through Whisper and should be treated as rough guidance rather
    
  • * than the representation understood by the model.
    
  • * asynchronously through
    
  • * [OpenAI Whisper transcription](https://platform.openai.com/docs/api-reference/audio/createTranscription)
    
  • * and should be treated as rough guidance rather than the representation
    
  • * understood by the model. The client can optionally set the language and prompt
    
  • * for transcription, these fields will be passed to the Whisper API.
    */
    
    input_audio_transcription?: Session.InputAudioTranscription;

@@ -1756,8 +1871,19 @@ export namespace SessionUpdateEvent {
*/
modalities?: Array<'text' | 'audio'>;

  • /**
  • * The Realtime model used for this session.
    
  • */
    
  • model?:
  •  | 'gpt-4o-realtime-preview'
    
  •  | 'gpt-4o-realtime-preview-2024-10-01'
    
  •  | 'gpt-4o-realtime-preview-2024-12-17'
    
  •  | 'gpt-4o-mini-realtime-preview'
    
  •  | 'gpt-4o-mini-realtime-preview-2024-12-17';
    
  • /**
    * The format of output audio. Options are pcm16, g711_ulaw, or g711_alaw.
  • * For `pcm16`, output audio is sampled at a rate of 24kHz.
    */
    
    output_audio_format?: 'pcm16' | 'g711_ulaw' | 'g711_alaw';

@@ -1797,15 +1923,33 @@ export namespace SessionUpdateEvent {
* Configuration for input audio transcription, defaults to off and can be set to
* null to turn off once on. Input audio transcription is not native to the
* model, since the model consumes audio directly. Transcription runs

  • * asynchronously through Whisper and should be treated as rough guidance rather
    
  • * than the representation understood by the model.
    
  • * asynchronously through
    
  • * [OpenAI Whisper transcription](https://platform.openai.com/docs/api-reference/audio/createTranscription)
    
  • * and should be treated as rough guidance rather than the representation
    
  • * understood by the model. The client can optionally set the language and prompt
    
  • * for transcription, these fields will be passed to the Whisper API.
    */
    

    export interface InputAudioTranscription {

  •  /**
    
  •   * The language of the input audio. Supplying the input language in
    
  •   * [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. `en`)
    
  •   * format will improve accuracy and latency.
    
  •   */
    
  •  language?: string;
    
  •  /**
      * The model to use for transcription, `whisper-1` is the only currently supported
      * model.
      */
     model?: string;
    
  •  /**
    
  •   * An optional text to guide the model's style or continue a previous audio
    
  •   * segment. The
    
  •   * [prompt](https://platform.openai.com/docs/guides/speech-to-text#prompting)
    
  •   * should match the audio language.
    
  •   */
    
  •  prompt?: string;
    

    }

    export interface Tool {
    diff --git src/resources/beta/realtime/sessions.ts src/resources/beta/realtime/sessions.ts
    index c1082d236..d2afa25b1 100644
    --- src/resources/beta/realtime/sessions.ts
    +++ src/resources/beta/realtime/sessions.ts
    @@ -32,7 +32,9 @@ export interface Session {
    id?: string;

    /**

    • The format of input audio. Options are pcm16, g711_ulaw, or g711_alaw.
    • The format of input audio. Options are pcm16, g711_ulaw, or g711_alaw. For
    • pcm16, input audio must be 16-bit PCM at a 24kHz sample rate, single channel
    • (mono), and little-endian byte order.
      */
      input_audio_format?: 'pcm16' | 'g711_ulaw' | 'g711_alaw';

@@ -86,6 +88,7 @@ export interface Session {

/**
* The format of output audio. Options are pcm16, g711_ulaw, or g711_alaw.

    • For pcm16, output audio is sampled at a rate of 24kHz.
      */
      output_audio_format?: 'pcm16' | 'g711_ulaw' | 'g711_alaw';

@@ -200,7 +203,7 @@ export interface SessionCreateResponse {
/**
* Ephemeral key returned by the API.
*/

  • client_secret?: SessionCreateResponse.ClientSecret;
  • client_secret: SessionCreateResponse.ClientSecret;

    /**

    • The format of input audio. Options are pcm16, g711_ulaw, or g711_alaw.
      @@ -289,14 +292,14 @@ export namespace SessionCreateResponse {
      • Timestamp for when the token expires. Currently, all tokens expire after one
      • minute.
        */
  • expires_at?: number;
  • expires_at: number;

    /**

    • Ephemeral key usable in client environments to authenticate connections to the
    • Realtime API. Use this in client-side environments rather than a standard API
    • token, which should only be used server-side.
      */
  • value?: string;
  • value: string;
    }

/**
@@ -372,17 +375,9 @@ export namespace SessionCreateResponse {

export interface SessionCreateParams {
/**

    • The Realtime model used for this session.
  • */
  • model:
  • | 'gpt-4o-realtime-preview'
  • | 'gpt-4o-realtime-preview-2024-10-01'
  • | 'gpt-4o-realtime-preview-2024-12-17'
  • | 'gpt-4o-mini-realtime-preview'
  • | 'gpt-4o-mini-realtime-preview-2024-12-17';
  • /**
    • The format of input audio. Options are pcm16, g711_ulaw, or g711_alaw.
    • The format of input audio. Options are pcm16, g711_ulaw, or g711_alaw. For
    • pcm16, input audio must be 16-bit PCM at a 24kHz sample rate, single channel
    • (mono), and little-endian byte order.
      */
      input_audio_format?: 'pcm16' | 'g711_ulaw' | 'g711_alaw';

@@ -390,8 +385,11 @@ export interface SessionCreateParams {
* Configuration for input audio transcription, defaults to off and can be set to
* null to turn off once on. Input audio transcription is not native to the
* model, since the model consumes audio directly. Transcription runs

    • asynchronously through Whisper and should be treated as rough guidance rather
    • than the representation understood by the model.
    • asynchronously through
    • and should be treated as rough guidance rather than the representation
    • understood by the model. The client can optionally set the language and prompt
    • for transcription, these fields will be passed to the Whisper API.
      */
      input_audio_transcription?: SessionCreateParams.InputAudioTranscription;

@@ -423,8 +421,19 @@ export interface SessionCreateParams {
*/
modalities?: Array<'text' | 'audio'>;

  • /**
    • The Realtime model used for this session.
  • */
  • model?:
  • | 'gpt-4o-realtime-preview'
  • | 'gpt-4o-realtime-preview-2024-10-01'
  • | 'gpt-4o-realtime-preview-2024-12-17'
  • | 'gpt-4o-mini-realtime-preview'
  • | 'gpt-4o-mini-realtime-preview-2024-12-17';
  • /**
    • The format of output audio. Options are pcm16, g711_ulaw, or g711_alaw.
    • For pcm16, output audio is sampled at a rate of 24kHz.
      */
      output_audio_format?: 'pcm16' | 'g711_ulaw' | 'g711_alaw';

@@ -464,15 +473,33 @@ export namespace SessionCreateParams {
* Configuration for input audio transcription, defaults to off and can be set to
* null to turn off once on. Input audio transcription is not native to the
* model, since the model consumes audio directly. Transcription runs

    • asynchronously through Whisper and should be treated as rough guidance rather
    • than the representation understood by the model.
    • asynchronously through
    • and should be treated as rough guidance rather than the representation
    • understood by the model. The client can optionally set the language and prompt
    • for transcription, these fields will be passed to the Whisper API.
      */
      export interface InputAudioTranscription {
  • /**
  • * The language of the input audio. Supplying the input language in
    
  • * [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. `en`)
    
  • * format will improve accuracy and latency.
    
  • */
    
  • language?: string;
  • /**
    * The model to use for transcription, whisper-1 is the only currently supported
    * model.
    */
    model?: string;
  • /**
  • * An optional text to guide the model's style or continue a previous audio
    
  • * segment. The
    
  • * [prompt](https://platform.openai.com/docs/guides/speech-to-text#prompting)
    
  • * should match the audio language.
    
  • */
    
  • prompt?: string;
    }

export interface Tool {
diff --git src/resources/beta/threads/messages.ts src/resources/beta/threads/messages.ts
index 8124f56cd..29fd2b29f 100644
--- src/resources/beta/threads/messages.ts
+++ src/resources/beta/threads/messages.ts
@@ -3,6 +3,7 @@
import { APIResource } from '../../../resource';
import { isRequestOptions } from '../../../core';
import * as Core from '../../../core';
+import * as Shared from '../../shared';
import * as AssistantsAPI from '../assistants';
import { CursorPage, type CursorPageParams } from '../../../pagination';

@@ -407,11 +408,13 @@ export interface Message {

/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful

    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata: unknown | null;
  • metadata: Shared.Metadata | null;

    /**

    • The object type, which is always thread.message.
      @@ -660,11 +663,13 @@ export interface MessageCreateParams {

    /**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;
    }

export namespace MessageCreateParams {
@@ -693,11 +698,13 @@ export namespace MessageCreateParams {
export interface MessageUpdateParams {
/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful

    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;
    }

export interface MessageListParams extends CursorPageParams {
diff --git src/resources/beta/threads/runs/runs.ts src/resources/beta/threads/runs/runs.ts
index 814ad3e89..84ba7b63c 100644
--- src/resources/beta/threads/runs/runs.ts
+++ src/resources/beta/threads/runs/runs.ts
@@ -8,6 +8,7 @@ import { AssistantStream, RunCreateParamsBaseStream } from '../../../../lib/Assi
import { sleep } from '../../../../core';
import { RunSubmitToolOutputsParamsStream } from '../../../../lib/AssistantStream';
import * as RunsAPI from './runs';
+import * as Shared from '../../../shared';
import * as AssistantsAPI from '../../assistants';
import * as ChatAPI from '../../../chat/chat';
import * as MessagesAPI from '../messages';
@@ -415,11 +416,13 @@ export interface Run {

/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful

    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata: unknown | null;
  • metadata: Shared.Metadata | null;

    /**

    • The model that the
      @@ -705,10 +708,12 @@ export interface RunCreateParamsBase {
      /**
    • Body param: Set of 16 key-value pairs that can be attached to an object. This
    • can be useful for storing additional information about the object in a
    • structured format. Keys can be a maximum of 64 characters long and values can be
    • a maxium of 512 characters long.
    • structured format, and querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;

    /**

    • Body param: The ID of the
      @@ -823,11 +828,13 @@ export namespace RunCreateParams {

    /**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
  • * for storing additional information about the object in a structured format. Keys
    
  • * can be a maximum of 64 characters long and values can be a maxium of 512
    
  • * characters long.
    
  • * for storing additional information about the object in a structured format, and
    
  • * querying for objects via API or the dashboard.
    
  • *
    
  • * Keys are strings with a maximum length of 64 characters. Values are strings with
    
  • * a maximum length of 512 characters.
    */
    
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;
    }

export namespace AdditionalMessage {
@@ -898,11 +905,13 @@ export interface RunCreateParamsStreaming extends RunCreateParamsBase {
export interface RunUpdateParams {
/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful

    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;
    }

export interface RunListParams extends CursorPageParams {
diff --git src/resources/beta/threads/runs/steps.ts src/resources/beta/threads/runs/steps.ts
index 6c6722b62..c491b4e83 100644
--- src/resources/beta/threads/runs/steps.ts
+++ src/resources/beta/threads/runs/steps.ts
@@ -4,6 +4,7 @@ import { APIResource } from '../../../../resource';
import { isRequestOptions } from '../../../../core';
import * as Core from '../../../../core';
import * as StepsAPI from './steps';
+import * as Shared from '../../../shared';
import { CursorPage, type CursorPageParams } from '../../../../pagination';

export class Steps extends APIResource {
@@ -515,11 +516,13 @@ export interface RunStep {

/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful

    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata: unknown | null;
  • metadata: Shared.Metadata | null;

    /**

    • The object type, which is always thread.run.step.
      diff --git src/resources/beta/threads/threads.ts src/resources/beta/threads/threads.ts
      index 453d8fa10..3f69c6e60 100644
      --- src/resources/beta/threads/threads.ts
      +++ src/resources/beta/threads/threads.ts
      @@ -250,11 +250,13 @@ export interface Thread {

    /**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata: unknown | null;
  • metadata: Shared.Metadata | null;

    /**

    • The object type, which is always thread.
      @@ -322,11 +324,13 @@ export interface ThreadCreateParams {

    /**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;

    /**

    • A set of resources that are made available to the assistant's tools in this
      @@ -361,11 +365,13 @@ export namespace ThreadCreateParams {

    /**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
  • * for storing additional information about the object in a structured format. Keys
    
  • * can be a maximum of 64 characters long and values can be a maxium of 512
    
  • * characters long.
    
  • * for storing additional information about the object in a structured format, and
    
  • * querying for objects via API or the dashboard.
    
  • *
    
  • * Keys are strings with a maximum length of 64 characters. Values are strings with
    
  • * a maximum length of 512 characters.
    */
    
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;
    }

export namespace Message {
@@ -447,12 +453,14 @@ export namespace ThreadCreateParams {
file_ids?: Array;

     /**
  •     * Set of 16 key-value pairs that can be attached to a vector, store. This can be
    
  •     * useful for storing additional information about the vector store in a structured
    
  •     * format. Keys can be a maximum of 64 characters long and values can be a maxium
    
  •     * of 512 characters long.
    
  •     * Set of 16 key-value pairs that can be attached to an object. This can be useful
    
  •     * for storing additional information about the object in a structured format, and
    
  •     * querying for objects via API or the dashboard.
    
  •     *
    
  •     * Keys are strings with a maximum length of 64 characters. Values are strings with
    
  •     * a maximum length of 512 characters.
        */
    
  •    metadata?: unknown;
    
  •    metadata?: Shared.Metadata | null;
     }
    
    }
    }
    @@ -461,11 +469,13 @@ export namespace ThreadCreateParams {
    export interface ThreadUpdateParams {
    /**
    • Set of 16 key-value pairs that can be attached to an object. This can be useful
    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;

    /**

    • A set of resources that are made available to the assistant's tools in this
      @@ -549,11 +559,13 @@ export interface ThreadCreateAndRunParamsBase {

    /**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;

    /**

    • The ID of the Model to
      @@ -609,7 +621,8 @@ export interface ThreadCreateAndRunParamsBase {
      temperature?: number | null;

    /**

    • If no thread is provided, an empty thread will be created.
    • Options to create a new thread. If no thread is provided when running a request,
    • an empty thread will be created.
      */
      thread?: ThreadCreateAndRunParams.Thread;

@@ -658,7 +671,8 @@ export interface ThreadCreateAndRunParamsBase {

export namespace ThreadCreateAndRunParams {
/**

    • If no thread is provided, an empty thread will be created.
    • Options to create a new thread. If no thread is provided when running a request,
    • an empty thread will be created.
      /
      export interface Thread {
      /
      *
      @@ -669,11 +683,13 @@ export namespace ThreadCreateAndRunParams {

    /**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
  • * for storing additional information about the object in a structured format. Keys
    
  • * can be a maximum of 64 characters long and values can be a maxium of 512
    
  • * characters long.
    
  • * for storing additional information about the object in a structured format, and
    
  • * querying for objects via API or the dashboard.
    
  • *
    
  • * Keys are strings with a maximum length of 64 characters. Values are strings with
    
  • * a maximum length of 512 characters.
    */
    
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;

    /**

    • A set of resources that are made available to the assistant's tools in this
      @@ -708,11 +724,13 @@ export namespace ThreadCreateAndRunParams {

    /**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
  •   * for storing additional information about the object in a structured format. Keys
    
  •   * can be a maximum of 64 characters long and values can be a maxium of 512
    
  •   * characters long.
    
  •   * for storing additional information about the object in a structured format, and
    
  •   * querying for objects via API or the dashboard.
    
  •   *
    
  •   * Keys are strings with a maximum length of 64 characters. Values are strings with
    
  •   * a maximum length of 512 characters.
      */
    
  •  metadata?: unknown | null;
    
  •  metadata?: Shared.Metadata | null;
    

    }

    export namespace Message {
    @@ -794,12 +812,14 @@ export namespace ThreadCreateAndRunParams {
    file_ids?: Array;

         /**
    
  •       * Set of 16 key-value pairs that can be attached to a vector store. This can be
    
  •       * useful for storing additional information about the vector store in a structured
    
  •       * format. Keys can be a maximum of 64 characters long and values can be a maxium
    
  •       * of 512 characters long.
    
  •       * Set of 16 key-value pairs that can be attached to an object. This can be useful
    
  •       * for storing additional information about the object in a structured format, and
    
  •       * querying for objects via API or the dashboard.
    
  •       *
    
  •       * Keys are strings with a maximum length of 64 characters. Values are strings with
    
  •       * a maximum length of 512 characters.
          */
    
  •      metadata?: unknown;
    
  •      metadata?: Shared.Metadata | null;
       }
     }
    

    }
    diff --git src/resources/beta/vector-stores/vector-stores.ts src/resources/beta/vector-stores/vector-stores.ts
    index cbff2d562..8438b79da 100644
    --- src/resources/beta/vector-stores/vector-stores.ts
    +++ src/resources/beta/vector-stores/vector-stores.ts
    @@ -3,6 +3,7 @@
    import { APIResource } from '../../../resource';
    import { isRequestOptions } from '../../../core';
    import * as Core from '../../../core';
    +import * as Shared from '../../shared';
    import * as FileBatchesAPI from './file-batches';
    import {
    FileBatchCreateParams,
    @@ -187,11 +188,13 @@ export interface VectorStore {

    /**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata: unknown | null;
  • metadata: Shared.Metadata | null;

    /**

    • The name of the vector store.
      @@ -300,11 +303,13 @@ export interface VectorStoreCreateParams {

    /**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;

    /**

    • The name of the vector store.
      @@ -338,11 +343,13 @@ export interface VectorStoreUpdateParams {

    /**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;

    /**

    • The name of the vector store.
      diff --git src/resources/chat/chat.ts src/resources/chat/chat.ts
      index 2230b19bd..d4a18929c 100644
      --- src/resources/chat/chat.ts
      +++ src/resources/chat/chat.ts
      @@ -46,6 +46,8 @@ export class Chat extends APIResource {
      }

export type ChatModel =

  • | 'o3-mini'

  • | 'o3-mini-2025-01-31'
    | 'o1'
    | 'o1-2024-12-17'
    | 'o1-preview'
    diff --git src/resources/chat/completions.ts src/resources/chat/completions.ts
    index 88c778036..55b008cf0 100644
    --- src/resources/chat/completions.ts
    +++ src/resources/chat/completions.ts
    @@ -76,8 +76,7 @@ export interface ChatCompletion {
    object: 'chat.completion';

    /**

    • The service tier used for processing the request. This field is only included if
    • the service_tier parameter is specified in the request.
    • The service tier used for processing the request.
      */
      service_tier?: 'scale' | 'default' | null;

@@ -300,8 +299,7 @@ export interface ChatCompletionChunk {
object: 'chat.completion.chunk';

/**

    • The service tier used for processing the request. This field is only included if
    • the service_tier parameter is specified in the request.
    • The service tier used for processing the request.
      */
      service_tier?: 'scale' | 'default' | null;

@@ -373,7 +371,7 @@ export namespace ChatCompletionChunk {
/**
* The role of the author of this message.
*/

  •  role?: 'system' | 'user' | 'assistant' | 'tool';
    
  •  role?: 'developer' | 'system' | 'user' | 'assistant' | 'tool';
    
     tool_calls?: Array<Delta.ToolCall>;
    
    }
    @@ -758,7 +756,7 @@ export type ChatCompletionReasoningEffort = 'low' | 'medium' | 'high';
    /**
    • The role of the author of a message
      */
      -export type ChatCompletionRole = 'system' | 'user' | 'assistant' | 'tool' | 'function';
      +export type ChatCompletionRole = 'developer' | 'system' | 'user' | 'assistant' | 'tool' | 'function';

/**

  • Options for streaming response. Only set this when you set stream: true.
    @@ -1014,10 +1012,14 @@ export interface ChatCompletionCreateParamsBase {
    max_tokens?: number | null;

/**

    • Developer-defined tags and values used for filtering completions in the
    • Set of 16 key-value pairs that can be attached to an object. This can be useful
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata?: Record<string, string> | null;
  • metadata?: Shared.Metadata | null;

    /**

    • Output types that you would like the model to generate for this request. Most
      @@ -1111,13 +1113,10 @@ export interface ChatCompletionCreateParamsBase {
    • utilize scale tier credits until they are exhausted.
      • If set to 'auto', and the Project is not Scale tier enabled, the request will
    • be processed using the default service tier with a lower uptime SLA and no
    • latency guarentee.
    • latency guarantee.
      • If set to 'default', the request will be processed using the default service
    • tier with a lower uptime SLA and no latency guarentee.
    • tier with a lower uptime SLA and no latency guarantee.
      • When not set, the default behavior is 'auto'.
    • When this parameter is set, the response body will include the service_tier
    • utilized.
      */
      service_tier?: 'auto' | 'default' | null;

diff --git src/resources/embeddings.ts src/resources/embeddings.ts
index 4b1644a68..d01ffc807 100644
--- src/resources/embeddings.ts
+++ src/resources/embeddings.ts
@@ -86,7 +86,8 @@ export interface EmbeddingCreateParams {
* text-embedding-ada-002), cannot be an empty string, and any array must be 2048
* dimensions or less.
* Example Python code

    • for counting tokens.
    • for counting tokens. Some models may also impose a limit on total number of
    • tokens summed across inputs.
      */
      input: string | Array | Array | Array<Array>;

diff --git src/resources/shared.ts src/resources/shared.ts
index f44fda8a7..3bb11582f 100644
--- src/resources/shared.ts
+++ src/resources/shared.ts
@@ -55,6 +55,16 @@ export interface FunctionDefinition {
*/
export type FunctionParameters = Record<string, unknown>;

+/**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
  • */
    +export type Metadata = Record<string, string>;

export interface ResponseFormatJSONObject {
/**
* The type of response format being defined: json_object
diff --git src/resources/uploads/uploads.ts src/resources/uploads/uploads.ts
index 8491d0fe2..bfe752cd7 100644
--- src/resources/uploads/uploads.ts
+++ src/resources/uploads/uploads.ts
@@ -113,7 +113,7 @@ export interface Upload {
status: 'pending' | 'completed' | 'cancelled' | 'expired';

/**

    • The ready File object after the Upload is completed.
    • The File object represents a document that has been uploaded to OpenAI.
      */
      file?: FilesAPI.FileObject | null;
      }
      diff --git src/version.ts src/version.ts
      index e8b9601ed..13c764d7d 100644
      --- src/version.ts
      +++ src/version.ts
      @@ -1 +1 @@
      -export const VERSION = '4.79.4'; // x-release-please-version
      +export const VERSION = '4.83.0'; // x-release-please-version
      diff --git tests/api-resources/beta/assistants.test.ts tests/api-resources/beta/assistants.test.ts
      index a64465c77..88a10ba8f 100644
      --- tests/api-resources/beta/assistants.test.ts
      +++ tests/api-resources/beta/assistants.test.ts
      @@ -25,7 +25,7 @@ describe('resource assistants', () => {
      model: 'gpt-4o',
      description: 'description',
      instructions: 'instructions',
  •  metadata: {},
    
  •  metadata: { foo: 'string' },
     name: 'name',
     response_format: 'auto',
     temperature: 1,
    

@@ -33,7 +33,9 @@ describe('resource assistants', () => {
code_interpreter: { file_ids: ['string'] },
file_search: {
vector_store_ids: ['string'],

  •      vector_stores: [{ chunking_strategy: { type: 'auto' }, file_ids: ['string'], metadata: {} }],
    
  •      vector_stores: [
    
  •        { chunking_strategy: { type: 'auto' }, file_ids: ['string'], metadata: { foo: 'string' } },
    
  •      ],
       },
     },
     tools: [{ type: 'code_interpreter' }],
    

diff --git tests/api-resources/beta/realtime/sessions.test.ts tests/api-resources/beta/realtime/sessions.test.ts
index 0ed998c27..dbb92ead3 100644
--- tests/api-resources/beta/realtime/sessions.test.ts
+++ tests/api-resources/beta/realtime/sessions.test.ts
@@ -9,8 +9,8 @@ const client = new OpenAI({
});

describe('resource sessions', () => {

  • test('create: only required params', async () => {
  • const responsePromise = client.beta.realtime.sessions.create({ model: 'gpt-4o-realtime-preview' });
  • test('create', async () => {
  • const responsePromise = client.beta.realtime.sessions.create({});
    const rawResponse = await responsePromise.asResponse();
    expect(rawResponse).toBeInstanceOf(Response);
    const response = await responsePromise;
    @@ -19,27 +19,4 @@ describe('resource sessions', () => {
    expect(dataAndResponse.data).toBe(response);
    expect(dataAndResponse.response).toBe(rawResponse);
    });
  • test('create: required and optional params', async () => {
  • const response = await client.beta.realtime.sessions.create({
  •  model: 'gpt-4o-realtime-preview',
    
  •  input_audio_format: 'pcm16',
    
  •  input_audio_transcription: { model: 'model' },
    
  •  instructions: 'instructions',
    
  •  max_response_output_tokens: 0,
    
  •  modalities: ['text'],
    
  •  output_audio_format: 'pcm16',
    
  •  temperature: 0,
    
  •  tool_choice: 'tool_choice',
    
  •  tools: [{ description: 'description', name: 'name', parameters: {}, type: 'function' }],
    
  •  turn_detection: {
    
  •    create_response: true,
    
  •    prefix_padding_ms: 0,
    
  •    silence_duration_ms: 0,
    
  •    threshold: 0,
    
  •    type: 'type',
    
  •  },
    
  •  voice: 'alloy',
    
  • });
  • });
    });
    diff --git tests/api-resources/beta/threads/messages.test.ts tests/api-resources/beta/threads/messages.test.ts
    index c1f5f7b6e..e125edd84 100644
    --- tests/api-resources/beta/threads/messages.test.ts
    +++ tests/api-resources/beta/threads/messages.test.ts
    @@ -28,7 +28,7 @@ describe('resource messages', () => {
    content: 'string',
    role: 'user',
    attachments: [{ file_id: 'file_id', tools: [{ type: 'code_interpreter' }] }],
  •  metadata: {},
    
  •  metadata: { foo: 'string' },
    
    });
    });

diff --git tests/api-resources/beta/threads/runs/runs.test.ts tests/api-resources/beta/threads/runs/runs.test.ts
index 4fd8261ac..9b728403f 100644
--- tests/api-resources/beta/threads/runs/runs.test.ts
+++ tests/api-resources/beta/threads/runs/runs.test.ts
@@ -30,13 +30,13 @@ describe('resource runs', () => {
content: 'string',
role: 'user',
attachments: [{ file_id: 'file_id', tools: [{ type: 'code_interpreter' }] }],

  •      metadata: {},
    
  •      metadata: { foo: 'string' },
       },
     ],
     instructions: 'instructions',
     max_completion_tokens: 256,
     max_prompt_tokens: 256,
    
  •  metadata: {},
    
  •  metadata: { foo: 'string' },
     model: 'gpt-4o',
     parallel_tool_calls: true,
     response_format: 'auto',
    

diff --git tests/api-resources/beta/threads/threads.test.ts tests/api-resources/beta/threads/threads.test.ts
index aba266316..f26d6ec44 100644
--- tests/api-resources/beta/threads/threads.test.ts
+++ tests/api-resources/beta/threads/threads.test.ts
@@ -37,15 +37,17 @@ describe('resource threads', () => {
content: 'string',
role: 'user',
attachments: [{ file_id: 'file_id', tools: [{ type: 'code_interpreter' }] }],

  •          metadata: {},
    
  •          metadata: { foo: 'string' },
           },
         ],
    
  •      metadata: {},
    
  •      metadata: { foo: 'string' },
         tool_resources: {
           code_interpreter: { file_ids: ['string'] },
           file_search: {
             vector_store_ids: ['string'],
    
  •          vector_stores: [{ chunking_strategy: { type: 'auto' }, file_ids: ['string'], metadata: {} }],
    
  •          vector_stores: [
    
  •            { chunking_strategy: { type: 'auto' }, file_ids: ['string'], metadata: { foo: 'string' } },
    
  •          ],
           },
         },
       },
    

@@ -118,7 +120,7 @@ describe('resource threads', () => {
instructions: 'instructions',
max_completion_tokens: 256,
max_prompt_tokens: 256,

  •  metadata: {},
    
  •  metadata: { foo: 'string' },
     model: 'gpt-4o',
     parallel_tool_calls: true,
     response_format: 'auto',
    

@@ -130,15 +132,17 @@ describe('resource threads', () => {
content: 'string',
role: 'user',
attachments: [{ file_id: 'file_id', tools: [{ type: 'code_interpreter' }] }],

  •        metadata: {},
    
  •        metadata: { foo: 'string' },
         },
       ],
    
  •    metadata: {},
    
  •    metadata: { foo: 'string' },
       tool_resources: {
         code_interpreter: { file_ids: ['string'] },
         file_search: {
           vector_store_ids: ['string'],
    
  •        vector_stores: [{ chunking_strategy: { type: 'auto' }, file_ids: ['string'], metadata: {} }],
    
  •        vector_stores: [
    
  •          { chunking_strategy: { type: 'auto' }, file_ids: ['string'], metadata: { foo: 'string' } },
    
  •        ],
         },
       },
     },
    

diff --git tests/api-resources/chat/completions.test.ts tests/api-resources/chat/completions.test.ts
index dfc09f69b..8f1bc7d4c 100644
--- tests/api-resources/chat/completions.test.ts
+++ tests/api-resources/chat/completions.test.ts
@@ -43,7 +43,7 @@ describe('resource completions', () => {
presence_penalty: -2,
reasoning_effort: 'low',
response_format: { type: 'text' },

  •  seed: -9007199254740991,
    
  •  seed: 0,
     service_tier: 'auto',
     stop: 'string',
     store: true,
    

diff --git tests/api-resources/completions.test.ts tests/api-resources/completions.test.ts
index 82322dc3a..c98501a87 100644
--- tests/api-resources/completions.test.ts
+++ tests/api-resources/completions.test.ts
@@ -32,7 +32,7 @@ describe('resource completions', () => {
max_tokens: 16,
n: 1,
presence_penalty: -2,

  •  seed: -9007199254740991,
    
  •  seed: 0,
     stop: '\n',
     stream: false,
     stream_options: { include_usage: true },
    

diff --git tests/lib/azure.test.ts tests/lib/azure.test.ts
index 064a0098c..430efbe57 100644
--- tests/lib/azure.test.ts
+++ tests/lib/azure.test.ts
@@ -51,6 +51,18 @@ describe('instantiate azure client', () => {
});
expect(req.headers as Headers).not.toHaveProperty('x-my-default-header');
});
+

  • test('includes retry count', () => {
  •  const { req } = client.buildRequest(
    
  •    {
    
  •      path: '/foo',
    
  •      method: 'post',
    
  •      headers: { 'X-My-Default-Header': null },
    
  •    },
    
  •    { retryCount: 1 },
    
  •  );
    
  •  expect((req.headers as Headers)['x-stainless-retry-count']).toEqual('1');
    
  • });
    });

describe('defaultQuery', () => {
@@ -483,21 +495,23 @@ describe('azure request building', () => {
);
});

  •  test('Audio translations is not handled', async () => {
    
  •  test('handles audio translations', async () => {
       const { url } = (await client.audio.translations.create({
         model: deployment,
         file: { url: 'https://example.com', blob: () => 0 as any },
       })) as any;
    
  •    expect(url).toStrictEqual(`https://example.com/openai/audio/translations?api-version=${apiVersion}`);
    
  •    expect(url).toStrictEqual(
    
  •      `https://example.com/openai/deployments/${deployment}/audio/translations?api-version=${apiVersion}`,
    
  •    );
     });
    
  •  test('Audio transcriptions is not handled', async () => {
    
  •  test('handles audio transcriptions', async () => {
       const { url } = (await client.audio.transcriptions.create({
         model: deployment,
         file: { url: 'https://example.com', blob: () => 0 as any },
       })) as any;
       expect(url).toStrictEqual(
    
  •      `https://example.com/openai/audio/transcriptions?api-version=${apiVersion}`,
    
  •      `https://example.com/openai/deployments/${deployment}/audio/transcriptions?api-version=${apiVersion}`,
       );
     });
    

</details>

### Description
This pull request (PR) updates the OpenAI Node.js SDK to version 4.83.0. The PR includes various improvements, bug fixes, and new features, especially aimed at enhancing Azure OpenAI support, real-time API capabilities, and metadata handling. The primary motivation for this change is to extend the functionalities and maintain the SDK.

### Possible Issues
1. **Backward Compatibility**: Changes in Azure-specific functions and additional metadata handling might break compatibility with applications relying on the previous implementation.
2. **Complexity in Real-Time WebSocket Handling**: The new Azure-specific WebSocket handling introduces increased complexity that may require thorough testing.

### Security Hotspots
- **Hardcoded Secrets Exposure**: Hardcoded keys should be avoided. Ensure that no hardcoded API keys or tokens exist, especially during Azure WebSocket connections (`openai-insecure-api-key`).
- **Token Management**: Ensure that the token generation and management for Azure credentials are secure and that tokens are never exposed in client-side code.

<details>
<summary><i>Changes</i></summary>

### Changes
- **Version Update**:
  - `.release-please-manifest.json`
  - `package.json`
  - `jsr.json`
  - `src/version.ts`

- **OpenAPI Spec URL Update**:
  - `.stats.yml`

- **Changelog Update**:
  - `CHANGELOG.md`

- **Readme and Documentation Updates**:
  - `README.md`
  - `api.md`
  - `helpers.md`

- **Code Changes**:
  - Added metadata handling (`src/resources/shared.ts`)
  - New real-time WebSocket implementation for Azure (`src/beta/realtime/websocket.ts`, `src/beta/realtime/ws.ts`)
  - Fixed audio model parameters and types (`src/resources/audio/speech.ts`, `src/resources/audio/transcriptions.ts`)
  - Adjustments in core API client for timeout and retry headers (`src/core.ts`)
  - Enhanced Azure handling logic (`src/index.ts`, `src/core.ts`)
  - Addition of new example scripts (`examples/azure/realtime/websocket.ts`, `examples/azure/realtime/ws.ts`)

- **Test Updates**:
  - Various test files (`tests/api-resources/*`, `tests/lib/azure.test.ts`) updated to support metadata handling, model updates, and new features.

```mermaid
sequenceDiagram
    autonumber
    participant Dev as Developer
    participant Client as AzureOpenAI Client
    participant OpenAIWebSocket as OpenAIRealtimeWebSocket
    participant Server as Azure Server

    Dev ->>+ Client: Initialize AzureOpenAI Client
    Client ->>+ OpenAIWebSocket: Create Azure WebSocket Connection
    OpenAIWebSocket ->> Server: Establish Connection (WebSocket)
    Server -->> OpenAIWebSocket: Connection Established
    OpenAIWebSocket ->> OpenAIWebSocket: Handle Connection Open
    OpenAIWebSocket ->>+ OpenAIWebSocket: Send Session Update (Headers incl. Tokens)
    OpenAIWebSocket ->>+ Server: Send Conversation Item Create
    OpenAIWebSocket->> Server: Wait for Response
    Server -->> OpenAIWebSocket: Response Text Delta
    OpenAIWebSocket->> Dev: Stream Response Text
    Server -->> OpenAIWebSocket: Response Done
    OpenAIWebSocket ->> Dev: Stream Done
    OpenAIWebSocket->> Server: Close Connection
    Server -->> OpenAIWebSocket: Connection Closed

Copy link

bedrock debug - [puLL-Merge] - openai/[email protected]

Diff
diff --git .release-please-manifest.json .release-please-manifest.json
index b1ab5c7b9..6eb0f130e 100644
--- .release-please-manifest.json
+++ .release-please-manifest.json
@@ -1,3 +1,3 @@
 {
-  ".": "4.79.4"
+  ".": "4.83.0"
 }
diff --git .stats.yml .stats.yml
index 9600edae3..df7877dfd 100644
--- .stats.yml
+++ .stats.yml
@@ -1,2 +1,2 @@
 configured_endpoints: 69
-openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-b5b0e2c794b012919701c3fd43286af10fa25d33ceb8a881bec2636028f446e0.yml
+openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-fc5dbc19505b0035f9e7f88868619f4fb519b048bde011f6154f3132d4be71fb.yml
diff --git CHANGELOG.md CHANGELOG.md
index 4254a9b8f..f61def5e4 100644
--- CHANGELOG.md
+++ CHANGELOG.md
@@ -1,5 +1,64 @@
 # Changelog
 
+## 4.83.0 (2025-02-05)
+
+Full Changelog: [v4.82.0...v4.83.0](https://github.com/openai/openai-node/compare/v4.82.0...v4.83.0)
+
+### Features
+
+* **client:** send `X-Stainless-Timeout` header ([#1299](https://github.com/openai/openai-node/issues/1299)) ([ddfc686](https://github.com/openai/openai-node/commit/ddfc686f43a3420c3adf8dec2e82b4d10a121eb8))
+
+
+### Bug Fixes
+
+* **api/types:** correct audio duration & role types ([#1300](https://github.com/openai/openai-node/issues/1300)) ([a955ac2](https://github.com/openai/openai-node/commit/a955ac2bf5bee663d530d0c82b0005bf3ce6fc47))
+* **azure/audio:** use model param for deployments ([#1297](https://github.com/openai/openai-node/issues/1297)) ([85de382](https://github.com/openai/openai-node/commit/85de382db17cbe5f112650e79d0fc1cc841efbb2))
+
+## 4.82.0 (2025-01-31)
+
+Full Changelog: [v4.81.0...v4.82.0](https://github.com/openai/openai-node/compare/v4.81.0...v4.82.0)
+
+### Features
+
+* **api:** add o3-mini ([#1295](https://github.com/openai/openai-node/issues/1295)) ([378e2f7](https://github.com/openai/openai-node/commit/378e2f7af62c570adb4c7644a4d49576b698de41))
+
+
+### Bug Fixes
+
+* **examples/realtime:** remove duplicate `session.update` call ([#1293](https://github.com/openai/openai-node/issues/1293)) ([ad800b4](https://github.com/openai/openai-node/commit/ad800b4f9410c6838994c24a3386ea708717f72b))
+* **types:** correct metadata type + other fixes ([378e2f7](https://github.com/openai/openai-node/commit/378e2f7af62c570adb4c7644a4d49576b698de41))
+
+## 4.81.0 (2025-01-29)
+
+Full Changelog: [v4.80.1...v4.81.0](https://github.com/openai/openai-node/compare/v4.80.1...v4.81.0)
+
+### Features
+
+* **azure:** Realtime API support ([#1287](https://github.com/openai/openai-node/issues/1287)) ([fe090c0](https://github.com/openai/openai-node/commit/fe090c0a57570217eb0b431e2cce40bf61de2b75))
+
+## 4.80.1 (2025-01-24)
+
+Full Changelog: [v4.80.0...v4.80.1](https://github.com/openai/openai-node/compare/v4.80.0...v4.80.1)
+
+### Bug Fixes
+
+* **azure:** include retry count header ([3e0ba40](https://github.com/openai/openai-node/commit/3e0ba409e57ce276fb1f95cd11c801e4ccaad572))
+
+
+### Documentation
+
+* fix typo, "zodFunctionTool" -&gt; "zodFunction" ([#1128](https://github.com/openai/openai-node/issues/1128)) ([b7ab6bb](https://github.com/openai/openai-node/commit/b7ab6bb304973ade94830f37eb646e800226d5ef))
+* **helpers:** fix type annotation ([fc019df](https://github.com/openai/openai-node/commit/fc019df1d9cc276e8f8e689742853a09aa94991a))
+* **readme:** fix realtime errors docs link ([#1286](https://github.com/openai/openai-node/issues/1286)) ([d1d50c8](https://github.com/openai/openai-node/commit/d1d50c897c18cefea964e8057fe1acfd766ae2bf))
+
+## 4.80.0 (2025-01-22)
+
+Full Changelog: [v4.79.4...v4.80.0](https://github.com/openai/openai-node/compare/v4.79.4...v4.80.0)
+
+### Features
+
+* **api:** update enum values, comments, and examples ([#1280](https://github.com/openai/openai-node/issues/1280)) ([d38f2c2](https://github.com/openai/openai-node/commit/d38f2c2648b6990f217c3c7d83ca31f3739641d3))
+
 ## 4.79.4 (2025-01-21)
 
 Full Changelog: [v4.79.3...v4.79.4](https://github.com/openai/openai-node/compare/v4.79.3...v4.79.4)
diff --git README.md README.md
index 3bd386e99..a1f4bf760 100644
--- README.md
+++ README.md
@@ -157,7 +157,7 @@ A full example can be found [here](https://github.com/openai/openai-node/blob/ma
 
 ### Realtime error handling
 
-When an error is encountered, either on the client side or returned from the server through the [`error` event](https://platform.openai.com/docs/guides/realtime/realtime-api-beta#handling-errors), the `error` event listener will be fired. However, if you haven't registered an `error` event listener then an `unhandled Promise rejection` error will be thrown.
+When an error is encountered, either on the client side or returned from the server through the [`error` event](https://platform.openai.com/docs/guides/realtime-model-capabilities#error-handling), the `error` event listener will be fired. However, if you haven't registered an `error` event listener then an `unhandled Promise rejection` error will be thrown.
 
 It is **highly recommended** that you register an `error` event listener and handle errors approriately as typically the underlying connection is still usable.
 
@@ -499,7 +499,7 @@ const credential = new DefaultAzureCredential();
 const scope = 'https://cognitiveservices.azure.com/.default';
 const azureADTokenProvider = getBearerTokenProvider(credential, scope);
 
-const openai = new AzureOpenAI({ azureADTokenProvider });
+const openai = new AzureOpenAI({ azureADTokenProvider, apiVersion: "<The API version, e.g. 2024-10-01-preview>" });
 
 const result = await openai.chat.completions.create({
   model: 'gpt-4o',
@@ -509,6 +509,26 @@ const result = await openai.chat.completions.create({
 console.log(result.choices[0]!.message?.content);
 \`\`\`
 
+### Realtime API
+This SDK provides real-time streaming capabilities for Azure OpenAI through the `OpenAIRealtimeWS` and `OpenAIRealtimeWebSocket` clients described previously.
+
+To utilize the real-time features, begin by creating a fully configured `AzureOpenAI` client and passing it into either `OpenAIRealtimeWS.azure` or `OpenAIRealtimeWebSocket.azure`. For example:
+
+```ts
+const cred = new DefaultAzureCredential();
+const scope = 'https://cognitiveservices.azure.com/.default';
+const deploymentName = 'gpt-4o-realtime-preview-1001';
+const azureADTokenProvider = getBearerTokenProvider(cred, scope);
+const client = new AzureOpenAI({
+  azureADTokenProvider,
+  apiVersion: '2024-10-01-preview',
+  deployment: deploymentName,
+});
+const rt = await OpenAIRealtimeWS.azure(client);
+```
+
+Once the instance has been created, you can then begin sending requests and receiving streaming responses in real time.
+
 ### Retries
 
 Certain errors will be automatically retried 2 times by default, with a short exponential backoff.
diff --git api.md api.md
index 33ab95ef6..01854a8e0 100644
--- api.md
+++ api.md
@@ -5,6 +5,7 @@ Types:
 - <code><a href="./src/resources/shared.ts">ErrorObject</a></code>
 - <code><a href="./src/resources/shared.ts">FunctionDefinition</a></code>
 - <code><a href="./src/resources/shared.ts">FunctionParameters</a></code>
+- <code><a href="./src/resources/shared.ts">Metadata</a></code>
 - <code><a href="./src/resources/shared.ts">ResponseFormatJSONObject</a></code>
 - <code><a href="./src/resources/shared.ts">ResponseFormatJSONSchema</a></code>
 - <code><a href="./src/resources/shared.ts">ResponseFormatText</a></code>
@@ -228,6 +229,7 @@ Types:
 - <code><a href="./src/resources/beta/realtime/realtime.ts">ConversationItemInputAudioTranscriptionFailedEvent</a></code>
 - <code><a href="./src/resources/beta/realtime/realtime.ts">ConversationItemTruncateEvent</a></code>
 - <code><a href="./src/resources/beta/realtime/realtime.ts">ConversationItemTruncatedEvent</a></code>
+- <code><a href="./src/resources/beta/realtime/realtime.ts">ConversationItemWithReference</a></code>
 - <code><a href="./src/resources/beta/realtime/realtime.ts">ErrorEvent</a></code>
 - <code><a href="./src/resources/beta/realtime/realtime.ts">InputAudioBufferAppendEvent</a></code>
 - <code><a href="./src/resources/beta/realtime/realtime.ts">InputAudioBufferClearEvent</a></code>
diff --git examples/azure.ts examples/azure/chat.ts
similarity index 91%
rename from examples/azure.ts
rename to examples/azure/chat.ts
index 5fe1718fa..46df820f8 100755
--- examples/azure.ts
+++ examples/azure/chat.ts
@@ -2,6 +2,7 @@
 
 import { AzureOpenAI } from 'openai';
 import { getBearerTokenProvider, DefaultAzureCredential } from '@azure/identity';
+import 'dotenv/config';
 
 // Corresponds to your Model deployment within your OpenAI resource, e.g. gpt-4-1106-preview
 // Navigate to the Azure OpenAI Studio to deploy a model.
@@ -13,7 +14,7 @@ const azureADTokenProvider = getBearerTokenProvider(credential, scope);
 
 // Make sure to set AZURE_OPENAI_ENDPOINT with the endpoint of your Azure resource.
 // You can find it in the Azure Portal.
-const openai = new AzureOpenAI({ azureADTokenProvider });
+const openai = new AzureOpenAI({ azureADTokenProvider, apiVersion: '2024-10-01-preview' });
 
 async function main() {
   console.log('Non-streaming:');
diff --git a/examples/azure/realtime/websocket.ts b/examples/azure/realtime/websocket.ts
new file mode 100644
index 000000000..bec74e654
--- /dev/null
+++ examples/azure/realtime/websocket.ts
@@ -0,0 +1,60 @@
+import { OpenAIRealtimeWebSocket } from 'openai/beta/realtime/websocket';
+import { AzureOpenAI } from 'openai';
+import { DefaultAzureCredential, getBearerTokenProvider } from '@azure/identity';
+import 'dotenv/config';
+
+async function main() {
+  const cred = new DefaultAzureCredential();
+  const scope = 'https://cognitiveservices.azure.com/.default';
+  const deploymentName = 'gpt-4o-realtime-preview-1001';
+  const azureADTokenProvider = getBearerTokenProvider(cred, scope);
+  const client = new AzureOpenAI({
+    azureADTokenProvider,
+    apiVersion: '2024-10-01-preview',
+    deployment: deploymentName,
+  });
+  const rt = await OpenAIRealtimeWebSocket.azure(client);
+
+  // access the underlying `ws.WebSocket` instance
+  rt.socket.addEventListener('open', () => {
+    console.log('Connection opened!');
+    rt.send({
+      type: 'session.update',
+      session: {
+        modalities: ['text'],
+        model: 'gpt-4o-realtime-preview',
+      },
+    });
+
+    rt.send({
+      type: 'conversation.item.create',
+      item: {
+        type: 'message',
+        role: 'user',
+        content: [{ type: 'input_text', text: 'Say a couple paragraphs!' }],
+      },
+    });
+
+    rt.send({ type: 'response.create' });
+  });
+
+  rt.on('error', (err) => {
+    // in a real world scenario this should be logged somewhere as you
+    // likely want to continue procesing events regardless of any errors
+    throw err;
+  });
+
+  rt.on('session.created', (event) => {
+    console.log('session created!', event.session);
+    console.log();
+  });
+
+  rt.on('response.text.delta', (event) => process.stdout.write(event.delta));
+  rt.on('response.text.done', () => console.log());
+
+  rt.on('response.done', () => rt.close());
+
+  rt.socket.addEventListener('close', () => console.log('\nConnection closed!'));
+}
+
+main();
diff --git a/examples/azure/realtime/ws.ts b/examples/azure/realtime/ws.ts
new file mode 100644
index 000000000..6ab7b742a
--- /dev/null
+++ examples/azure/realtime/ws.ts
@@ -0,0 +1,60 @@
+import { DefaultAzureCredential, getBearerTokenProvider } from '@azure/identity';
+import { OpenAIRealtimeWS } from 'openai/beta/realtime/ws';
+import { AzureOpenAI } from 'openai';
+import 'dotenv/config';
+
+async function main() {
+  const cred = new DefaultAzureCredential();
+  const scope = 'https://cognitiveservices.azure.com/.default';
+  const deploymentName = 'gpt-4o-realtime-preview-1001';
+  const azureADTokenProvider = getBearerTokenProvider(cred, scope);
+  const client = new AzureOpenAI({
+    azureADTokenProvider,
+    apiVersion: '2024-10-01-preview',
+    deployment: deploymentName,
+  });
+  const rt = await OpenAIRealtimeWS.azure(client);
+
+  // access the underlying `ws.WebSocket` instance
+  rt.socket.on('open', () => {
+    console.log('Connection opened!');
+    rt.send({
+      type: 'session.update',
+      session: {
+        modalities: ['text'],
+        model: 'gpt-4o-realtime-preview',
+      },
+    });
+
+    rt.send({
+      type: 'conversation.item.create',
+      item: {
+        type: 'message',
+        role: 'user',
+        content: [{ type: 'input_text', text: 'Say a couple paragraphs!' }],
+      },
+    });
+
+    rt.send({ type: 'response.create' });
+  });
+
+  rt.on('error', (err) => {
+    // in a real world scenario this should be logged somewhere as you
+    // likely want to continue procesing events regardless of any errors
+    throw err;
+  });
+
+  rt.on('session.created', (event) => {
+    console.log('session created!', event.session);
+    console.log();
+  });
+
+  rt.on('response.text.delta', (event) => process.stdout.write(event.delta));
+  rt.on('response.text.done', () => console.log());
+
+  rt.on('response.done', () => rt.close());
+
+  rt.socket.on('close', () => console.log('\nConnection closed!'));
+}
+
+main();
diff --git examples/package.json examples/package.json
index b8c34ac45..70ec2c523 100644
--- examples/package.json
+++ examples/package.json
@@ -7,6 +7,7 @@
   "private": true,
   "dependencies": {
     "@azure/identity": "^4.2.0",
+    "dotenv": "^16.4.7",
     "express": "^4.18.2",
     "next": "^14.1.1",
     "openai": "file:..",
diff --git examples/realtime/ws.ts examples/realtime/ws.ts
index 4bbe85e5d..08c6fbcb6 100644
--- examples/realtime/ws.ts
+++ examples/realtime/ws.ts
@@ -6,13 +6,6 @@ async function main() {
   // access the underlying `ws.WebSocket` instance
   rt.socket.on('open', () => {
     console.log('Connection opened!');
-    rt.send({
-      type: 'session.update',
-      session: {
-        modalities: ['foo'] as any,
-        model: 'gpt-4o-realtime-preview',
-      },
-    });
     rt.send({
       type: 'session.update',
       session: {
diff --git helpers.md helpers.md
index abf980c82..16bc1f277 100644
--- helpers.md
+++ helpers.md
@@ -49,7 +49,7 @@ if (message?.parsed) {
 
 The `.parse()` method will also automatically parse `function` tool calls if:
 
-- You use the `zodFunctionTool()` helper method
+- You use the `zodFunction()` helper method
 - You mark your tool schema with `"strict": True`
 
 For example:
@@ -226,7 +226,7 @@ on in the documentation page [Message](https://platform.openai.com/docs/api-refe
 
 ```ts
 .on('textCreated', (content: Text) => ...)
-.on('textDelta', (delta: RunStepDelta, snapshot: Text) => ...)
+.on('textDelta', (delta: TextDelta, snapshot: Text) => ...)
 .on('textDone', (content: Text, snapshot: Message) => ...)

diff --git jsr.json jsr.json
index e6d772116..6fa05e624 100644
--- jsr.json
+++ jsr.json
@@ -1,6 +1,6 @@
{
"name": "@openai/openai",

  • "version": "4.79.4",
  • "version": "4.83.0",
    "exports": {
    ".": "./index.ts",
    "./helpers/zod": "./helpers/zod.ts",
    diff --git package.json package.json
    index d7a5555e5..bd507e9f8 100644
    --- package.json
    +++ package.json
    @@ -1,6 +1,6 @@
    {
    "name": "openai",
  • "version": "4.79.4",
  • "version": "4.83.0",
    "description": "The official TypeScript library for the OpenAI API",
    "author": "OpenAI [email protected]",
    "types": "dist/index.d.ts",
    diff --git src/beta/realtime/internal-base.ts src/beta/realtime/internal-base.ts
    index 391d69911..b704812ee 100644
    --- src/beta/realtime/internal-base.ts
    +++ src/beta/realtime/internal-base.ts
    @@ -1,6 +1,7 @@
    import { RealtimeClientEvent, RealtimeServerEvent, ErrorEvent } from '../../resources/beta/realtime/realtime';
    import { EventEmitter } from '../../lib/EventEmitter';
    import { OpenAIError } from '../../error';
    +import OpenAI, { AzureOpenAI } from '../../index';

export class OpenAIRealtimeError extends OpenAIError {
/**
@@ -73,11 +74,20 @@ export abstract class OpenAIRealtimeEmitter extends EventEmitter
}
}

-export function buildRealtimeURL(props: { baseURL: string; model: string }): URL {

  • const path = '/realtime';
    +export function isAzure(client: Pick<OpenAI, 'apiKey' | 'baseURL'>): client is AzureOpenAI {
  • return client instanceof AzureOpenAI;
    +}
  • const url = new URL(props.baseURL + (props.baseURL.endsWith('/') ? path.slice(1) : path));
    +export function buildRealtimeURL(client: Pick<OpenAI, 'apiKey' | 'baseURL'>, model: string): URL {
  • const path = '/realtime';
  • const baseURL = client.baseURL;
  • const url = new URL(baseURL + (baseURL.endsWith('/') ? path.slice(1) : path));
    url.protocol = 'wss';
  • url.searchParams.set('model', props.model);
  • if (isAzure(client)) {
  • url.searchParams.set('api-version', client.apiVersion);
  • url.searchParams.set('deployment', model);
  • } else {
  • url.searchParams.set('model', model);
  • }
    return url;
    }
    diff --git src/beta/realtime/websocket.ts src/beta/realtime/websocket.ts
    index e0853779d..349cf5760 100644
    --- src/beta/realtime/websocket.ts
    +++ src/beta/realtime/websocket.ts
    @@ -1,8 +1,8 @@
    -import { OpenAI } from '../../index';
    +import { AzureOpenAI, OpenAI } from '../../index';
    import { OpenAIError } from '../../error';
    import * as Core from '../../core';
    import type { RealtimeClientEvent, RealtimeServerEvent } from '../../resources/beta/realtime/realtime';
    -import { OpenAIRealtimeEmitter, buildRealtimeURL } from './internal-base';
    +import { OpenAIRealtimeEmitter, buildRealtimeURL, isAzure } from './internal-base';

interface MessageEvent {
data: string;
@@ -26,6 +26,11 @@ export class OpenAIRealtimeWebSocket extends OpenAIRealtimeEmitter {
props: {
model: string;
dangerouslyAllowBrowser?: boolean;

  •  /**
    
  •   * Callback to mutate the URL, needed for Azure.
    
  •   * @internal
    
  •   */
    
  •  onURL?: (url: URL) => void;
    

    },
    client?: Pick<OpenAI, 'apiKey' | 'baseURL'>,
    ) {
    @@ -44,11 +49,13 @@ export class OpenAIRealtimeWebSocket extends OpenAIRealtimeEmitter {

    client ??= new OpenAI({ dangerouslyAllowBrowser });

  • this.url = buildRealtimeURL({ baseURL: client.baseURL, model: props.model });
  • this.url = buildRealtimeURL(client, props.model);
  • props.onURL?.(this.url);
  • // @ts-ignore
    this.socket = new WebSocket(this.url, [
    'realtime',
  •  `openai-insecure-api-key.${client.apiKey}`,
    
  •  ...(isAzure(client) ? [] : [`openai-insecure-api-key.${client.apiKey}`]),
     'openai-beta.realtime-v1',
    
    ]);

@@ -77,6 +84,45 @@ export class OpenAIRealtimeWebSocket extends OpenAIRealtimeEmitter {
this.socket.addEventListener('error', (event: any) => {
this._onError(null, event.message, null);
});
+

  • if (isAzure(client)) {
  •  if (this.url.searchParams.get('Authorization') !== null) {
    
  •    this.url.searchParams.set('Authorization', '<REDACTED>');
    
  •  } else {
    
  •    this.url.searchParams.set('api-key', '<REDACTED>');
    
  •  }
    
  • }
  • }
  • static async azure(
  • client: AzureOpenAI,
  • options: { deploymentName?: string; dangerouslyAllowBrowser?: boolean } = {},
  • ): Promise {
  • const token = await client._getAzureADToken();
  • function onURL(url: URL) {
  •  if (client.apiKey !== '<Missing Key>') {
    
  •    url.searchParams.set('api-key', client.apiKey);
    
  •  } else {
    
  •    if (token) {
    
  •      url.searchParams.set('Authorization', `Bearer ${token}`);
    
  •    } else {
    
  •      throw new Error('AzureOpenAI is not instantiated correctly. No API key or token provided.');
    
  •    }
    
  •  }
    
  • }
  • const deploymentName = options.deploymentName ?? client.deploymentName;
  • if (!deploymentName) {
  •  throw new Error('No deployment name provided');
    
  • }
  • const { dangerouslyAllowBrowser } = options;
  • return new OpenAIRealtimeWebSocket(
  •  {
    
  •    model: deploymentName,
    
  •    onURL,
    
  •    ...(dangerouslyAllowBrowser ? { dangerouslyAllowBrowser } : {}),
    
  •  },
    
  •  client,
    
  • );
    }

send(event: RealtimeClientEvent) {
diff --git src/beta/realtime/ws.ts src/beta/realtime/ws.ts
index 631a36cd2..51339089c 100644
--- src/beta/realtime/ws.ts
+++ src/beta/realtime/ws.ts
@@ -1,7 +1,7 @@
import * as WS from 'ws';
-import { OpenAI } from '../../index';
+import { AzureOpenAI, OpenAI } from '../../index';
import type { RealtimeClientEvent, RealtimeServerEvent } from '../../resources/beta/realtime/realtime';
-import { OpenAIRealtimeEmitter, buildRealtimeURL } from './internal-base';
+import { OpenAIRealtimeEmitter, buildRealtimeURL, isAzure } from './internal-base';

export class OpenAIRealtimeWS extends OpenAIRealtimeEmitter {
url: URL;
@@ -14,12 +14,12 @@ export class OpenAIRealtimeWS extends OpenAIRealtimeEmitter {
super();
client ??= new OpenAI();

  • this.url = buildRealtimeURL({ baseURL: client.baseURL, model: props.model });
  • this.url = buildRealtimeURL(client, props.model);
    this.socket = new WS.WebSocket(this.url, {
    ...props.options,
    headers: {
    ...props.options?.headers,
  •    Authorization: `Bearer ${client.apiKey}`,
    
  •    ...(isAzure(client) ? {} : { Authorization: `Bearer ${client.apiKey}` }),
       'OpenAI-Beta': 'realtime=v1',
     },
    

    });
    @@ -51,6 +51,20 @@ export class OpenAIRealtimeWS extends OpenAIRealtimeEmitter {
    });
    }

  • static async azure(

  • client: AzureOpenAI,

  • options: { deploymentName?: string; options?: WS.ClientOptions | undefined } = {},

  • ): Promise {

  • const deploymentName = options.deploymentName ?? client.deploymentName;

  • if (!deploymentName) {

  •  throw new Error('No deployment name provided');
    
  • }

  • return new OpenAIRealtimeWS(

  •  { model: deploymentName, options: { headers: await getAzureHeaders(client) } },
    
  •  client,
    
  • );

  • }

  • send(event: RealtimeClientEvent) {
    try {
    this.socket.send(JSON.stringify(event));
    @@ -67,3 +81,16 @@ export class OpenAIRealtimeWS extends OpenAIRealtimeEmitter {
    }
    }
    }

+async function getAzureHeaders(client: AzureOpenAI) {

  • if (client.apiKey !== '') {

  • return { 'api-key': client.apiKey };

  • } else {

  • const token = await client._getAzureADToken();

  • if (token) {

  •  return { Authorization: `Bearer ${token}` };
    
  • } else {

  •  throw new Error('AzureOpenAI is not instantiated correctly. No API key or token provided.');
    
  • }

  • }
    +}
    diff --git src/core.ts src/core.ts
    index 3d2d029a5..6578c0781 100644
    --- src/core.ts
    +++ src/core.ts
    @@ -315,6 +315,7 @@ export abstract class APIClient {
    options: FinalRequestOptions,
    { retryCount = 0 }: { retryCount?: number } = {},
    ): { req: RequestInit; url: string; timeout: number } {

  • options = { ...options };
    const { method, path, query, headers: headers = {} } = options;

    const body =
    @@ -327,9 +328,9 @@ export abstract class APIClient {

    const url = this.buildURL(path!, query);
    if ('timeout' in options) validatePositiveInteger('timeout', options.timeout);

  • const timeout = options.timeout ?? this.timeout;
  • options.timeout = options.timeout ?? this.timeout;
    const httpAgent = options.httpAgent ?? this.httpAgent ?? getDefaultAgent(url);
  • const minAgentTimeout = timeout + 1000;
  • const minAgentTimeout = options.timeout + 1000;
    if (
    typeof (httpAgent as any)?.options?.timeout === 'number' &&
    minAgentTimeout > ((httpAgent as any).options.timeout ?? 0)
    @@ -358,7 +359,7 @@ export abstract class APIClient {
    signal: options.signal ?? null,
    };
  • return { req, url, timeout };
  • return { req, url, timeout: options.timeout };
    }

private buildHeaders({
@@ -386,15 +387,22 @@ export abstract class APIClient {
delete reqHeaders['content-type'];
}

  • // Don't set the retry count header if it was already set or removed through default headers or by the
  • // caller. We check defaultHeaders and headers, which can contain nulls, instead of reqHeaders to
  • // account for the removal case.
  • // Don't set theses headers if they were already set or removed through default headers or by the caller.

  • // We check defaultHeaders and headers, which can contain nulls, instead of reqHeaders to account

  • // for the removal case.
    if (
    getHeader(defaultHeaders, 'x-stainless-retry-count') === undefined &&
    getHeader(headers, 'x-stainless-retry-count') === undefined
    ) {
    reqHeaders['x-stainless-retry-count'] = String(retryCount);
    }

  • if (

  •  getHeader(defaultHeaders, 'x-stainless-timeout') === undefined &&
    
  •  getHeader(headers, 'x-stainless-timeout') === undefined &&
    
  •  options.timeout
    
  • ) {

  •  reqHeaders['x-stainless-timeout'] = String(options.timeout);
    
  • }

    this.validateHeaders(reqHeaders, headers);

@@ -814,6 +822,7 @@ export type RequestOptions<
signal?: AbortSignal | undefined | null;
idempotencyKey?: string;

  • __metadata?: Record<string, unknown>;
    __binaryRequest?: boolean | undefined;
    __binaryResponse?: boolean | undefined;
    __streamClass?: typeof Stream;
    @@ -836,6 +845,7 @@ const requestOptionsKeys: KeysEnum = {
    signal: true,
    idempotencyKey: true,

  • __metadata: true,
    __binaryRequest: true,
    __binaryResponse: true,
    __streamClass: true,
    diff --git src/index.ts src/index.ts
    index cf6aa89e3..f4e940af8 100644
    --- src/index.ts
    +++ src/index.ts
    @@ -451,6 +451,7 @@ export declare namespace OpenAI {
    export type ErrorObject = API.ErrorObject;
    export type FunctionDefinition = API.FunctionDefinition;
    export type FunctionParameters = API.FunctionParameters;

  • export type Metadata = API.Metadata;
    export type ResponseFormatJSONObject = API.ResponseFormatJSONObject;
    export type ResponseFormatJSONSchema = API.ResponseFormatJSONSchema;
    export type ResponseFormatText = API.ResponseFormatText;
    @@ -491,7 +492,7 @@ export interface AzureClientOptions extends ClientOptions {
    /** API Client for interfacing with the Azure OpenAI API. */
    export class AzureOpenAI extends OpenAI {
    private _azureADTokenProvider: (() => Promise) | undefined;

  • private _deployment: string | undefined;
  • deploymentName: string | undefined;
    apiVersion: string = '';
    /**

    • API Client for interfacing with the Azure OpenAI API.
      @@ -574,10 +575,13 @@ export class AzureOpenAI extends OpenAI {

    this._azureADTokenProvider = azureADTokenProvider;
    this.apiVersion = apiVersion;

  • this._deployment = deployment;
  • this.deploymentName = deployment;
    }
  • override buildRequest(options: Core.FinalRequestOptions): {
  • override buildRequest(
  • options: Core.FinalRequestOptions,
  • props: { retryCount?: number } = {},
  • ): {
    req: RequestInit;
    url: string;
    timeout: number;
    @@ -586,15 +590,15 @@ export class AzureOpenAI extends OpenAI {
    if (!Core.isObj(options.body)) {
    throw new Error('Expected request body to be an object');
    }
  •  const model = this._deployment || options.body['model'];
    
  •  const model = this.deploymentName || options.body['model'] || options.__metadata?.['model'];
     if (model !== undefined && !this.baseURL.includes('/deployments')) {
       options.path = `/deployments/${model}${options.path}`;
     }
    
    }
  • return super.buildRequest(options);
  • return super.buildRequest(options, props);
    }
  • private async _getAzureADToken(): Promise<string | undefined> {
  • async _getAzureADToken(): Promise<string | undefined> {
    if (typeof this._azureADTokenProvider === 'function') {
    const token = await this._azureADTokenProvider();
    if (!token || typeof token !== 'string') {
    diff --git src/lib/ChatCompletionStream.ts src/lib/ChatCompletionStream.ts
    index a88f8a23b..6c846f70b 100644
    --- src/lib/ChatCompletionStream.ts
    +++ src/lib/ChatCompletionStream.ts
    @@ -12,6 +12,7 @@ import {
    type ChatCompletionCreateParams,
    type ChatCompletionCreateParamsStreaming,
    type ChatCompletionCreateParamsBase,
  • type ChatCompletionRole,
    } from '../resources/chat/completions';
    import {
    AbstractChatCompletionRunner,
    @@ -797,7 +798,7 @@ export namespace ChatCompletionSnapshot {
    /**
    * The role of the author of this message.
    */
  •  role?: 'system' | 'user' | 'assistant' | 'function' | 'tool';
    
  •  role?: ChatCompletionRole;
    

    }

    export namespace Message {
    diff --git src/resources/audio/speech.ts src/resources/audio/speech.ts
    index bd2ed9f65..35e82c4c1 100644
    --- src/resources/audio/speech.ts
    +++ src/resources/audio/speech.ts
    @@ -33,12 +33,12 @@ export interface SpeechCreateParams {
    model: (string & {}) | SpeechModel;

    /**

    • The voice to use when generating the audio. Supported voices are alloy,
    • echo, fable, onyx, nova, and shimmer. Previews of the voices are
    • available in the
    • The voice to use when generating the audio. Supported voices are alloy, ash,
    • coral, echo, fable, onyx, nova, sage and shimmer. Previews of the
  • voice: 'alloy' | 'echo' | 'fable' | 'onyx' | 'nova' | 'shimmer';
  • voice: 'alloy' | 'ash' | 'coral' | 'echo' | 'fable' | 'onyx' | 'nova' | 'sage' | 'shimmer';

    /**

    • The format to audio in. Supported formats are mp3, opus, aac, flac,
      diff --git src/resources/audio/transcriptions.ts src/resources/audio/transcriptions.ts
      index 0b6da4620..6fbe96b58 100644
      --- src/resources/audio/transcriptions.ts
      +++ src/resources/audio/transcriptions.ts
      @@ -25,7 +25,10 @@ export class Transcriptions extends APIResource {
      body: TranscriptionCreateParams,
      options?: Core.RequestOptions,
      ): Core.APIPromise<TranscriptionCreateResponse | string> {
  • return this._client.post('/audio/transcriptions', Core.multipartFormRequestOptions({ body, ...options }));
  • return this._client.post(
  •  '/audio/transcriptions',
    
  •  Core.multipartFormRequestOptions({ body, ...options, __metadata: { model: body.model } }),
    
  • );
    }
    }

@@ -103,7 +106,7 @@ export interface TranscriptionVerbose {
/**
* The duration of the input audio.
*/

  • duration: string;
  • duration: number;

    /**

    • The language of the input audio.
      @@ -166,8 +169,8 @@ export interface TranscriptionCreateParams<

    /**

    • The language of the input audio. Supplying the input language in
    • improve accuracy and latency.
    • format will improve accuracy and latency.
      */
      language?: string;

diff --git src/resources/audio/translations.ts src/resources/audio/translations.ts
index c6bf7c870..dac519ede 100644
--- src/resources/audio/translations.ts
+++ src/resources/audio/translations.ts
@@ -26,7 +26,10 @@ export class Translations extends APIResource {
body: TranslationCreateParams,
options?: Core.RequestOptions,
): Core.APIPromise<TranslationCreateResponse | string> {

  • return this._client.post('/audio/translations', Core.multipartFormRequestOptions({ body, ...options }));
  • return this._client.post(
  •  '/audio/translations',
    
  •  Core.multipartFormRequestOptions({ body, ...options, __metadata: { model: body.model } }),
    
  • );
    }
    }

@@ -38,7 +41,7 @@ export interface TranslationVerbose {
/**
* The duration of the input audio.
*/

  • duration: string;
  • duration: number;

    /**

    • The language of the output translation (always english).
      diff --git src/resources/batches.ts src/resources/batches.ts
      index ec5ca6331..aadda83a6 100644
      --- src/resources/batches.ts
      +++ src/resources/batches.ts
      @@ -4,6 +4,7 @@ import { APIResource } from '../resource';
      import { isRequestOptions } from '../core';
      import * as Core from '../core';
      import * as BatchesAPI from './batches';
      +import * as Shared from './shared';
      import { CursorPage, type CursorPageParams } from '../pagination';

export class Batches extends APIResource {
@@ -138,11 +139,13 @@ export interface Batch {

/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful

    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;

    /**

    • The ID of the file containing the outputs of successfully executed requests.
      @@ -237,9 +240,14 @@ export interface BatchCreateParams {
      input_file_id: string;

    /**

    • Optional custom metadata for the batch.
    • Set of 16 key-value pairs that can be attached to an object. This can be useful
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata?: Record<string, string> | null;
  • metadata?: Shared.Metadata | null;
    }

export interface BatchListParams extends CursorPageParams {}
diff --git src/resources/beta/assistants.ts src/resources/beta/assistants.ts
index 0e657b1d4..69a5db520 100644
--- src/resources/beta/assistants.ts
+++ src/resources/beta/assistants.ts
@@ -111,11 +111,13 @@ export interface Assistant {

/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful

    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata: unknown | null;
  • metadata: Shared.Metadata | null;

    /**

    • ID of the model to use. You can use the
      @@ -1118,11 +1120,13 @@ export interface AssistantCreateParams {

    /**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;

    /**

    • The name of the assistant. The maximum length is 256 characters.
      @@ -1242,12 +1246,14 @@ export namespace AssistantCreateParams {
      file_ids?: Array;

      /**

  •     * Set of 16 key-value pairs that can be attached to a vector store. This can be
    
  •     * useful for storing additional information about the vector store in a structured
    
  •     * format. Keys can be a maximum of 64 characters long and values can be a maxium
    
  •     * of 512 characters long.
    
  •     * Set of 16 key-value pairs that can be attached to an object. This can be useful
    
  •     * for storing additional information about the object in a structured format, and
    
  •     * querying for objects via API or the dashboard.
    
  •     *
    
  •     * Keys are strings with a maximum length of 64 characters. Values are strings with
    
  •     * a maximum length of 512 characters.
        */
    
  •    metadata?: unknown;
    
  •    metadata?: Shared.Metadata | null;
     }
    

    }
    }
    @@ -1267,11 +1273,13 @@ export interface AssistantUpdateParams {

    /**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;

    /**

    • ID of the model to use. You can use the
      diff --git src/resources/beta/realtime/realtime.ts src/resources/beta/realtime/realtime.ts
      index 5de06917a..e46dcdaaf 100644
      --- src/resources/beta/realtime/realtime.ts
      +++ src/resources/beta/realtime/realtime.ts
      @@ -2,6 +2,7 @@

import { APIResource } from '../../../resource';
import * as RealtimeAPI from './realtime';
+import * as Shared from '../../shared';
import * as SessionsAPI from './sessions';
import {
Session as SessionsAPISession,
@@ -173,9 +174,10 @@ export interface ConversationItemCreateEvent {

/**
* The ID of the preceding item after which the new item will be inserted. If not

    • set, the new item will be appended to the end of the conversation. If set, it
    • allows an item to be inserted mid-conversation. If the ID cannot be found, an
    • error will be returned and the item will not be added.
    • set, the new item will be appended to the end of the conversation. If set to
    • root, the new item will be added to the beginning of the conversation. If set
    • to an existing ID, it allows an item to be inserted mid-conversation. If the ID
    • cannot be found, an error will be returned and the item will not be added.
      */
      previous_item_id?: string;
      }
      @@ -437,6 +439,76 @@ export interface ConversationItemTruncatedEvent {
      type: 'conversation.item.truncated';
      }

+/**

    • The item to add to the conversation.
  • */
    +export interface ConversationItemWithReference {
  • /**
    • For an item of type (message | function_call | function_call_output) this
    • field allows the client to assign the unique ID of the item. It is not required
    • because the server will generate one if not provided.
    • For an item of type item_reference, this field is required and is a reference
    • to any item that has previously existed in the conversation.
  • */
  • id?: string;
  • /**
    • The arguments of the function call (for function_call items).
  • */
  • arguments?: string;
  • /**
    • The ID of the function call (for function_call and function_call_output
    • items). If passed on a function_call_output item, the server will check that a
    • function_call item with the same ID exists in the conversation history.
  • */
  • call_id?: string;
  • /**
    • The content of the message, applicable for message items.
      • Message items of role system support only input_text content
      • Message items of role user support input_text and input_audio content
      • Message items of role assistant support text content.
  • */
  • content?: Array;
  • /**
    • The name of the function being called (for function_call items).
  • */
  • name?: string;
  • /**
    • Identifier for the API object being returned - always realtime.item.
  • */
  • object?: 'realtime.item';
  • /**
    • The output of the function call (for function_call_output items).
  • */
  • output?: string;
  • /**
    • The role of the message sender (user, assistant, system), only applicable
    • for message items.
  • */
  • role?: 'user' | 'assistant' | 'system';
  • /**
    • The status of the item (completed, incomplete). These have no effect on the
    • conversation, but are accepted for consistency with the
    • conversation.item.created event.
  • */
  • status?: 'completed' | 'incomplete';
  • /**
    • The type of the item (message, function_call, function_call_output,
    • item_reference).
  • */
  • type?: 'message' | 'function_call' | 'function_call_output' | 'item_reference';
    +}

/**

  • Returned when an error occurs, which could be a client problem or a server
  • problem. Most errors are recoverable and the session will stay open, we
    @@ -740,9 +812,38 @@ export interface RealtimeResponse {
    id?: string;

/**

    • Developer-provided string key-value pairs associated with this response.
    • Which conversation the response is added to, determined by the conversation
    • field in the response.create event. If auto, the response will be added to
    • the default conversation and the value of conversation_id will be an id like
    • conv_1234. If none, the response will not be added to any conversation and
    • the value of conversation_id will be null. If responses are being triggered
    • by server VAD, the response will be added to the default conversation, thus the
    • conversation_id will be an id like conv_1234.
  • */
  • conversation_id?: string;
  • /**
    • Maximum number of output tokens for a single assistant response, inclusive of
    • tool calls, that was used in this response.
  • */
  • max_output_tokens?: number | 'inf';
  • /**
    • Set of 16 key-value pairs that can be attached to an object. This can be useful
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;

  • /**

    • The set of modalities the model used to respond. If there are multiple
    • modalities, the model will pick one, for example if modalities is
    • ["text", "audio"], the model could be responding in either text or audio.
  • */

  • modalities?: Array<'text' | 'audio'>;

    /**

    • The object type, must be realtime.response.
      @@ -754,6 +855,11 @@ export interface RealtimeResponse {
      */
      output?: Array;
  • /**

    • The format of output audio. Options are pcm16, g711_ulaw, or g711_alaw.
  • */

  • output_audio_format?: 'pcm16' | 'g711_ulaw' | 'g711_alaw';

  • /**

    • The final status of the response (completed, cancelled, failed, or
    • incomplete).
      @@ -765,6 +871,11 @@ export interface RealtimeResponse {
      */
      status_details?: RealtimeResponseStatus;
  • /**

    • Sampling temperature for the model, limited to [0.6, 1.2]. Defaults to 0.8.
  • */

  • temperature?: number;

  • /**

    • Usage statistics for the Response, this will correspond to billing. A Realtime
    • API session will maintain a conversation context and append new Items to the
      @@ -772,6 +883,12 @@ export interface RealtimeResponse {
    • become the input for later turns.
      */
      usage?: RealtimeResponseUsage;
  • /**

    • The voice the model used to respond. Current voice options are alloy, ash,
    • ballad, coral, echo sage, shimmer and verse.
  • */

  • voice?: 'alloy' | 'ash' | 'ballad' | 'coral' | 'echo' | 'sage' | 'shimmer' | 'verse';
    }

/**
@@ -1289,11 +1406,12 @@ export namespace ResponseCreateEvent {
conversation?: (string & {}) | 'auto' | 'none';

 /**
  • * Input items to include in the prompt for the model. Creates a new context for
    
  • * this response, without including the default conversation. Can include
    
  • * references to items from the default conversation.
    
  • * Input items to include in the prompt for the model. Using this field creates a
    
  • * new context for this Response instead of using the default conversation. An
    
  • * empty array `[]` will clear the context for this Response. Note that this can
    
  • * include references to items from the default conversation.
    */
    
  • input?: Array<RealtimeAPI.ConversationItem>;
  • input?: Array<RealtimeAPI.ConversationItemWithReference>;

    /**

    • The default system instructions (i.e. system message) prepended to model calls.
      @@ -1319,11 +1437,13 @@ export namespace ResponseCreateEvent {

    /**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
  • * for storing additional information about the object in a structured format. Keys
    
  • * can be a maximum of 64 characters long and values can be a maximum of 512
    
  • * characters long.
    
  • * for storing additional information about the object in a structured format, and
    
  • * querying for objects via API or the dashboard.
    
  • *
    
  • * Keys are strings with a maximum length of 64 characters. Values are strings with
    
  • * a maximum length of 512 characters.
    */
    
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;

    /**

    • The set of modalities the model can respond with. To disable audio, set this to
      @@ -1705,17 +1825,9 @@ export namespace SessionUpdateEvent {
      /
      export interface Session {
      /
      *
  • * The Realtime model used for this session.
    
  • */
    
  • model:
  •  | 'gpt-4o-realtime-preview'
    
  •  | 'gpt-4o-realtime-preview-2024-10-01'
    
  •  | 'gpt-4o-realtime-preview-2024-12-17'
    
  •  | 'gpt-4o-mini-realtime-preview'
    
  •  | 'gpt-4o-mini-realtime-preview-2024-12-17';
    
  • /**
  • * The format of input audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`.
    
  • * The format of input audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`. For
    
  • * `pcm16`, input audio must be 16-bit PCM at a 24kHz sample rate, single channel
    
  • * (mono), and little-endian byte order.
    */
    
    input_audio_format?: 'pcm16' | 'g711_ulaw' | 'g711_alaw';

@@ -1723,8 +1835,11 @@ export namespace SessionUpdateEvent {
* Configuration for input audio transcription, defaults to off and can be set to
* null to turn off once on. Input audio transcription is not native to the
* model, since the model consumes audio directly. Transcription runs

  • * asynchronously through Whisper and should be treated as rough guidance rather
    
  • * than the representation understood by the model.
    
  • * asynchronously through
    
  • * [OpenAI Whisper transcription](https://platform.openai.com/docs/api-reference/audio/createTranscription)
    
  • * and should be treated as rough guidance rather than the representation
    
  • * understood by the model. The client can optionally set the language and prompt
    
  • * for transcription, these fields will be passed to the Whisper API.
    */
    
    input_audio_transcription?: Session.InputAudioTranscription;

@@ -1756,8 +1871,19 @@ export namespace SessionUpdateEvent {
*/
modalities?: Array<'text' | 'audio'>;

  • /**
  • * The Realtime model used for this session.
    
  • */
    
  • model?:
  •  | 'gpt-4o-realtime-preview'
    
  •  | 'gpt-4o-realtime-preview-2024-10-01'
    
  •  | 'gpt-4o-realtime-preview-2024-12-17'
    
  •  | 'gpt-4o-mini-realtime-preview'
    
  •  | 'gpt-4o-mini-realtime-preview-2024-12-17';
    
  • /**
    * The format of output audio. Options are pcm16, g711_ulaw, or g711_alaw.
  • * For `pcm16`, output audio is sampled at a rate of 24kHz.
    */
    
    output_audio_format?: 'pcm16' | 'g711_ulaw' | 'g711_alaw';

@@ -1797,15 +1923,33 @@ export namespace SessionUpdateEvent {
* Configuration for input audio transcription, defaults to off and can be set to
* null to turn off once on. Input audio transcription is not native to the
* model, since the model consumes audio directly. Transcription runs

  • * asynchronously through Whisper and should be treated as rough guidance rather
    
  • * than the representation understood by the model.
    
  • * asynchronously through
    
  • * [OpenAI Whisper transcription](https://platform.openai.com/docs/api-reference/audio/createTranscription)
    
  • * and should be treated as rough guidance rather than the representation
    
  • * understood by the model. The client can optionally set the language and prompt
    
  • * for transcription, these fields will be passed to the Whisper API.
    */
    

    export interface InputAudioTranscription {

  •  /**
    
  •   * The language of the input audio. Supplying the input language in
    
  •   * [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. `en`)
    
  •   * format will improve accuracy and latency.
    
  •   */
    
  •  language?: string;
    
  •  /**
      * The model to use for transcription, `whisper-1` is the only currently supported
      * model.
      */
     model?: string;
    
  •  /**
    
  •   * An optional text to guide the model's style or continue a previous audio
    
  •   * segment. The
    
  •   * [prompt](https://platform.openai.com/docs/guides/speech-to-text#prompting)
    
  •   * should match the audio language.
    
  •   */
    
  •  prompt?: string;
    

    }

    export interface Tool {
    diff --git src/resources/beta/realtime/sessions.ts src/resources/beta/realtime/sessions.ts
    index c1082d236..d2afa25b1 100644
    --- src/resources/beta/realtime/sessions.ts
    +++ src/resources/beta/realtime/sessions.ts
    @@ -32,7 +32,9 @@ export interface Session {
    id?: string;

    /**

    • The format of input audio. Options are pcm16, g711_ulaw, or g711_alaw.
    • The format of input audio. Options are pcm16, g711_ulaw, or g711_alaw. For
    • pcm16, input audio must be 16-bit PCM at a 24kHz sample rate, single channel
    • (mono), and little-endian byte order.
      */
      input_audio_format?: 'pcm16' | 'g711_ulaw' | 'g711_alaw';

@@ -86,6 +88,7 @@ export interface Session {

/**
* The format of output audio. Options are pcm16, g711_ulaw, or g711_alaw.

    • For pcm16, output audio is sampled at a rate of 24kHz.
      */
      output_audio_format?: 'pcm16' | 'g711_ulaw' | 'g711_alaw';

@@ -200,7 +203,7 @@ export interface SessionCreateResponse {
/**
* Ephemeral key returned by the API.
*/

  • client_secret?: SessionCreateResponse.ClientSecret;
  • client_secret: SessionCreateResponse.ClientSecret;

    /**

    • The format of input audio. Options are pcm16, g711_ulaw, or g711_alaw.
      @@ -289,14 +292,14 @@ export namespace SessionCreateResponse {
      • Timestamp for when the token expires. Currently, all tokens expire after one
      • minute.
        */
  • expires_at?: number;
  • expires_at: number;

    /**

    • Ephemeral key usable in client environments to authenticate connections to the
    • Realtime API. Use this in client-side environments rather than a standard API
    • token, which should only be used server-side.
      */
  • value?: string;
  • value: string;
    }

/**
@@ -372,17 +375,9 @@ export namespace SessionCreateResponse {

export interface SessionCreateParams {
/**

    • The Realtime model used for this session.
  • */
  • model:
  • | 'gpt-4o-realtime-preview'
  • | 'gpt-4o-realtime-preview-2024-10-01'
  • | 'gpt-4o-realtime-preview-2024-12-17'
  • | 'gpt-4o-mini-realtime-preview'
  • | 'gpt-4o-mini-realtime-preview-2024-12-17';
  • /**
    • The format of input audio. Options are pcm16, g711_ulaw, or g711_alaw.
    • The format of input audio. Options are pcm16, g711_ulaw, or g711_alaw. For
    • pcm16, input audio must be 16-bit PCM at a 24kHz sample rate, single channel
    • (mono), and little-endian byte order.
      */
      input_audio_format?: 'pcm16' | 'g711_ulaw' | 'g711_alaw';

@@ -390,8 +385,11 @@ export interface SessionCreateParams {
* Configuration for input audio transcription, defaults to off and can be set to
* null to turn off once on. Input audio transcription is not native to the
* model, since the model consumes audio directly. Transcription runs

    • asynchronously through Whisper and should be treated as rough guidance rather
    • than the representation understood by the model.
    • asynchronously through
    • and should be treated as rough guidance rather than the representation
    • understood by the model. The client can optionally set the language and prompt
    • for transcription, these fields will be passed to the Whisper API.
      */
      input_audio_transcription?: SessionCreateParams.InputAudioTranscription;

@@ -423,8 +421,19 @@ export interface SessionCreateParams {
*/
modalities?: Array<'text' | 'audio'>;

  • /**
    • The Realtime model used for this session.
  • */
  • model?:
  • | 'gpt-4o-realtime-preview'
  • | 'gpt-4o-realtime-preview-2024-10-01'
  • | 'gpt-4o-realtime-preview-2024-12-17'
  • | 'gpt-4o-mini-realtime-preview'
  • | 'gpt-4o-mini-realtime-preview-2024-12-17';
  • /**
    • The format of output audio. Options are pcm16, g711_ulaw, or g711_alaw.
    • For pcm16, output audio is sampled at a rate of 24kHz.
      */
      output_audio_format?: 'pcm16' | 'g711_ulaw' | 'g711_alaw';

@@ -464,15 +473,33 @@ export namespace SessionCreateParams {
* Configuration for input audio transcription, defaults to off and can be set to
* null to turn off once on. Input audio transcription is not native to the
* model, since the model consumes audio directly. Transcription runs

    • asynchronously through Whisper and should be treated as rough guidance rather
    • than the representation understood by the model.
    • asynchronously through
    • and should be treated as rough guidance rather than the representation
    • understood by the model. The client can optionally set the language and prompt
    • for transcription, these fields will be passed to the Whisper API.
      */
      export interface InputAudioTranscription {
  • /**
  • * The language of the input audio. Supplying the input language in
    
  • * [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. `en`)
    
  • * format will improve accuracy and latency.
    
  • */
    
  • language?: string;
  • /**
    * The model to use for transcription, whisper-1 is the only currently supported
    * model.
    */
    model?: string;
  • /**
  • * An optional text to guide the model's style or continue a previous audio
    
  • * segment. The
    
  • * [prompt](https://platform.openai.com/docs/guides/speech-to-text#prompting)
    
  • * should match the audio language.
    
  • */
    
  • prompt?: string;
    }

export interface Tool {
diff --git src/resources/beta/threads/messages.ts src/resources/beta/threads/messages.ts
index 8124f56cd..29fd2b29f 100644
--- src/resources/beta/threads/messages.ts
+++ src/resources/beta/threads/messages.ts
@@ -3,6 +3,7 @@
import { APIResource } from '../../../resource';
import { isRequestOptions } from '../../../core';
import * as Core from '../../../core';
+import * as Shared from '../../shared';
import * as AssistantsAPI from '../assistants';
import { CursorPage, type CursorPageParams } from '../../../pagination';

@@ -407,11 +408,13 @@ export interface Message {

/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful

    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata: unknown | null;
  • metadata: Shared.Metadata | null;

    /**

    • The object type, which is always thread.message.
      @@ -660,11 +663,13 @@ export interface MessageCreateParams {

    /**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;
    }

export namespace MessageCreateParams {
@@ -693,11 +698,13 @@ export namespace MessageCreateParams {
export interface MessageUpdateParams {
/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful

    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;
    }

export interface MessageListParams extends CursorPageParams {
diff --git src/resources/beta/threads/runs/runs.ts src/resources/beta/threads/runs/runs.ts
index 814ad3e89..84ba7b63c 100644
--- src/resources/beta/threads/runs/runs.ts
+++ src/resources/beta/threads/runs/runs.ts
@@ -8,6 +8,7 @@ import { AssistantStream, RunCreateParamsBaseStream } from '../../../../lib/Assi
import { sleep } from '../../../../core';
import { RunSubmitToolOutputsParamsStream } from '../../../../lib/AssistantStream';
import * as RunsAPI from './runs';
+import * as Shared from '../../../shared';
import * as AssistantsAPI from '../../assistants';
import * as ChatAPI from '../../../chat/chat';
import * as MessagesAPI from '../messages';
@@ -415,11 +416,13 @@ export interface Run {

/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful

    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata: unknown | null;
  • metadata: Shared.Metadata | null;

    /**

    • The model that the
      @@ -705,10 +708,12 @@ export interface RunCreateParamsBase {
      /**
    • Body param: Set of 16 key-value pairs that can be attached to an object. This
    • can be useful for storing additional information about the object in a
    • structured format. Keys can be a maximum of 64 characters long and values can be
    • a maxium of 512 characters long.
    • structured format, and querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;

    /**

    • Body param: The ID of the
      @@ -823,11 +828,13 @@ export namespace RunCreateParams {

    /**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
  • * for storing additional information about the object in a structured format. Keys
    
  • * can be a maximum of 64 characters long and values can be a maxium of 512
    
  • * characters long.
    
  • * for storing additional information about the object in a structured format, and
    
  • * querying for objects via API or the dashboard.
    
  • *
    
  • * Keys are strings with a maximum length of 64 characters. Values are strings with
    
  • * a maximum length of 512 characters.
    */
    
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;
    }

export namespace AdditionalMessage {
@@ -898,11 +905,13 @@ export interface RunCreateParamsStreaming extends RunCreateParamsBase {
export interface RunUpdateParams {
/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful

    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;
    }

export interface RunListParams extends CursorPageParams {
diff --git src/resources/beta/threads/runs/steps.ts src/resources/beta/threads/runs/steps.ts
index 6c6722b62..c491b4e83 100644
--- src/resources/beta/threads/runs/steps.ts
+++ src/resources/beta/threads/runs/steps.ts
@@ -4,6 +4,7 @@ import { APIResource } from '../../../../resource';
import { isRequestOptions } from '../../../../core';
import * as Core from '../../../../core';
import * as StepsAPI from './steps';
+import * as Shared from '../../../shared';
import { CursorPage, type CursorPageParams } from '../../../../pagination';

export class Steps extends APIResource {
@@ -515,11 +516,13 @@ export interface RunStep {

/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful

    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata: unknown | null;
  • metadata: Shared.Metadata | null;

    /**

    • The object type, which is always thread.run.step.
      diff --git src/resources/beta/threads/threads.ts src/resources/beta/threads/threads.ts
      index 453d8fa10..3f69c6e60 100644
      --- src/resources/beta/threads/threads.ts
      +++ src/resources/beta/threads/threads.ts
      @@ -250,11 +250,13 @@ export interface Thread {

    /**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata: unknown | null;
  • metadata: Shared.Metadata | null;

    /**

    • The object type, which is always thread.
      @@ -322,11 +324,13 @@ export interface ThreadCreateParams {

    /**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;

    /**

    • A set of resources that are made available to the assistant's tools in this
      @@ -361,11 +365,13 @@ export namespace ThreadCreateParams {

    /**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
  • * for storing additional information about the object in a structured format. Keys
    
  • * can be a maximum of 64 characters long and values can be a maxium of 512
    
  • * characters long.
    
  • * for storing additional information about the object in a structured format, and
    
  • * querying for objects via API or the dashboard.
    
  • *
    
  • * Keys are strings with a maximum length of 64 characters. Values are strings with
    
  • * a maximum length of 512 characters.
    */
    
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;
    }

export namespace Message {
@@ -447,12 +453,14 @@ export namespace ThreadCreateParams {
file_ids?: Array;

     /**
  •     * Set of 16 key-value pairs that can be attached to a vector, store. This can be
    
  •     * useful for storing additional information about the vector store in a structured
    
  •     * format. Keys can be a maximum of 64 characters long and values can be a maxium
    
  •     * of 512 characters long.
    
  •     * Set of 16 key-value pairs that can be attached to an object. This can be useful
    
  •     * for storing additional information about the object in a structured format, and
    
  •     * querying for objects via API or the dashboard.
    
  •     *
    
  •     * Keys are strings with a maximum length of 64 characters. Values are strings with
    
  •     * a maximum length of 512 characters.
        */
    
  •    metadata?: unknown;
    
  •    metadata?: Shared.Metadata | null;
     }
    
    }
    }
    @@ -461,11 +469,13 @@ export namespace ThreadCreateParams {
    export interface ThreadUpdateParams {
    /**
    • Set of 16 key-value pairs that can be attached to an object. This can be useful
    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;

    /**

    • A set of resources that are made available to the assistant's tools in this
      @@ -549,11 +559,13 @@ export interface ThreadCreateAndRunParamsBase {

    /**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;

    /**

    • The ID of the Model to
      @@ -609,7 +621,8 @@ export interface ThreadCreateAndRunParamsBase {
      temperature?: number | null;

    /**

    • If no thread is provided, an empty thread will be created.
    • Options to create a new thread. If no thread is provided when running a request,
    • an empty thread will be created.
      */
      thread?: ThreadCreateAndRunParams.Thread;

@@ -658,7 +671,8 @@ export interface ThreadCreateAndRunParamsBase {

export namespace ThreadCreateAndRunParams {
/**

    • If no thread is provided, an empty thread will be created.
    • Options to create a new thread. If no thread is provided when running a request,
    • an empty thread will be created.
      /
      export interface Thread {
      /
      *
      @@ -669,11 +683,13 @@ export namespace ThreadCreateAndRunParams {

    /**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
  • * for storing additional information about the object in a structured format. Keys
    
  • * can be a maximum of 64 characters long and values can be a maxium of 512
    
  • * characters long.
    
  • * for storing additional information about the object in a structured format, and
    
  • * querying for objects via API or the dashboard.
    
  • *
    
  • * Keys are strings with a maximum length of 64 characters. Values are strings with
    
  • * a maximum length of 512 characters.
    */
    
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;

    /**

    • A set of resources that are made available to the assistant's tools in this
      @@ -708,11 +724,13 @@ export namespace ThreadCreateAndRunParams {

    /**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
  •   * for storing additional information about the object in a structured format. Keys
    
  •   * can be a maximum of 64 characters long and values can be a maxium of 512
    
  •   * characters long.
    
  •   * for storing additional information about the object in a structured format, and
    
  •   * querying for objects via API or the dashboard.
    
  •   *
    
  •   * Keys are strings with a maximum length of 64 characters. Values are strings with
    
  •   * a maximum length of 512 characters.
      */
    
  •  metadata?: unknown | null;
    
  •  metadata?: Shared.Metadata | null;
    

    }

    export namespace Message {
    @@ -794,12 +812,14 @@ export namespace ThreadCreateAndRunParams {
    file_ids?: Array;

         /**
    
  •       * Set of 16 key-value pairs that can be attached to a vector store. This can be
    
  •       * useful for storing additional information about the vector store in a structured
    
  •       * format. Keys can be a maximum of 64 characters long and values can be a maxium
    
  •       * of 512 characters long.
    
  •       * Set of 16 key-value pairs that can be attached to an object. This can be useful
    
  •       * for storing additional information about the object in a structured format, and
    
  •       * querying for objects via API or the dashboard.
    
  •       *
    
  •       * Keys are strings with a maximum length of 64 characters. Values are strings with
    
  •       * a maximum length of 512 characters.
          */
    
  •      metadata?: unknown;
    
  •      metadata?: Shared.Metadata | null;
       }
     }
    

    }
    diff --git src/resources/beta/vector-stores/vector-stores.ts src/resources/beta/vector-stores/vector-stores.ts
    index cbff2d562..8438b79da 100644
    --- src/resources/beta/vector-stores/vector-stores.ts
    +++ src/resources/beta/vector-stores/vector-stores.ts
    @@ -3,6 +3,7 @@
    import { APIResource } from '../../../resource';
    import { isRequestOptions } from '../../../core';
    import * as Core from '../../../core';
    +import * as Shared from '../../shared';
    import * as FileBatchesAPI from './file-batches';
    import {
    FileBatchCreateParams,
    @@ -187,11 +188,13 @@ export interface VectorStore {

    /**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata: unknown | null;
  • metadata: Shared.Metadata | null;

    /**

    • The name of the vector store.
      @@ -300,11 +303,13 @@ export interface VectorStoreCreateParams {

    /**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;

    /**

    • The name of the vector store.
      @@ -338,11 +343,13 @@ export interface VectorStoreUpdateParams {

    /**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
    • for storing additional information about the object in a structured format. Keys
    • can be a maximum of 64 characters long and values can be a maxium of 512
    • characters long.
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata?: unknown | null;
  • metadata?: Shared.Metadata | null;

    /**

    • The name of the vector store.
      diff --git src/resources/chat/chat.ts src/resources/chat/chat.ts
      index 2230b19bd..d4a18929c 100644
      --- src/resources/chat/chat.ts
      +++ src/resources/chat/chat.ts
      @@ -46,6 +46,8 @@ export class Chat extends APIResource {
      }

export type ChatModel =

  • | 'o3-mini'

  • | 'o3-mini-2025-01-31'
    | 'o1'
    | 'o1-2024-12-17'
    | 'o1-preview'
    diff --git src/resources/chat/completions.ts src/resources/chat/completions.ts
    index 88c778036..55b008cf0 100644
    --- src/resources/chat/completions.ts
    +++ src/resources/chat/completions.ts
    @@ -76,8 +76,7 @@ export interface ChatCompletion {
    object: 'chat.completion';

    /**

    • The service tier used for processing the request. This field is only included if
    • the service_tier parameter is specified in the request.
    • The service tier used for processing the request.
      */
      service_tier?: 'scale' | 'default' | null;

@@ -300,8 +299,7 @@ export interface ChatCompletionChunk {
object: 'chat.completion.chunk';

/**

    • The service tier used for processing the request. This field is only included if
    • the service_tier parameter is specified in the request.
    • The service tier used for processing the request.
      */
      service_tier?: 'scale' | 'default' | null;

@@ -373,7 +371,7 @@ export namespace ChatCompletionChunk {
/**
* The role of the author of this message.
*/

  •  role?: 'system' | 'user' | 'assistant' | 'tool';
    
  •  role?: 'developer' | 'system' | 'user' | 'assistant' | 'tool';
    
     tool_calls?: Array<Delta.ToolCall>;
    
    }
    @@ -758,7 +756,7 @@ export type ChatCompletionReasoningEffort = 'low' | 'medium' | 'high';
    /**
    • The role of the author of a message
      */
      -export type ChatCompletionRole = 'system' | 'user' | 'assistant' | 'tool' | 'function';
      +export type ChatCompletionRole = 'developer' | 'system' | 'user' | 'assistant' | 'tool' | 'function';

/**

  • Options for streaming response. Only set this when you set stream: true.
    @@ -1014,10 +1012,14 @@ export interface ChatCompletionCreateParamsBase {
    max_tokens?: number | null;

/**

    • Developer-defined tags and values used for filtering completions in the
    • Set of 16 key-value pairs that can be attached to an object. This can be useful
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
      */
  • metadata?: Record<string, string> | null;
  • metadata?: Shared.Metadata | null;

    /**

    • Output types that you would like the model to generate for this request. Most
      @@ -1111,13 +1113,10 @@ export interface ChatCompletionCreateParamsBase {
    • utilize scale tier credits until they are exhausted.
      • If set to 'auto', and the Project is not Scale tier enabled, the request will
    • be processed using the default service tier with a lower uptime SLA and no
    • latency guarentee.
    • latency guarantee.
      • If set to 'default', the request will be processed using the default service
    • tier with a lower uptime SLA and no latency guarentee.
    • tier with a lower uptime SLA and no latency guarantee.
      • When not set, the default behavior is 'auto'.
    • When this parameter is set, the response body will include the service_tier
    • utilized.
      */
      service_tier?: 'auto' | 'default' | null;

diff --git src/resources/embeddings.ts src/resources/embeddings.ts
index 4b1644a68..d01ffc807 100644
--- src/resources/embeddings.ts
+++ src/resources/embeddings.ts
@@ -86,7 +86,8 @@ export interface EmbeddingCreateParams {
* text-embedding-ada-002), cannot be an empty string, and any array must be 2048
* dimensions or less.
* Example Python code

    • for counting tokens.
    • for counting tokens. Some models may also impose a limit on total number of
    • tokens summed across inputs.
      */
      input: string | Array | Array | Array<Array>;

diff --git src/resources/shared.ts src/resources/shared.ts
index f44fda8a7..3bb11582f 100644
--- src/resources/shared.ts
+++ src/resources/shared.ts
@@ -55,6 +55,16 @@ export interface FunctionDefinition {
*/
export type FunctionParameters = Record<string, unknown>;

+/**

    • Set of 16 key-value pairs that can be attached to an object. This can be useful
    • for storing additional information about the object in a structured format, and
    • querying for objects via API or the dashboard.
    • Keys are strings with a maximum length of 64 characters. Values are strings with
    • a maximum length of 512 characters.
  • */
    +export type Metadata = Record<string, string>;

export interface ResponseFormatJSONObject {
/**
* The type of response format being defined: json_object
diff --git src/resources/uploads/uploads.ts src/resources/uploads/uploads.ts
index 8491d0fe2..bfe752cd7 100644
--- src/resources/uploads/uploads.ts
+++ src/resources/uploads/uploads.ts
@@ -113,7 +113,7 @@ export interface Upload {
status: 'pending' | 'completed' | 'cancelled' | 'expired';

/**

    • The ready File object after the Upload is completed.
    • The File object represents a document that has been uploaded to OpenAI.
      */
      file?: FilesAPI.FileObject | null;
      }
      diff --git src/version.ts src/version.ts
      index e8b9601ed..13c764d7d 100644
      --- src/version.ts
      +++ src/version.ts
      @@ -1 +1 @@
      -export const VERSION = '4.79.4'; // x-release-please-version
      +export const VERSION = '4.83.0'; // x-release-please-version
      diff --git tests/api-resources/beta/assistants.test.ts tests/api-resources/beta/assistants.test.ts
      index a64465c77..88a10ba8f 100644
      --- tests/api-resources/beta/assistants.test.ts
      +++ tests/api-resources/beta/assistants.test.ts
      @@ -25,7 +25,7 @@ describe('resource assistants', () => {
      model: 'gpt-4o',
      description: 'description',
      instructions: 'instructions',
  •  metadata: {},
    
  •  metadata: { foo: 'string' },
     name: 'name',
     response_format: 'auto',
     temperature: 1,
    

@@ -33,7 +33,9 @@ describe('resource assistants', () => {
code_interpreter: { file_ids: ['string'] },
file_search: {
vector_store_ids: ['string'],

  •      vector_stores: [{ chunking_strategy: { type: 'auto' }, file_ids: ['string'], metadata: {} }],
    
  •      vector_stores: [
    
  •        { chunking_strategy: { type: 'auto' }, file_ids: ['string'], metadata: { foo: 'string' } },
    
  •      ],
       },
     },
     tools: [{ type: 'code_interpreter' }],
    

diff --git tests/api-resources/beta/realtime/sessions.test.ts tests/api-resources/beta/realtime/sessions.test.ts
index 0ed998c27..dbb92ead3 100644
--- tests/api-resources/beta/realtime/sessions.test.ts
+++ tests/api-resources/beta/realtime/sessions.test.ts
@@ -9,8 +9,8 @@ const client = new OpenAI({
});

describe('resource sessions', () => {

  • test('create: only required params', async () => {
  • const responsePromise = client.beta.realtime.sessions.create({ model: 'gpt-4o-realtime-preview' });
  • test('create', async () => {
  • const responsePromise = client.beta.realtime.sessions.create({});
    const rawResponse = await responsePromise.asResponse();
    expect(rawResponse).toBeInstanceOf(Response);
    const response = await responsePromise;
    @@ -19,27 +19,4 @@ describe('resource sessions', () => {
    expect(dataAndResponse.data).toBe(response);
    expect(dataAndResponse.response).toBe(rawResponse);
    });
  • test('create: required and optional params', async () => {
  • const response = await client.beta.realtime.sessions.create({
  •  model: 'gpt-4o-realtime-preview',
    
  •  input_audio_format: 'pcm16',
    
  •  input_audio_transcription: { model: 'model' },
    
  •  instructions: 'instructions',
    
  •  max_response_output_tokens: 0,
    
  •  modalities: ['text'],
    
  •  output_audio_format: 'pcm16',
    
  •  temperature: 0,
    
  •  tool_choice: 'tool_choice',
    
  •  tools: [{ description: 'description', name: 'name', parameters: {}, type: 'function' }],
    
  •  turn_detection: {
    
  •    create_response: true,
    
  •    prefix_padding_ms: 0,
    
  •    silence_duration_ms: 0,
    
  •    threshold: 0,
    
  •    type: 'type',
    
  •  },
    
  •  voice: 'alloy',
    
  • });
  • });
    });
    diff --git tests/api-resources/beta/threads/messages.test.ts tests/api-resources/beta/threads/messages.test.ts
    index c1f5f7b6e..e125edd84 100644
    --- tests/api-resources/beta/threads/messages.test.ts
    +++ tests/api-resources/beta/threads/messages.test.ts
    @@ -28,7 +28,7 @@ describe('resource messages', () => {
    content: 'string',
    role: 'user',
    attachments: [{ file_id: 'file_id', tools: [{ type: 'code_interpreter' }] }],
  •  metadata: {},
    
  •  metadata: { foo: 'string' },
    
    });
    });

diff --git tests/api-resources/beta/threads/runs/runs.test.ts tests/api-resources/beta/threads/runs/runs.test.ts
index 4fd8261ac..9b728403f 100644
--- tests/api-resources/beta/threads/runs/runs.test.ts
+++ tests/api-resources/beta/threads/runs/runs.test.ts
@@ -30,13 +30,13 @@ describe('resource runs', () => {
content: 'string',
role: 'user',
attachments: [{ file_id: 'file_id', tools: [{ type: 'code_interpreter' }] }],

  •      metadata: {},
    
  •      metadata: { foo: 'string' },
       },
     ],
     instructions: 'instructions',
     max_completion_tokens: 256,
     max_prompt_tokens: 256,
    
  •  metadata: {},
    
  •  metadata: { foo: 'string' },
     model: 'gpt-4o',
     parallel_tool_calls: true,
     response_format: 'auto',
    

diff --git tests/api-resources/beta/threads/threads.test.ts tests/api-resources/beta/threads/threads.test.ts
index aba266316..f26d6ec44 100644
--- tests/api-resources/beta/threads/threads.test.ts
+++ tests/api-resources/beta/threads/threads.test.ts
@@ -37,15 +37,17 @@ describe('resource threads', () => {
content: 'string',
role: 'user',
attachments: [{ file_id: 'file_id', tools: [{ type: 'code_interpreter' }] }],

  •          metadata: {},
    
  •          metadata: { foo: 'string' },
           },
         ],
    
  •      metadata: {},
    
  •      metadata: { foo: 'string' },
         tool_resources: {
           code_interpreter: { file_ids: ['string'] },
           file_search: {
             vector_store_ids: ['string'],
    
  •          vector_stores: [{ chunking_strategy: { type: 'auto' }, file_ids: ['string'], metadata: {} }],
    
  •          vector_stores: [
    
  •            { chunking_strategy: { type: 'auto' }, file_ids: ['string'], metadata: { foo: 'string' } },
    
  •          ],
           },
         },
       },
    

@@ -118,7 +120,7 @@ describe('resource threads', () => {
instructions: 'instructions',
max_completion_tokens: 256,
max_prompt_tokens: 256,

  •  metadata: {},
    
  •  metadata: { foo: 'string' },
     model: 'gpt-4o',
     parallel_tool_calls: true,
     response_format: 'auto',
    

@@ -130,15 +132,17 @@ describe('resource threads', () => {
content: 'string',
role: 'user',
attachments: [{ file_id: 'file_id', tools: [{ type: 'code_interpreter' }] }],

  •        metadata: {},
    
  •        metadata: { foo: 'string' },
         },
       ],
    
  •    metadata: {},
    
  •    metadata: { foo: 'string' },
       tool_resources: {
         code_interpreter: { file_ids: ['string'] },
         file_search: {
           vector_store_ids: ['string'],
    
  •        vector_stores: [{ chunking_strategy: { type: 'auto' }, file_ids: ['string'], metadata: {} }],
    
  •        vector_stores: [
    
  •          { chunking_strategy: { type: 'auto' }, file_ids: ['string'], metadata: { foo: 'string' } },
    
  •        ],
         },
       },
     },
    

diff --git tests/api-resources/chat/completions.test.ts tests/api-resources/chat/completions.test.ts
index dfc09f69b..8f1bc7d4c 100644
--- tests/api-resources/chat/completions.test.ts
+++ tests/api-resources/chat/completions.test.ts
@@ -43,7 +43,7 @@ describe('resource completions', () => {
presence_penalty: -2,
reasoning_effort: 'low',
response_format: { type: 'text' },

  •  seed: -9007199254740991,
    
  •  seed: 0,
     service_tier: 'auto',
     stop: 'string',
     store: true,
    

diff --git tests/api-resources/completions.test.ts tests/api-resources/completions.test.ts
index 82322dc3a..c98501a87 100644
--- tests/api-resources/completions.test.ts
+++ tests/api-resources/completions.test.ts
@@ -32,7 +32,7 @@ describe('resource completions', () => {
max_tokens: 16,
n: 1,
presence_penalty: -2,

  •  seed: -9007199254740991,
    
  •  seed: 0,
     stop: '\n',
     stream: false,
     stream_options: { include_usage: true },
    

diff --git tests/lib/azure.test.ts tests/lib/azure.test.ts
index 064a0098c..430efbe57 100644
--- tests/lib/azure.test.ts
+++ tests/lib/azure.test.ts
@@ -51,6 +51,18 @@ describe('instantiate azure client', () => {
});
expect(req.headers as Headers).not.toHaveProperty('x-my-default-header');
});
+

  • test('includes retry count', () => {
  •  const { req } = client.buildRequest(
    
  •    {
    
  •      path: '/foo',
    
  •      method: 'post',
    
  •      headers: { 'X-My-Default-Header': null },
    
  •    },
    
  •    { retryCount: 1 },
    
  •  );
    
  •  expect((req.headers as Headers)['x-stainless-retry-count']).toEqual('1');
    
  • });
    });

describe('defaultQuery', () => {
@@ -483,21 +495,23 @@ describe('azure request building', () => {
);
});

  •  test('Audio translations is not handled', async () => {
    
  •  test('handles audio translations', async () => {
       const { url } = (await client.audio.translations.create({
         model: deployment,
         file: { url: 'https://example.com', blob: () => 0 as any },
       })) as any;
    
  •    expect(url).toStrictEqual(`https://example.com/openai/audio/translations?api-version=${apiVersion}`);
    
  •    expect(url).toStrictEqual(
    
  •      `https://example.com/openai/deployments/${deployment}/audio/translations?api-version=${apiVersion}`,
    
  •    );
     });
    
  •  test('Audio transcriptions is not handled', async () => {
    
  •  test('handles audio transcriptions', async () => {
       const { url } = (await client.audio.transcriptions.create({
         model: deployment,
         file: { url: 'https://example.com', blob: () => 0 as any },
       })) as any;
       expect(url).toStrictEqual(
    
  •      `https://example.com/openai/audio/transcriptions?api-version=${apiVersion}`,
    
  •      `https://example.com/openai/deployments/${deployment}/audio/transcriptions?api-version=${apiVersion}`,
       );
     });
    

</details>

### Description
This PR updates the OpenAI Node.js SDK from version 4.79.4 to 4.83.0, including multiple feature additions and bug fixes. The main changes focus on Azure Realtime API support, improved typing for metadata fields, and various API endpoint updates.

<details>
<summary><i>Changes</i></summary>

### Changes
1. **Version Upgrades & Core Changes**
- Updated version from 4.79.4 to 4.83.0
- Added `X-Stainless-Timeout` header support
- Updated OpenAPI spec URL

2. **Azure Support**
- Added Realtime API support for Azure OpenAI
- Added Azure deployment parameters for audio endpoints
- Improved Azure AD token handling
- Added new Azure examples for realtime websocket usage

3. **API Enhancements**
- Added new model `o3-mini`
- Added developer role to ChatCompletionRole
- Updated metadata type definitions across multiple resources
- Enhanced audio-related type definitions and parameters
- Improved documentation for various endpoints

4. **Documentation**
- Fixed various typos and documentation links
- Added Azure realtime API usage examples
- Updated metadata field documentation

5. **Type System Improvements**
- Added shared Metadata type
- Corrected audio duration type from string to number
- Enhanced type definitions for chat completions
- Added more specific typing for various API parameters

```mermaid
sequenceDiagram
    participant Client
    participant AzureOpenAI
    participant WebSocket
    participant OpenAIAPI

    Client->>AzureOpenAI: Create client with credentials
    AzureOpenAI->>AzureOpenAI: Initialize with AD token/key
    Client->>AzureOpenAI: Request realtime session
    AzureOpenAI->>WebSocket: Establish WebSocket connection
    WebSocket->>OpenAIAPI: Authenticate connection
    OpenAIAPI-->>WebSocket: Connection confirmed
    
    loop Real-time Communication
        Client->>WebSocket: Send event/message
        WebSocket->>OpenAIAPI: Forward request
        OpenAIAPI-->>WebSocket: Stream response
        WebSocket-->>Client: Handle response
    end
    
    Client->>WebSocket: Close connection
    WebSocket->>OpenAIAPI: Terminate session

@thypon thypon merged commit 488166d into main Feb 12, 2025
8 checks passed
@thypon thypon deleted the renovate/openai-4.x-lockfile branch February 12, 2025 22:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant