diff --git a/.github/workflows/detect-breaking-changes.yml b/.github/workflows/detect-breaking-changes.yml new file mode 100644 index 000000000..09bc17df1 --- /dev/null +++ b/.github/workflows/detect-breaking-changes.yml @@ -0,0 +1,90 @@ +name: CI +on: + pull_request: + branches: + - main + - next + +jobs: + detect_breaking_changes: + runs-on: 'ubuntu-latest' + name: detect-breaking-changes + if: github.repository == 'openai/openai-node' + steps: + - name: Calculate fetch-depth + run: | + echo "FETCH_DEPTH=$(expr ${{ github.event.pull_request.commits }} + 1)" >> $GITHUB_ENV + + - uses: actions/checkout@v4 + with: + # Ensure we can check out the pull request base in the script below. + fetch-depth: ${{ env.FETCH_DEPTH }} + + - name: Set up Node + uses: actions/setup-node@v3 + with: + node-version: '20' + - name: Install dependencies + run: | + yarn install + + - name: Detect breaking changes + run: | + # Try to check out previous versions of the breaking change detection script. This ensures that + # we still detect breaking changes when entire files and their tests are removed. + git checkout "${{ github.event.pull_request.base.sha }}" -- ./scripts/detect-breaking-changes 2>/dev/null || true + ./scripts/detect-breaking-changes ${{ github.event.pull_request.base.sha }} + agents_sdk: + runs-on: 'ubuntu-latest' + name: Detect Agents SDK regressions + if: github.repository == 'openai/openai-node' + steps: + - name: Set up Node + uses: actions/setup-node@v4 + with: + node-version: '20' + + - name: Install pnpm + uses: pnpm/action-setup@v4 + with: + version: 10.25.0 + run_install: false + + # Setup this sdk + - uses: actions/checkout@v4 + with: + path: openai-node + + - name: Bootstrap + working-directory: openai-node + run: ./scripts/bootstrap + + - name: Build + working-directory: openai-node + run: ./scripts/build + + # Setup the agents packages + - uses: actions/checkout@v4 + with: + repository: openai/openai-agents-js + path: openai-agents-js + + - name: Link agents packages to local SDKs + working-directory: openai-agents-js + run: pnpm --filter @openai/agents-core --filter @openai/agents-openai --filter @openai/agents add file:../../../openai-node/dist + + - name: Install dependencies + working-directory: openai-agents-js + run: pnpm install + + - name: Build all packages + working-directory: openai-agents-js + run: pnpm build + + - name: Run linter + working-directory: openai-agents-js + run: pnpm lint + + - name: Type-check docs scripts + working-directory: openai-agents-js + run: pnpm docs:scripts:check diff --git a/.release-please-manifest.json b/.release-please-manifest.json index a3e78badb..c6cd56fa2 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "6.15.0" + ".": "6.16.0" } diff --git a/.stats.yml b/.stats.yml index eb957d45d..e77bbf6d8 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 136 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-75926226b642ebb2cb415694da9dff35e8ab40145ac1b791cefb82a83809db4d.yml -openapi_spec_hash: 6a0e391b0ba5747b6b4a3e5fe21de4da -config_hash: adcf23ecf5f84d3cadf1d71e82ec636a +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-9442fa9212dd61aac2bb0edd19744bee381e75888712f9098bc6ebb92c52b557.yml +openapi_spec_hash: f87823d164b7a8f72a42eba04e482a99 +config_hash: ad7136f7366fddec432ec378939e58a7 diff --git a/CHANGELOG.md b/CHANGELOG.md index d1b7c7b5c..75e0921c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,20 @@ # Changelog +## 6.16.0 (2026-01-09) + +Full Changelog: [v6.15.0...v6.16.0](https://github.com/openai/openai-node/compare/v6.15.0...v6.16.0) + +### Features + +* **api:** add new Response completed_at prop ([ca40534](https://github.com/openai/openai-node/commit/ca40534778311def52bc7dbbab043d925cdaf847)) +* **ci:** add breaking change detection workflow ([a6f3dea](https://github.com/openai/openai-node/commit/a6f3deaf89ea0ef85cc57e1150032bb6b807c3b9)) + + +### Chores + +* break long lines in snippets into multiline ([80dee2f](https://github.com/openai/openai-node/commit/80dee2fe64d1b13f181bd482b31eb06fd6c5f3f4)) +* **internal:** codegen related update ([b2fac3e](https://github.com/openai/openai-node/commit/b2fac3ecdc3aecc3303c26304c4c94deda061edb)) + ## 6.15.0 (2025-12-19) Full Changelog: [v6.14.0...v6.15.0](https://github.com/openai/openai-node/compare/v6.14.0...v6.15.0) diff --git a/LICENSE b/LICENSE index f011417af..cbb5bb26e 100644 --- a/LICENSE +++ b/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright 2025 OpenAI + Copyright 2026 OpenAI Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/README.md b/README.md index 351d9c0dc..18552fa36 100644 --- a/README.md +++ b/README.md @@ -111,7 +111,10 @@ await client.files.create({ file: fs.createReadStream('input.jsonl'), purpose: ' await client.files.create({ file: new File(['my bytes'], 'input.jsonl'), purpose: 'fine-tune' }); // You can also pass a `fetch` `Response`: -await client.files.create({ file: await fetch('https://somesite/input.jsonl'), purpose: 'fine-tune' }); +await client.files.create({ + file: await fetch('https://somesite/input.jsonl'), + purpose: 'fine-tune', +}); // Finally, if none of the above are convenient, you can use our `toFile` helper: await client.files.create({ diff --git a/jsr.json b/jsr.json index 00ec5c704..43da23c96 100644 --- a/jsr.json +++ b/jsr.json @@ -1,6 +1,6 @@ { "name": "@openai/openai", - "version": "6.15.0", + "version": "6.16.0", "exports": { ".": "./index.ts", "./helpers/zod": "./helpers/zod.ts", diff --git a/package.json b/package.json index 52f1d20d1..de52bb630 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "openai", - "version": "6.15.0", + "version": "6.16.0", "description": "The official TypeScript library for the OpenAI API", "author": "OpenAI ", "types": "dist/index.d.ts", diff --git a/src/resources/audio/speech.ts b/src/resources/audio/speech.ts index 6a7e19059..92b787f62 100644 --- a/src/resources/audio/speech.ts +++ b/src/resources/audio/speech.ts @@ -46,9 +46,10 @@ export interface SpeechCreateParams { model: (string & {}) | SpeechModel; /** - * The voice to use when generating the audio. Supported voices are `alloy`, `ash`, - * `ballad`, `coral`, `echo`, `fable`, `onyx`, `nova`, `sage`, `shimmer`, and - * `verse`. Previews of the voices are available in the + * The voice to use when generating the audio. Supported built-in voices are + * `alloy`, `ash`, `ballad`, `coral`, `echo`, `fable`, `onyx`, `nova`, `sage`, + * `shimmer`, `verse`, `marin`, and `cedar`. Previews of the voices are available + * in the * [Text to speech guide](https://platform.openai.com/docs/guides/text-to-speech#voice-options). */ voice: diff --git a/src/resources/chat/completions/completions.ts b/src/resources/chat/completions/completions.ts index b5b0d7e1a..c59bcb6cd 100644 --- a/src/resources/chat/completions/completions.ts +++ b/src/resources/chat/completions/completions.ts @@ -486,8 +486,9 @@ export interface ChatCompletionAudioParam { format: 'wav' | 'aac' | 'mp3' | 'flac' | 'opus' | 'pcm16'; /** - * The voice the model uses to respond. Supported voices are `alloy`, `ash`, - * `ballad`, `coral`, `echo`, `fable`, `nova`, `onyx`, `sage`, and `shimmer`. + * The voice the model uses to respond. Supported built-in voices are `alloy`, + * `ash`, `ballad`, `coral`, `echo`, `fable`, `nova`, `onyx`, `sage`, `shimmer`, + * `marin`, and `cedar`. */ voice: | (string & {}) diff --git a/src/resources/images.ts b/src/resources/images.ts index 5ece6ef30..d305603b7 100644 --- a/src/resources/images.ts +++ b/src/resources/images.ts @@ -28,7 +28,8 @@ export class Images extends APIResource { /** * Creates an edited or extended image given one or more source images and a - * prompt. This endpoint only supports `gpt-image-1` and `dall-e-2`. + * prompt. This endpoint supports GPT Image models (`gpt-image-1.5`, `gpt-image-1`, + * and `gpt-image-1-mini`) and `dall-e-2`. * * @example * ```ts diff --git a/src/resources/realtime/realtime.ts b/src/resources/realtime/realtime.ts index 75525e1fd..bd4c7041c 100644 --- a/src/resources/realtime/realtime.ts +++ b/src/resources/realtime/realtime.ts @@ -1256,10 +1256,10 @@ export interface RealtimeAudioConfigOutput { speed?: number; /** - * The voice the model uses to respond. Voice cannot be changed during the session - * once the model has responded with audio at least once. Current voice options are - * `alloy`, `ash`, `ballad`, `coral`, `echo`, `sage`, `shimmer`, `verse`, `marin`, - * and `cedar`. We recommend `marin` and `cedar` for best quality. + * The voice the model uses to respond. Supported built-in voices are `alloy`, + * `ash`, `ballad`, `coral`, `echo`, `sage`, `shimmer`, `verse`, `marin`, and + * `cedar`. Voice cannot be changed during the session once the model has responded + * with audio at least once. We recommend `marin` and `cedar` for best quality. */ voice?: | (string & {}) @@ -2121,10 +2121,10 @@ export namespace RealtimeResponseCreateAudioOutput { format?: RealtimeAPI.RealtimeAudioFormats; /** - * The voice the model uses to respond. Voice cannot be changed during the session - * once the model has responded with audio at least once. Current voice options are - * `alloy`, `ash`, `ballad`, `coral`, `echo`, `sage`, `shimmer`, `verse`, `marin`, - * and `cedar`. We recommend `marin` and `cedar` for best quality. + * The voice the model uses to respond. Supported built-in voices are `alloy`, + * `ash`, `ballad`, `coral`, `echo`, `sage`, `shimmer`, `verse`, `marin`, and + * `cedar`. Voice cannot be changed during the session once the model has responded + * with audio at least once. */ voice?: | (string & {}) diff --git a/src/resources/responses/input-tokens.ts b/src/resources/responses/input-tokens.ts index c3826ce1e..29adc3456 100644 --- a/src/resources/responses/input-tokens.ts +++ b/src/resources/responses/input-tokens.ts @@ -89,9 +89,7 @@ export interface InputTokenCountParams { text?: InputTokenCountParams.Text | null; /** - * How the model should select which tool (or tools) to use when generating a - * response. See the `tools` parameter to see how to specify which tools the model - * can call. + * Controls which tool the model should use, if any. */ tool_choice?: | ResponsesAPI.ToolChoiceOptions diff --git a/src/resources/responses/responses.ts b/src/resources/responses/responses.ts index f13cfeba4..d4ce44395 100644 --- a/src/resources/responses/responses.ts +++ b/src/resources/responses/responses.ts @@ -595,8 +595,14 @@ export interface Response { background?: boolean | null; /** - * The conversation that this response belongs to. Input items and output items - * from this response are automatically added to this conversation. + * Unix timestamp (in seconds) of when this Response was completed. Only present + * when the status is `completed`. + */ + completed_at?: number | null; + + /** + * The conversation that this response belonged to. Input items and output items + * from this response were automatically added to this conversation. */ conversation?: Response.Conversation | null; @@ -727,12 +733,12 @@ export namespace Response { } /** - * The conversation that this response belongs to. Input items and output items - * from this response are automatically added to this conversation. + * The conversation that this response belonged to. Input items and output items + * from this response were automatically added to this conversation. */ export interface Conversation { /** - * The unique ID of the conversation. + * The unique ID of the conversation that this response was associated with. */ id: string; } @@ -1159,6 +1165,9 @@ export interface ResponseCompactionItem { */ id: string; + /** + * The encrypted content that was produced by compaction. + */ encrypted_content: string; /** @@ -1166,6 +1175,9 @@ export interface ResponseCompactionItem { */ type: 'compaction'; + /** + * The identifier of the actor that created the item. + */ created_by?: string; } @@ -1174,6 +1186,9 @@ export interface ResponseCompactionItem { * [`v1/responses/compact` API](https://platform.openai.com/docs/api-reference/responses/compact). */ export interface ResponseCompactionItemParam { + /** + * The encrypted content of the compaction summary. + */ encrypted_content: string; /** @@ -2172,13 +2187,16 @@ export interface ResponseFunctionCallArgumentsDoneEvent { } /** - * A text input to the model. + * A piece of message content, such as text, an image, or a file. */ export type ResponseFunctionCallOutputItem = | ResponseInputTextContent | ResponseInputImageContent | ResponseInputFileContent; +/** + * An array of content outputs (text, image, file) for the function tool call. + */ export type ResponseFunctionCallOutputItemList = Array; /** @@ -2285,7 +2303,7 @@ export namespace ResponseFunctionShellToolCall { } /** - * The output of a shell tool call. + * The output of a shell tool call that was emitted. */ export interface ResponseFunctionShellToolCallOutput { /** @@ -2315,12 +2333,15 @@ export interface ResponseFunctionShellToolCallOutput { */ type: 'shell_call_output'; + /** + * The identifier of the actor that created the item. + */ created_by?: string; } export namespace ResponseFunctionShellToolCallOutput { /** - * The content of a shell call output. + * The content of a shell tool call output that was emitted. */ export interface Output { /** @@ -2329,10 +2350,19 @@ export namespace ResponseFunctionShellToolCallOutput { */ outcome: Output.Timeout | Output.Exit; + /** + * The standard error output that was captured. + */ stderr: string; + /** + * The standard output that was captured. + */ stdout: string; + /** + * The identifier of the actor that created the item. + */ created_by?: string; } @@ -2471,7 +2501,7 @@ export namespace ResponseFunctionWebSearch { */ export interface Search { /** - * The search query. + * [DEPRECATED] The search query. */ query: string; @@ -2480,6 +2510,11 @@ export namespace ResponseFunctionWebSearch { */ type: 'search'; + /** + * The search queries. + */ + queries?: Array; + /** * The sources used in the search. */ @@ -5731,6 +5766,9 @@ export namespace Tool { */ file_ids?: Array; + /** + * The memory limit for the code interpreter container. + */ memory_limit?: '1g' | '4g' | '16g' | '64g' | null; } } diff --git a/src/resources/videos.ts b/src/resources/videos.ts index ec5358f59..ca86c5158 100644 --- a/src/resources/videos.ts +++ b/src/resources/videos.ts @@ -140,9 +140,18 @@ export interface Video { status: 'queued' | 'in_progress' | 'completed' | 'failed'; } +/** + * An error that occurred while generating the response. + */ export interface VideoCreateError { + /** + * A machine-readable error code that was returned. + */ code: string; + /** + * A human-readable description of the error that was returned. + */ message: string; } diff --git a/src/version.ts b/src/version.ts index fe880f9ea..6a46d2d55 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export const VERSION = '6.15.0'; // x-release-please-version +export const VERSION = '6.16.0'; // x-release-please-version diff --git a/tests/api-resources/beta/assistants.test.ts b/tests/api-resources/beta/assistants.test.ts index d6f3fd141..695837b7b 100644 --- a/tests/api-resources/beta/assistants.test.ts +++ b/tests/api-resources/beta/assistants.test.ts @@ -34,7 +34,11 @@ describe('resource assistants', () => { file_search: { vector_store_ids: ['string'], vector_stores: [ - { chunking_strategy: { type: 'auto' }, file_ids: ['string'], metadata: { foo: 'string' } }, + { + chunking_strategy: { type: 'auto' }, + file_ids: ['string'], + metadata: { foo: 'string' }, + }, ], }, }, @@ -80,7 +84,12 @@ describe('resource assistants', () => { // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error await expect( client.beta.assistants.list( - { after: 'after', before: 'before', limit: 0, order: 'asc' }, + { + after: 'after', + before: 'before', + limit: 0, + order: 'asc', + }, { path: '/_stainless_unknown_path' }, ), ).rejects.toThrow(OpenAI.NotFoundError); diff --git a/tests/api-resources/beta/chatkit/sessions.test.ts b/tests/api-resources/beta/chatkit/sessions.test.ts index 674fb95e5..3448007aa 100644 --- a/tests/api-resources/beta/chatkit/sessions.test.ts +++ b/tests/api-resources/beta/chatkit/sessions.test.ts @@ -9,7 +9,10 @@ const client = new OpenAI({ describe('resource sessions', () => { test('create: only required params', async () => { - const responsePromise = client.beta.chatkit.sessions.create({ user: 'x', workflow: { id: 'id' } }); + const responsePromise = client.beta.chatkit.sessions.create({ + user: 'x', + workflow: { id: 'id' }, + }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -30,7 +33,11 @@ describe('resource sessions', () => { }, chatkit_configuration: { automatic_thread_titling: { enabled: true }, - file_upload: { enabled: true, max_file_size: 1, max_files: 1 }, + file_upload: { + enabled: true, + max_file_size: 1, + max_files: 1, + }, history: { enabled: true, recent_threads: 1 }, }, expires_after: { anchor: 'created_at', seconds: 1 }, diff --git a/tests/api-resources/beta/chatkit/threads.test.ts b/tests/api-resources/beta/chatkit/threads.test.ts index ded6dde2e..1985d276b 100644 --- a/tests/api-resources/beta/chatkit/threads.test.ts +++ b/tests/api-resources/beta/chatkit/threads.test.ts @@ -34,7 +34,13 @@ describe('resource threads', () => { // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error await expect( client.beta.chatkit.threads.list( - { after: 'after', before: 'before', limit: 0, order: 'asc', user: 'x' }, + { + after: 'after', + before: 'before', + limit: 0, + order: 'asc', + user: 'x', + }, { path: '/_stainless_unknown_path' }, ), ).rejects.toThrow(OpenAI.NotFoundError); @@ -67,7 +73,12 @@ describe('resource threads', () => { await expect( client.beta.chatkit.threads.listItems( 'cthr_123', - { after: 'after', before: 'before', limit: 0, order: 'asc' }, + { + after: 'after', + before: 'before', + limit: 0, + order: 'asc', + }, { path: '/_stainless_unknown_path' }, ), ).rejects.toThrow(OpenAI.NotFoundError); diff --git a/tests/api-resources/beta/threads/messages.test.ts b/tests/api-resources/beta/threads/messages.test.ts index 587daf0a1..315c0c2ca 100644 --- a/tests/api-resources/beta/threads/messages.test.ts +++ b/tests/api-resources/beta/threads/messages.test.ts @@ -80,7 +80,13 @@ describe('resource messages', () => { await expect( client.beta.threads.messages.list( 'thread_id', - { after: 'after', before: 'before', limit: 0, order: 'asc', run_id: 'run_id' }, + { + after: 'after', + before: 'before', + limit: 0, + order: 'asc', + run_id: 'run_id', + }, { path: '/_stainless_unknown_path' }, ), ).rejects.toThrow(OpenAI.NotFoundError); diff --git a/tests/api-resources/beta/threads/runs/runs.test.ts b/tests/api-resources/beta/threads/runs/runs.test.ts index 1d9badfee..3b811c43c 100644 --- a/tests/api-resources/beta/threads/runs/runs.test.ts +++ b/tests/api-resources/beta/threads/runs/runs.test.ts @@ -98,7 +98,12 @@ describe('resource runs', () => { await expect( client.beta.threads.runs.list( 'thread_id', - { after: 'after', before: 'before', limit: 0, order: 'asc' }, + { + after: 'after', + before: 'before', + limit: 0, + order: 'asc', + }, { path: '/_stainless_unknown_path' }, ), ).rejects.toThrow(OpenAI.NotFoundError); diff --git a/tests/api-resources/beta/threads/threads.test.ts b/tests/api-resources/beta/threads/threads.test.ts index 342e673b3..b15a40746 100644 --- a/tests/api-resources/beta/threads/threads.test.ts +++ b/tests/api-resources/beta/threads/threads.test.ts @@ -38,7 +38,11 @@ describe('resource threads', () => { file_search: { vector_store_ids: ['string'], vector_stores: [ - { chunking_strategy: { type: 'auto' }, file_ids: ['string'], metadata: { foo: 'string' } }, + { + chunking_strategy: { type: 'auto' }, + file_ids: ['string'], + metadata: { foo: 'string' }, + }, ], }, }, @@ -119,7 +123,11 @@ describe('resource threads', () => { file_search: { vector_store_ids: ['string'], vector_stores: [ - { chunking_strategy: { type: 'auto' }, file_ids: ['string'], metadata: { foo: 'string' } }, + { + chunking_strategy: { type: 'auto' }, + file_ids: ['string'], + metadata: { foo: 'string' }, + }, ], }, }, diff --git a/tests/api-resources/chat/completions/completions.test.ts b/tests/api-resources/chat/completions/completions.test.ts index ec4694b34..d8ab7e6fc 100644 --- a/tests/api-resources/chat/completions/completions.test.ts +++ b/tests/api-resources/chat/completions/completions.test.ts @@ -24,12 +24,24 @@ describe('resource completions', () => { test('create: required and optional params', async () => { const response = await client.chat.completions.create({ - messages: [{ content: 'string', role: 'developer', name: 'name' }], + messages: [ + { + content: 'string', + role: 'developer', + name: 'name', + }, + ], model: 'gpt-4o', audio: { format: 'wav', voice: 'ash' }, frequency_penalty: -2, function_call: 'none', - functions: [{ name: 'name', description: 'description', parameters: { foo: 'bar' } }], + functions: [ + { + name: 'name', + description: 'description', + parameters: { foo: 'bar' }, + }, + ], logit_bias: { foo: 0 }, logprobs: true, max_completion_tokens: 0, @@ -55,7 +67,12 @@ describe('resource completions', () => { tool_choice: 'none', tools: [ { - function: { name: 'name', description: 'description', parameters: { foo: 'bar' }, strict: true }, + function: { + name: 'name', + description: 'description', + parameters: { foo: 'bar' }, + strict: true, + }, type: 'function', }, ], @@ -66,7 +83,12 @@ describe('resource completions', () => { web_search_options: { search_context_size: 'low', user_location: { - approximate: { city: 'city', country: 'country', region: 'region', timezone: 'timezone' }, + approximate: { + city: 'city', + country: 'country', + region: 'region', + timezone: 'timezone', + }, type: 'approximate', }, }, @@ -114,7 +136,13 @@ describe('resource completions', () => { // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error await expect( client.chat.completions.list( - { after: 'after', limit: 0, metadata: { foo: 'string' }, model: 'model', order: 'asc' }, + { + after: 'after', + limit: 0, + metadata: { foo: 'string' }, + model: 'model', + order: 'asc', + }, { path: '/_stainless_unknown_path' }, ), ).rejects.toThrow(OpenAI.NotFoundError); diff --git a/tests/api-resources/chat/completions/messages.test.ts b/tests/api-resources/chat/completions/messages.test.ts index 98dd22167..225d34e71 100644 --- a/tests/api-resources/chat/completions/messages.test.ts +++ b/tests/api-resources/chat/completions/messages.test.ts @@ -24,7 +24,11 @@ describe('resource messages', () => { await expect( client.chat.completions.messages.list( 'completion_id', - { after: 'after', limit: 0, order: 'asc' }, + { + after: 'after', + limit: 0, + order: 'asc', + }, { path: '/_stainless_unknown_path' }, ), ).rejects.toThrow(OpenAI.NotFoundError); diff --git a/tests/api-resources/containers/containers.test.ts b/tests/api-resources/containers/containers.test.ts index 6b739e4ef..5ae416df0 100644 --- a/tests/api-resources/containers/containers.test.ts +++ b/tests/api-resources/containers/containers.test.ts @@ -54,7 +54,11 @@ describe('resource containers', () => { // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error await expect( client.containers.list( - { after: 'after', limit: 0, order: 'asc' }, + { + after: 'after', + limit: 0, + order: 'asc', + }, { path: '/_stainless_unknown_path' }, ), ).rejects.toThrow(OpenAI.NotFoundError); diff --git a/tests/api-resources/containers/files/files.test.ts b/tests/api-resources/containers/files/files.test.ts index f57b46316..2273ec8f4 100644 --- a/tests/api-resources/containers/files/files.test.ts +++ b/tests/api-resources/containers/files/files.test.ts @@ -50,7 +50,11 @@ describe('resource files', () => { await expect( client.containers.files.list( 'container_id', - { after: 'after', limit: 0, order: 'asc' }, + { + after: 'after', + limit: 0, + order: 'asc', + }, { path: '/_stainless_unknown_path' }, ), ).rejects.toThrow(OpenAI.NotFoundError); diff --git a/tests/api-resources/conversations/conversations.test.ts b/tests/api-resources/conversations/conversations.test.ts index 9a85d4b5f..f9a72e94d 100644 --- a/tests/api-resources/conversations/conversations.test.ts +++ b/tests/api-resources/conversations/conversations.test.ts @@ -23,7 +23,16 @@ describe('resource conversations', () => { // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error await expect( client.conversations.create( - { items: [{ content: 'string', role: 'user', type: 'message' }], metadata: { foo: 'string' } }, + { + items: [ + { + content: 'string', + role: 'user', + type: 'message', + }, + ], + metadata: { foo: 'string' }, + }, { path: '/_stainless_unknown_path' }, ), ).rejects.toThrow(OpenAI.NotFoundError); diff --git a/tests/api-resources/conversations/items.test.ts b/tests/api-resources/conversations/items.test.ts index 1c1ca83d0..520b36a89 100644 --- a/tests/api-resources/conversations/items.test.ts +++ b/tests/api-resources/conversations/items.test.ts @@ -10,7 +10,13 @@ const client = new OpenAI({ describe('resource items', () => { test('create: only required params', async () => { const responsePromise = client.conversations.items.create('conv_123', { - items: [{ content: 'string', role: 'user', type: 'message' }], + items: [ + { + content: 'string', + role: 'user', + type: 'message', + }, + ], }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); @@ -23,7 +29,13 @@ describe('resource items', () => { test('create: required and optional params', async () => { const response = await client.conversations.items.create('conv_123', { - items: [{ content: 'string', role: 'user', type: 'message' }], + items: [ + { + content: 'string', + role: 'user', + type: 'message', + }, + ], include: ['file_search_call.results'], }); }); @@ -62,7 +74,12 @@ describe('resource items', () => { await expect( client.conversations.items.list( 'conv_123', - { after: 'after', include: ['file_search_call.results'], limit: 0, order: 'asc' }, + { + after: 'after', + include: ['file_search_call.results'], + limit: 0, + order: 'asc', + }, { path: '/_stainless_unknown_path' }, ), ).rejects.toThrow(OpenAI.NotFoundError); diff --git a/tests/api-resources/evals/evals.test.ts b/tests/api-resources/evals/evals.test.ts index a852ef8f7..c59f8a4e1 100644 --- a/tests/api-resources/evals/evals.test.ts +++ b/tests/api-resources/evals/evals.test.ts @@ -10,7 +10,10 @@ const client = new OpenAI({ describe('resource evals', () => { test('create: only required params', async () => { const responsePromise = client.evals.create({ - data_source_config: { item_schema: { foo: 'bar' }, type: 'custom' }, + data_source_config: { + item_schema: { foo: 'bar' }, + type: 'custom', + }, testing_criteria: [ { input: [{ content: 'content', role: 'role' }], @@ -33,7 +36,11 @@ describe('resource evals', () => { test('create: required and optional params', async () => { const response = await client.evals.create({ - data_source_config: { item_schema: { foo: 'bar' }, type: 'custom', include_sample_schema: true }, + data_source_config: { + item_schema: { foo: 'bar' }, + type: 'custom', + include_sample_schema: true, + }, testing_criteria: [ { input: [{ content: 'content', role: 'role' }], @@ -86,7 +93,12 @@ describe('resource evals', () => { // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error await expect( client.evals.list( - { after: 'after', limit: 0, order: 'asc', order_by: 'created_at' }, + { + after: 'after', + limit: 0, + order: 'asc', + order_by: 'created_at', + }, { path: '/_stainless_unknown_path' }, ), ).rejects.toThrow(OpenAI.NotFoundError); diff --git a/tests/api-resources/evals/runs/runs.test.ts b/tests/api-resources/evals/runs/runs.test.ts index d17cd2a9a..629bbf4bd 100644 --- a/tests/api-resources/evals/runs/runs.test.ts +++ b/tests/api-resources/evals/runs/runs.test.ts @@ -10,7 +10,10 @@ const client = new OpenAI({ describe('resource runs', () => { test('create: only required params', async () => { const responsePromise = client.evals.runs.create('eval_id', { - data_source: { source: { content: [{ item: { foo: 'bar' } }], type: 'file_content' }, type: 'jsonl' }, + data_source: { + source: { content: [{ item: { foo: 'bar' } }], type: 'file_content' }, + type: 'jsonl', + }, }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); @@ -24,7 +27,15 @@ describe('resource runs', () => { test('create: required and optional params', async () => { const response = await client.evals.runs.create('eval_id', { data_source: { - source: { content: [{ item: { foo: 'bar' }, sample: { foo: 'bar' } }], type: 'file_content' }, + source: { + content: [ + { + item: { foo: 'bar' }, + sample: { foo: 'bar' }, + }, + ], + type: 'file_content', + }, type: 'jsonl', }, metadata: { foo: 'string' }, @@ -63,7 +74,12 @@ describe('resource runs', () => { await expect( client.evals.runs.list( 'eval_id', - { after: 'after', limit: 0, order: 'asc', status: 'queued' }, + { + after: 'after', + limit: 0, + order: 'asc', + status: 'queued', + }, { path: '/_stainless_unknown_path' }, ), ).rejects.toThrow(OpenAI.NotFoundError); diff --git a/tests/api-resources/files.test.ts b/tests/api-resources/files.test.ts index 03a8988b7..b7830a9af 100644 --- a/tests/api-resources/files.test.ts +++ b/tests/api-resources/files.test.ts @@ -56,7 +56,12 @@ describe('resource files', () => { // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error await expect( client.files.list( - { after: 'after', limit: 0, order: 'asc', purpose: 'purpose' }, + { + after: 'after', + limit: 0, + order: 'asc', + purpose: 'purpose', + }, { path: '/_stainless_unknown_path' }, ), ).rejects.toThrow(OpenAI.NotFoundError); diff --git a/tests/api-resources/fine-tuning/alpha/graders.test.ts b/tests/api-resources/fine-tuning/alpha/graders.test.ts index 13288e0c3..09b71cf37 100644 --- a/tests/api-resources/fine-tuning/alpha/graders.test.ts +++ b/tests/api-resources/fine-tuning/alpha/graders.test.ts @@ -10,7 +10,13 @@ const client = new OpenAI({ describe('resource graders', () => { test('run: only required params', async () => { const responsePromise = client.fineTuning.alpha.graders.run({ - grader: { input: 'input', name: 'name', operation: 'eq', reference: 'reference', type: 'string_check' }, + grader: { + input: 'input', + name: 'name', + operation: 'eq', + reference: 'reference', + type: 'string_check', + }, model_sample: 'model_sample', }); const rawResponse = await responsePromise.asResponse(); @@ -24,7 +30,13 @@ describe('resource graders', () => { test('run: required and optional params', async () => { const response = await client.fineTuning.alpha.graders.run({ - grader: { input: 'input', name: 'name', operation: 'eq', reference: 'reference', type: 'string_check' }, + grader: { + input: 'input', + name: 'name', + operation: 'eq', + reference: 'reference', + type: 'string_check', + }, model_sample: 'model_sample', item: {}, }); @@ -32,7 +44,13 @@ describe('resource graders', () => { test('validate: only required params', async () => { const responsePromise = client.fineTuning.alpha.graders.validate({ - grader: { input: 'input', name: 'name', operation: 'eq', reference: 'reference', type: 'string_check' }, + grader: { + input: 'input', + name: 'name', + operation: 'eq', + reference: 'reference', + type: 'string_check', + }, }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); @@ -45,7 +63,13 @@ describe('resource graders', () => { test('validate: required and optional params', async () => { const response = await client.fineTuning.alpha.graders.validate({ - grader: { input: 'input', name: 'name', operation: 'eq', reference: 'reference', type: 'string_check' }, + grader: { + input: 'input', + name: 'name', + operation: 'eq', + reference: 'reference', + type: 'string_check', + }, }); }); }); diff --git a/tests/api-resources/fine-tuning/checkpoints/permissions.test.ts b/tests/api-resources/fine-tuning/checkpoints/permissions.test.ts index 8427ee957..cdeca2d2b 100644 --- a/tests/api-resources/fine-tuning/checkpoints/permissions.test.ts +++ b/tests/api-resources/fine-tuning/checkpoints/permissions.test.ts @@ -45,7 +45,12 @@ describe('resource permissions', () => { await expect( client.fineTuning.checkpoints.permissions.retrieve( 'ft-AF1WoRqd3aJAHsqc9NY7iL8F', - { after: 'after', limit: 0, order: 'ascending', project_id: 'project_id' }, + { + after: 'after', + limit: 0, + order: 'ascending', + project_id: 'project_id', + }, { path: '/_stainless_unknown_path' }, ), ).rejects.toThrow(OpenAI.NotFoundError); diff --git a/tests/api-resources/fine-tuning/jobs/jobs.test.ts b/tests/api-resources/fine-tuning/jobs/jobs.test.ts index 8cd4088ab..dae2036a5 100644 --- a/tests/api-resources/fine-tuning/jobs/jobs.test.ts +++ b/tests/api-resources/fine-tuning/jobs/jobs.test.ts @@ -26,11 +26,20 @@ describe('resource jobs', () => { const response = await client.fineTuning.jobs.create({ model: 'gpt-4o-mini', training_file: 'file-abc123', - hyperparameters: { batch_size: 'auto', learning_rate_multiplier: 'auto', n_epochs: 'auto' }, + hyperparameters: { + batch_size: 'auto', + learning_rate_multiplier: 'auto', + n_epochs: 'auto', + }, integrations: [ { type: 'wandb', - wandb: { project: 'my-wandb-project', entity: 'entity', name: 'name', tags: ['custom-tag'] }, + wandb: { + project: 'my-wandb-project', + entity: 'entity', + name: 'name', + tags: ['custom-tag'], + }, }, ], metadata: { foo: 'string' }, @@ -63,7 +72,11 @@ describe('resource jobs', () => { }, }, supervised: { - hyperparameters: { batch_size: 'auto', learning_rate_multiplier: 'auto', n_epochs: 'auto' }, + hyperparameters: { + batch_size: 'auto', + learning_rate_multiplier: 'auto', + n_epochs: 'auto', + }, }, }, seed: 42, @@ -98,7 +111,11 @@ describe('resource jobs', () => { // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error await expect( client.fineTuning.jobs.list( - { after: 'after', limit: 0, metadata: { foo: 'string' } }, + { + after: 'after', + limit: 0, + metadata: { foo: 'string' }, + }, { path: '/_stainless_unknown_path' }, ), ).rejects.toThrow(OpenAI.NotFoundError); diff --git a/tests/api-resources/realtime/calls.test.ts b/tests/api-resources/realtime/calls.test.ts index f0f9a417e..55ab9c45f 100644 --- a/tests/api-resources/realtime/calls.test.ts +++ b/tests/api-resources/realtime/calls.test.ts @@ -26,7 +26,11 @@ describe('resource calls', () => { input: { format: { rate: 24000, type: 'audio/pcm' }, noise_reduction: { type: 'near_field' }, - transcription: { language: 'language', model: 'string', prompt: 'prompt' }, + transcription: { + language: 'language', + model: 'string', + prompt: 'prompt', + }, turn_detection: { type: 'server_vad', create_response: true, @@ -37,16 +41,31 @@ describe('resource calls', () => { threshold: 0, }, }, - output: { format: { rate: 24000, type: 'audio/pcm' }, speed: 0.25, voice: 'ash' }, + output: { + format: { rate: 24000, type: 'audio/pcm' }, + speed: 0.25, + voice: 'ash', + }, }, include: ['item.input_audio_transcription.logprobs'], instructions: 'instructions', max_output_tokens: 0, model: 'string', output_modalities: ['text'], - prompt: { id: 'id', variables: { foo: 'string' }, version: 'version' }, + prompt: { + id: 'id', + variables: { foo: 'string' }, + version: 'version', + }, tool_choice: 'none', - tools: [{ description: 'description', name: 'name', parameters: {}, type: 'function' }], + tools: [ + { + description: 'description', + name: 'name', + parameters: {}, + type: 'function', + }, + ], tracing: 'auto', truncation: 'auto', }); diff --git a/tests/api-resources/responses/input-items.test.ts b/tests/api-resources/responses/input-items.test.ts index f04422e14..299a5102c 100644 --- a/tests/api-resources/responses/input-items.test.ts +++ b/tests/api-resources/responses/input-items.test.ts @@ -24,7 +24,12 @@ describe('resource inputItems', () => { await expect( client.responses.inputItems.list( 'response_id', - { after: 'after', include: ['file_search_call.results'], limit: 0, order: 'asc' }, + { + after: 'after', + include: ['file_search_call.results'], + limit: 0, + order: 'asc', + }, { path: '/_stainless_unknown_path' }, ), ).rejects.toThrow(OpenAI.NotFoundError); diff --git a/tests/api-resources/responses/input-tokens.test.ts b/tests/api-resources/responses/input-tokens.test.ts index 48e5372f1..2879f3c5d 100644 --- a/tests/api-resources/responses/input-tokens.test.ts +++ b/tests/api-resources/responses/input-tokens.test.ts @@ -30,8 +30,15 @@ describe('resource inputTokens', () => { model: 'model', parallel_tool_calls: true, previous_response_id: 'resp_123', - reasoning: { effort: 'none', generate_summary: 'auto', summary: 'auto' }, - text: { format: { type: 'text' }, verbosity: 'low' }, + reasoning: { + effort: 'none', + generate_summary: 'auto', + summary: 'auto', + }, + text: { + format: { type: 'text' }, + verbosity: 'low', + }, tool_choice: 'none', tools: [ { diff --git a/tests/api-resources/vector-stores/files.test.ts b/tests/api-resources/vector-stores/files.test.ts index 9e9afc95d..26de5d903 100644 --- a/tests/api-resources/vector-stores/files.test.ts +++ b/tests/api-resources/vector-stores/files.test.ts @@ -83,7 +83,13 @@ describe('resource files', () => { await expect( client.vectorStores.files.list( 'vector_store_id', - { after: 'after', before: 'before', filter: 'in_progress', limit: 0, order: 'asc' }, + { + after: 'after', + before: 'before', + filter: 'in_progress', + limit: 0, + order: 'asc', + }, { path: '/_stainless_unknown_path' }, ), ).rejects.toThrow(OpenAI.NotFoundError); diff --git a/tests/api-resources/vector-stores/vector-stores.test.ts b/tests/api-resources/vector-stores/vector-stores.test.ts index be4b55209..857180043 100644 --- a/tests/api-resources/vector-stores/vector-stores.test.ts +++ b/tests/api-resources/vector-stores/vector-stores.test.ts @@ -56,7 +56,12 @@ describe('resource vectorStores', () => { // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error await expect( client.vectorStores.list( - { after: 'after', before: 'before', limit: 0, order: 'asc' }, + { + after: 'after', + before: 'before', + limit: 0, + order: 'asc', + }, { path: '/_stainless_unknown_path' }, ), ).rejects.toThrow(OpenAI.NotFoundError); @@ -87,7 +92,11 @@ describe('resource vectorStores', () => { test('search: required and optional params', async () => { const response = await client.vectorStores.search('vs_abc123', { query: 'string', - filters: { key: 'key', type: 'eq', value: 'string' }, + filters: { + key: 'key', + type: 'eq', + value: 'string', + }, max_num_results: 1, ranking_options: { ranker: 'none', score_threshold: 0 }, rewrite_query: true, diff --git a/tests/api-resources/videos.test.ts b/tests/api-resources/videos.test.ts index 0fb2e10de..abb71aa5a 100644 --- a/tests/api-resources/videos.test.ts +++ b/tests/api-resources/videos.test.ts @@ -54,7 +54,14 @@ describe('resource videos', () => { test('list: request options and params are passed correctly', async () => { // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error await expect( - client.videos.list({ after: 'after', limit: 0, order: 'asc' }, { path: '/_stainless_unknown_path' }), + client.videos.list( + { + after: 'after', + limit: 0, + order: 'asc', + }, + { path: '/_stainless_unknown_path' }, + ), ).rejects.toThrow(OpenAI.NotFoundError); }); diff --git a/tests/index.test.ts b/tests/index.test.ts index 661b28516..bafbbd4f6 100644 --- a/tests/index.test.ts +++ b/tests/index.test.ts @@ -87,7 +87,11 @@ describe('instantiate client', () => { error: jest.fn(), }; - const client = new OpenAI({ logger: logger, logLevel: 'debug', apiKey: 'My API Key' }); + const client = new OpenAI({ + logger: logger, + logLevel: 'debug', + apiKey: 'My API Key', + }); await forceAPIResponseForClient(client); expect(debugMock).toHaveBeenCalled(); @@ -107,7 +111,11 @@ describe('instantiate client', () => { error: jest.fn(), }; - const client = new OpenAI({ logger: logger, logLevel: 'info', apiKey: 'My API Key' }); + const client = new OpenAI({ + logger: logger, + logLevel: 'info', + apiKey: 'My API Key', + }); await forceAPIResponseForClient(client); expect(debugMock).not.toHaveBeenCalled(); @@ -157,7 +165,11 @@ describe('instantiate client', () => { }; process.env['OPENAI_LOG'] = 'debug'; - const client = new OpenAI({ logger: logger, logLevel: 'off', apiKey: 'My API Key' }); + const client = new OpenAI({ + logger: logger, + logLevel: 'off', + apiKey: 'My API Key', + }); await forceAPIResponseForClient(client); expect(debugMock).not.toHaveBeenCalled(); @@ -173,7 +185,11 @@ describe('instantiate client', () => { }; process.env['OPENAI_LOG'] = 'not a log level'; - const client = new OpenAI({ logger: logger, logLevel: 'debug', apiKey: 'My API Key' }); + const client = new OpenAI({ + logger: logger, + logLevel: 'debug', + apiKey: 'My API Key', + }); expect(client.logLevel).toBe('debug'); expect(warnMock).not.toHaveBeenCalled(); }); @@ -267,7 +283,11 @@ describe('instantiate client', () => { return new Response(JSON.stringify({}), { headers: { 'Content-Type': 'application/json' } }); }; - const client = new OpenAI({ baseURL: 'http://localhost:5000/', apiKey: 'My API Key', fetch: testFetch }); + const client = new OpenAI({ + baseURL: 'http://localhost:5000/', + apiKey: 'My API Key', + fetch: testFetch, + }); await client.patch('/foo'); expect(capturedRequest?.method).toEqual('PATCH'); @@ -345,7 +365,11 @@ describe('instantiate client', () => { describe('withOptions', () => { test('creates a new client with overridden options', async () => { - const client = new OpenAI({ baseURL: 'http://localhost:5000/', maxRetries: 3, apiKey: 'My API Key' }); + const client = new OpenAI({ + baseURL: 'http://localhost:5000/', + maxRetries: 3, + apiKey: 'My API Key', + }); const newClient = client.withOptions({ maxRetries: 5, @@ -385,7 +409,11 @@ describe('instantiate client', () => { }); test('respects runtime property changes when creating new client', () => { - const client = new OpenAI({ baseURL: 'http://localhost:5000/', timeout: 1000, apiKey: 'My API Key' }); + const client = new OpenAI({ + baseURL: 'http://localhost:5000/', + timeout: 1000, + apiKey: 'My API Key', + }); // Modify the client properties directly after creation client.baseURL = 'http://localhost:6000/'; @@ -531,7 +559,11 @@ describe('retries', () => { return new Response(JSON.stringify({ a: 1 }), { headers: { 'Content-Type': 'application/json' } }); }; - const client = new OpenAI({ apiKey: 'My API Key', timeout: 10, fetch: testFetch }); + const client = new OpenAI({ + apiKey: 'My API Key', + timeout: 10, + fetch: testFetch, + }); expect(await client.request({ path: '/foo', method: 'get' })).toEqual({ a: 1 }); expect(count).toEqual(2); @@ -561,7 +593,11 @@ describe('retries', () => { return new Response(JSON.stringify({ a: 1 }), { headers: { 'Content-Type': 'application/json' } }); }; - const client = new OpenAI({ apiKey: 'My API Key', fetch: testFetch, maxRetries: 4 }); + const client = new OpenAI({ + apiKey: 'My API Key', + fetch: testFetch, + maxRetries: 4, + }); expect(await client.request({ path: '/foo', method: 'get' })).toEqual({ a: 1 }); @@ -585,7 +621,11 @@ describe('retries', () => { capturedRequest = init; return new Response(JSON.stringify({ a: 1 }), { headers: { 'Content-Type': 'application/json' } }); }; - const client = new OpenAI({ apiKey: 'My API Key', fetch: testFetch, maxRetries: 4 }); + const client = new OpenAI({ + apiKey: 'My API Key', + fetch: testFetch, + maxRetries: 4, + }); expect( await client.request({ @@ -647,7 +687,11 @@ describe('retries', () => { capturedRequest = init; return new Response(JSON.stringify({ a: 1 }), { headers: { 'Content-Type': 'application/json' } }); }; - const client = new OpenAI({ apiKey: 'My API Key', fetch: testFetch, maxRetries: 4 }); + const client = new OpenAI({ + apiKey: 'My API Key', + fetch: testFetch, + maxRetries: 4, + }); expect( await client.request({