diff --git a/.release-please-manifest.json b/.release-please-manifest.json index df50ea851..a3a12f494 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "5.23.2" + ".": "6.0.0" } diff --git a/.stats.yml b/.stats.yml index 48863a6e9..10c939b22 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 118 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-410219ea680089f02bb55163c673919703f946c3d6ad7ff5d6f607121d5287d5.yml -openapi_spec_hash: 2b3eee95d3f6796c7a61dfddf694a59a -config_hash: 666d6bb4b564f0d9d431124b5d1a0665 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-49233088b5e73dbb96bf7af27be3d4547632e3db1c2b00f14184900613325bbc.yml +openapi_spec_hash: b34f14b141d5019244112901c5c7c2d8 +config_hash: 94e9ba08201c3d1ca46e093e6a0138fa diff --git a/CHANGELOG.md b/CHANGELOG.md index fa0a0b249..e1b1e3d3e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,22 @@ # Changelog +## 6.0.0 (2025-09-30) + +Full Changelog: [v5.23.2...v6.0.0](https://github.com/openai/openai-node/compare/v5.23.2...v6.0.0) + +### ⚠ BREAKING CHANGES + +* **api:** `ResponseFunctionToolCallOutputItem.output` and `ResponseCustomToolCallOutput.output` now return `string | Array` instead of `string` only. This may break existing callsites that assume `output` is always a string. + +### Features + +* **api:** Support images and files for function call outputs in responses, BatchUsage ([abe56f8](https://github.com/openai/openai-node/commit/abe56f86afdf28fc1a1b410ace1dd422672361a7)) + + +### Chores + +* compat with zod v4 ([#1658](https://github.com/openai/openai-node/issues/1658)) ([94569a0](https://github.com/openai/openai-node/commit/94569a07ce55317b0166e742b90a463df0f70e56)) + ## 5.23.2 (2025-09-29) Full Changelog: [v5.23.1...v5.23.2](https://github.com/openai/openai-node/compare/v5.23.1...v5.23.2) diff --git a/api.md b/api.md index 3a73f13f0..6316bfeb3 100644 --- a/api.md +++ b/api.md @@ -614,6 +614,7 @@ Types: - Batch - BatchError - BatchRequestCounts +- BatchUsage Methods: @@ -688,6 +689,8 @@ Types: - ResponseFormatTextJSONSchemaConfig - ResponseFunctionCallArgumentsDeltaEvent - ResponseFunctionCallArgumentsDoneEvent +- ResponseFunctionCallOutputItem +- ResponseFunctionCallOutputItemList - ResponseFunctionToolCall - ResponseFunctionToolCallItem - ResponseFunctionToolCallOutputItem @@ -703,11 +706,14 @@ Types: - ResponseInputAudio - ResponseInputContent - ResponseInputFile +- ResponseInputFileContent - ResponseInputImage +- ResponseInputImageContent - ResponseInputItem - ResponseInputMessageContentList - ResponseInputMessageItem - ResponseInputText +- ResponseInputTextContent - ResponseItem - ResponseMcpCallArgumentsDeltaEvent - ResponseMcpCallArgumentsDoneEvent diff --git a/examples/parsing-run-tools.ts b/examples/parsing-run-tools.ts index f94e932ad..f63758e3b 100644 --- a/examples/parsing-run-tools.ts +++ b/examples/parsing-run-tools.ts @@ -1,5 +1,5 @@ import OpenAI from 'openai'; -import z from 'zod'; +import z from 'zod/v3'; import { zodFunction } from 'openai/helpers/zod'; const Table = z.enum(['orders', 'customers', 'products']); diff --git a/examples/parsing-stream.ts b/examples/parsing-stream.ts index 08c95d91b..9a7e9863b 100644 --- a/examples/parsing-stream.ts +++ b/examples/parsing-stream.ts @@ -1,6 +1,6 @@ import { zodResponseFormat } from 'openai/helpers/zod'; import OpenAI from 'openai/index'; -import { z } from 'zod'; +import { z } from 'zod/v3'; const Step = z.object({ explanation: z.string(), diff --git a/examples/parsing-tools-stream.ts b/examples/parsing-tools-stream.ts index 971e22c40..54e97df7a 100644 --- a/examples/parsing-tools-stream.ts +++ b/examples/parsing-tools-stream.ts @@ -1,6 +1,6 @@ import { zodFunction } from 'openai/helpers/zod'; import OpenAI from 'openai/index'; -import { z } from 'zod'; +import { z } from 'zod/v3'; const GetWeatherArgs = z.object({ city: z.string(), diff --git a/examples/parsing-tools.ts b/examples/parsing-tools.ts index e570d8b6b..4fd466395 100644 --- a/examples/parsing-tools.ts +++ b/examples/parsing-tools.ts @@ -1,6 +1,6 @@ import { zodFunction } from 'openai/helpers/zod'; import OpenAI from 'openai/index'; -import { z } from 'zod'; +import { z } from 'zod/v3'; const Table = z.enum(['orders', 'customers', 'products']); diff --git a/examples/parsing.ts b/examples/parsing.ts index 3e71f74f3..1290b074c 100644 --- a/examples/parsing.ts +++ b/examples/parsing.ts @@ -1,6 +1,6 @@ import { zodResponseFormat } from 'openai/helpers/zod'; import OpenAI from 'openai/index'; -import { z } from 'zod'; +import { z } from 'zod/v3'; const Step = z.object({ explanation: z.string(), diff --git a/examples/responses/streaming-tools.ts b/examples/responses/streaming-tools.ts index 87a48d0c3..b62a4edc0 100755 --- a/examples/responses/streaming-tools.ts +++ b/examples/responses/streaming-tools.ts @@ -2,7 +2,7 @@ import { OpenAI } from 'openai'; import { zodResponsesFunction } from 'openai/helpers/zod'; -import { z } from 'zod'; +import { z } from 'zod/v3'; const Table = z.enum(['orders', 'customers', 'products']); const Column = z.enum([ diff --git a/examples/responses/structured-outputs-tools.ts b/examples/responses/structured-outputs-tools.ts index 29eaabf93..9605fd6eb 100755 --- a/examples/responses/structured-outputs-tools.ts +++ b/examples/responses/structured-outputs-tools.ts @@ -2,7 +2,7 @@ import { OpenAI } from 'openai'; import { zodResponsesFunction } from 'openai/helpers/zod'; -import { z } from 'zod'; +import { z } from 'zod/v3'; const Table = z.enum(['orders', 'customers', 'products']); const Column = z.enum([ diff --git a/examples/responses/structured-outputs.ts b/examples/responses/structured-outputs.ts index 07ff93a60..e1de6f219 100755 --- a/examples/responses/structured-outputs.ts +++ b/examples/responses/structured-outputs.ts @@ -2,7 +2,7 @@ import { OpenAI } from 'openai'; import { zodTextFormat } from 'openai/helpers/zod'; -import { z } from 'zod'; +import { z } from 'zod/v3'; const Step = z.object({ explanation: z.string(), diff --git a/examples/tool-call-helpers-zod.ts b/examples/tool-call-helpers-zod.ts index b4e1aedcf..162b54946 100755 --- a/examples/tool-call-helpers-zod.ts +++ b/examples/tool-call-helpers-zod.ts @@ -2,7 +2,7 @@ import OpenAI from 'openai'; import { zodFunction } from 'openai/helpers/zod'; -import { z } from 'zod'; +import { z } from 'zod/v3'; // gets API Key from environment variable OPENAI_API_KEY const openai = new OpenAI(); diff --git a/examples/ui-generation.ts b/examples/ui-generation.ts index 003bb7568..4e61e1f17 100644 --- a/examples/ui-generation.ts +++ b/examples/ui-generation.ts @@ -1,5 +1,5 @@ import OpenAI from 'openai'; -import { z } from 'zod'; +import { z } from 'zod/v3'; import { zodResponseFormat } from 'openai/helpers/zod'; const openai = new OpenAI(); diff --git a/helpers.md b/helpers.md index 0ed2abb4c..268a0abe9 100644 --- a/helpers.md +++ b/helpers.md @@ -13,7 +13,7 @@ into a JSON schema, send it to the API and parse the response content back using ```ts import { zodResponseFormat } from 'openai/helpers/zod'; import OpenAI from 'openai/index'; -import { z } from 'zod'; +import { z } from 'zod/v3'; const Step = z.object({ explanation: z.string(), @@ -57,7 +57,7 @@ For example: ```ts import { zodFunction } from 'openai/helpers/zod'; import OpenAI from 'openai/index'; -import { z } from 'zod'; +import { z } from 'zod/v3'; const Table = z.enum(['orders', 'customers', 'products']); @@ -630,7 +630,7 @@ assistant's response to make sure it conforms to a schema. Paired with [`zod-to- ```ts import OpenAI from 'openai'; -import { z } from 'zod'; +import { z } from 'zod/v3'; import { zodToJsonSchema } from 'zod-to-json-schema'; const client = new OpenAI(); diff --git a/jsr.json b/jsr.json index b7656aeab..243fc71b7 100644 --- a/jsr.json +++ b/jsr.json @@ -1,6 +1,6 @@ { "name": "@openai/openai", - "version": "5.23.2", + "version": "6.0.0", "exports": { ".": "./index.ts", "./helpers/zod": "./helpers/zod.ts", diff --git a/package.json b/package.json index 8f54e60a0..b5e07eeee 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "openai", - "version": "5.23.2", + "version": "6.0.0", "description": "The official TypeScript library for the OpenAI API", "author": "OpenAI ", "types": "dist/index.d.ts", @@ -52,7 +52,7 @@ "tslib": "^2.8.1", "typescript": "5.8.3", "ws": "^8.18.0", - "zod": "^3.23.8", + "zod": "^3.25 || ^4.0", "typescript-eslint": "8.31.1" }, "bin": { @@ -76,7 +76,7 @@ }, "peerDependencies": { "ws": "^8.18.0", - "zod": "^3.23.8" + "zod": "^3.25 || ^4.0" }, "peerDependenciesMeta": { "ws": { diff --git a/src/_vendor/zod-to-json-schema/Options.ts b/src/_vendor/zod-to-json-schema/Options.ts index a9abfc0e2..74895559c 100644 --- a/src/_vendor/zod-to-json-schema/Options.ts +++ b/src/_vendor/zod-to-json-schema/Options.ts @@ -1,4 +1,4 @@ -import { ZodSchema, ZodTypeDef } from 'zod'; +import { ZodSchema, ZodTypeDef } from 'zod/v3'; import { Refs, Seen } from './Refs'; import { JsonSchema7Type } from './parseDef'; diff --git a/src/_vendor/zod-to-json-schema/Refs.ts b/src/_vendor/zod-to-json-schema/Refs.ts index ea63c076a..b9720476a 100644 --- a/src/_vendor/zod-to-json-schema/Refs.ts +++ b/src/_vendor/zod-to-json-schema/Refs.ts @@ -1,4 +1,4 @@ -import type { ZodTypeDef } from 'zod'; +import type { ZodTypeDef } from 'zod/v3'; import { getDefaultOptions, Options, Targets } from './Options'; import { JsonSchema7Type } from './parseDef'; import { zodDef } from './util'; diff --git a/src/_vendor/zod-to-json-schema/parseDef.ts b/src/_vendor/zod-to-json-schema/parseDef.ts index 8af5ce4be..f4dd747ca 100644 --- a/src/_vendor/zod-to-json-schema/parseDef.ts +++ b/src/_vendor/zod-to-json-schema/parseDef.ts @@ -1,4 +1,4 @@ -import { ZodFirstPartyTypeKind, ZodTypeDef } from 'zod'; +import { ZodFirstPartyTypeKind, ZodTypeDef } from 'zod/v3'; import { JsonSchema7AnyType, parseAnyDef } from './parsers/any'; import { JsonSchema7ArrayType, parseArrayDef } from './parsers/array'; import { JsonSchema7BigintType, parseBigintDef } from './parsers/bigint'; diff --git a/src/_vendor/zod-to-json-schema/parsers/array.ts b/src/_vendor/zod-to-json-schema/parsers/array.ts index 3e8578f8b..9a90338a3 100644 --- a/src/_vendor/zod-to-json-schema/parsers/array.ts +++ b/src/_vendor/zod-to-json-schema/parsers/array.ts @@ -1,4 +1,4 @@ -import { ZodArrayDef, ZodFirstPartyTypeKind } from 'zod'; +import { ZodArrayDef, ZodFirstPartyTypeKind } from 'zod/v3'; import { ErrorMessages, setResponseValueAndErrors } from '../errorMessages'; import { JsonSchema7Type, parseDef } from '../parseDef'; import { Refs } from '../Refs'; diff --git a/src/_vendor/zod-to-json-schema/parsers/bigint.ts b/src/_vendor/zod-to-json-schema/parsers/bigint.ts index f46784184..7048b1444 100644 --- a/src/_vendor/zod-to-json-schema/parsers/bigint.ts +++ b/src/_vendor/zod-to-json-schema/parsers/bigint.ts @@ -1,4 +1,4 @@ -import { ZodBigIntDef } from 'zod'; +import { ZodBigIntDef } from 'zod/v3'; import { Refs } from '../Refs'; import { ErrorMessages, setResponseValueAndErrors } from '../errorMessages'; diff --git a/src/_vendor/zod-to-json-schema/parsers/branded.ts b/src/_vendor/zod-to-json-schema/parsers/branded.ts index 2242580a5..c585f2d93 100644 --- a/src/_vendor/zod-to-json-schema/parsers/branded.ts +++ b/src/_vendor/zod-to-json-schema/parsers/branded.ts @@ -1,4 +1,4 @@ -import { ZodBrandedDef } from 'zod'; +import { ZodBrandedDef } from 'zod/v3'; import { parseDef } from '../parseDef'; import { Refs } from '../Refs'; diff --git a/src/_vendor/zod-to-json-schema/parsers/catch.ts b/src/_vendor/zod-to-json-schema/parsers/catch.ts index 5cce3afa1..f4f196408 100644 --- a/src/_vendor/zod-to-json-schema/parsers/catch.ts +++ b/src/_vendor/zod-to-json-schema/parsers/catch.ts @@ -1,4 +1,4 @@ -import { ZodCatchDef } from 'zod'; +import { ZodCatchDef } from 'zod/v3'; import { parseDef } from '../parseDef'; import { Refs } from '../Refs'; diff --git a/src/_vendor/zod-to-json-schema/parsers/date.ts b/src/_vendor/zod-to-json-schema/parsers/date.ts index 4afc4e8dc..19168f46f 100644 --- a/src/_vendor/zod-to-json-schema/parsers/date.ts +++ b/src/_vendor/zod-to-json-schema/parsers/date.ts @@ -1,4 +1,4 @@ -import { ZodDateDef } from 'zod'; +import { ZodDateDef } from 'zod/v3'; import { Refs } from '../Refs'; import { ErrorMessages, setResponseValueAndErrors } from '../errorMessages'; import { JsonSchema7NumberType } from './number'; diff --git a/src/_vendor/zod-to-json-schema/parsers/default.ts b/src/_vendor/zod-to-json-schema/parsers/default.ts index f71726075..2c705d5fa 100644 --- a/src/_vendor/zod-to-json-schema/parsers/default.ts +++ b/src/_vendor/zod-to-json-schema/parsers/default.ts @@ -1,4 +1,4 @@ -import { ZodDefaultDef } from 'zod'; +import { ZodDefaultDef } from 'zod/v3'; import { JsonSchema7Type, parseDef } from '../parseDef'; import { Refs } from '../Refs'; diff --git a/src/_vendor/zod-to-json-schema/parsers/effects.ts b/src/_vendor/zod-to-json-schema/parsers/effects.ts index b010d5c47..5b9f70365 100644 --- a/src/_vendor/zod-to-json-schema/parsers/effects.ts +++ b/src/_vendor/zod-to-json-schema/parsers/effects.ts @@ -1,4 +1,4 @@ -import { ZodEffectsDef } from 'zod'; +import { ZodEffectsDef } from 'zod/v3'; import { JsonSchema7Type, parseDef } from '../parseDef'; import { Refs } from '../Refs'; diff --git a/src/_vendor/zod-to-json-schema/parsers/enum.ts b/src/_vendor/zod-to-json-schema/parsers/enum.ts index d6f5ceb24..ed459f33f 100644 --- a/src/_vendor/zod-to-json-schema/parsers/enum.ts +++ b/src/_vendor/zod-to-json-schema/parsers/enum.ts @@ -1,4 +1,4 @@ -import { ZodEnumDef } from 'zod'; +import { ZodEnumDef } from 'zod/v3'; export type JsonSchema7EnumType = { type: 'string'; diff --git a/src/_vendor/zod-to-json-schema/parsers/intersection.ts b/src/_vendor/zod-to-json-schema/parsers/intersection.ts index af5f0421d..abf5016d5 100644 --- a/src/_vendor/zod-to-json-schema/parsers/intersection.ts +++ b/src/_vendor/zod-to-json-schema/parsers/intersection.ts @@ -1,4 +1,4 @@ -import { ZodIntersectionDef } from 'zod'; +import { ZodIntersectionDef } from 'zod/v3'; import { JsonSchema7Type, parseDef } from '../parseDef'; import { Refs } from '../Refs'; import { JsonSchema7StringType } from './string'; diff --git a/src/_vendor/zod-to-json-schema/parsers/literal.ts b/src/_vendor/zod-to-json-schema/parsers/literal.ts index a35625cfc..70f549858 100644 --- a/src/_vendor/zod-to-json-schema/parsers/literal.ts +++ b/src/_vendor/zod-to-json-schema/parsers/literal.ts @@ -1,4 +1,4 @@ -import { ZodLiteralDef } from 'zod'; +import { ZodLiteralDef } from 'zod/v3'; import { Refs } from '../Refs'; export type JsonSchema7LiteralType = diff --git a/src/_vendor/zod-to-json-schema/parsers/map.ts b/src/_vendor/zod-to-json-schema/parsers/map.ts index 5084ccd68..58c9c0dad 100644 --- a/src/_vendor/zod-to-json-schema/parsers/map.ts +++ b/src/_vendor/zod-to-json-schema/parsers/map.ts @@ -1,4 +1,4 @@ -import { ZodMapDef } from 'zod'; +import { ZodMapDef } from 'zod/v3'; import { JsonSchema7Type, parseDef } from '../parseDef'; import { Refs } from '../Refs'; import { JsonSchema7RecordType, parseRecordDef } from './record'; diff --git a/src/_vendor/zod-to-json-schema/parsers/nativeEnum.ts b/src/_vendor/zod-to-json-schema/parsers/nativeEnum.ts index a2ed901bb..e3539883b 100644 --- a/src/_vendor/zod-to-json-schema/parsers/nativeEnum.ts +++ b/src/_vendor/zod-to-json-schema/parsers/nativeEnum.ts @@ -1,4 +1,4 @@ -import { ZodNativeEnumDef } from 'zod'; +import { ZodNativeEnumDef } from 'zod/v3'; export type JsonSchema7NativeEnumType = { type: 'string' | 'number' | ['string', 'number']; diff --git a/src/_vendor/zod-to-json-schema/parsers/nullable.ts b/src/_vendor/zod-to-json-schema/parsers/nullable.ts index 0d7063610..aed1b8722 100644 --- a/src/_vendor/zod-to-json-schema/parsers/nullable.ts +++ b/src/_vendor/zod-to-json-schema/parsers/nullable.ts @@ -1,4 +1,4 @@ -import { ZodNullableDef } from 'zod'; +import { ZodNullableDef } from 'zod/v3'; import { JsonSchema7Type, parseDef } from '../parseDef'; import { Refs } from '../Refs'; import { JsonSchema7NullType } from './null'; diff --git a/src/_vendor/zod-to-json-schema/parsers/number.ts b/src/_vendor/zod-to-json-schema/parsers/number.ts index 45a1f3c02..343e1dfa6 100644 --- a/src/_vendor/zod-to-json-schema/parsers/number.ts +++ b/src/_vendor/zod-to-json-schema/parsers/number.ts @@ -1,4 +1,4 @@ -import { ZodNumberDef } from 'zod'; +import { ZodNumberDef } from 'zod/v3'; import { addErrorMessage, ErrorMessages, setResponseValueAndErrors } from '../errorMessages'; import { Refs } from '../Refs'; diff --git a/src/_vendor/zod-to-json-schema/parsers/object.ts b/src/_vendor/zod-to-json-schema/parsers/object.ts index 1335c6dd0..943b02620 100644 --- a/src/_vendor/zod-to-json-schema/parsers/object.ts +++ b/src/_vendor/zod-to-json-schema/parsers/object.ts @@ -1,4 +1,4 @@ -import { ZodObjectDef } from 'zod'; +import { ZodObjectDef } from 'zod/v3'; import { JsonSchema7Type, parseDef } from '../parseDef'; import { Refs } from '../Refs'; diff --git a/src/_vendor/zod-to-json-schema/parsers/optional.ts b/src/_vendor/zod-to-json-schema/parsers/optional.ts index 6948d7c51..dbaab348e 100644 --- a/src/_vendor/zod-to-json-schema/parsers/optional.ts +++ b/src/_vendor/zod-to-json-schema/parsers/optional.ts @@ -1,4 +1,4 @@ -import { ZodOptionalDef } from 'zod'; +import { ZodOptionalDef } from 'zod/v3'; import { JsonSchema7Type, parseDef } from '../parseDef'; import { Refs } from '../Refs'; diff --git a/src/_vendor/zod-to-json-schema/parsers/pipeline.ts b/src/_vendor/zod-to-json-schema/parsers/pipeline.ts index 7fdcbae02..e29bb581f 100644 --- a/src/_vendor/zod-to-json-schema/parsers/pipeline.ts +++ b/src/_vendor/zod-to-json-schema/parsers/pipeline.ts @@ -1,4 +1,4 @@ -import { ZodPipelineDef } from 'zod'; +import { ZodPipelineDef } from 'zod/v3'; import { JsonSchema7Type, parseDef } from '../parseDef'; import { Refs } from '../Refs'; import { JsonSchema7AllOfType } from './intersection'; diff --git a/src/_vendor/zod-to-json-schema/parsers/promise.ts b/src/_vendor/zod-to-json-schema/parsers/promise.ts index f586d1139..f25445a2c 100644 --- a/src/_vendor/zod-to-json-schema/parsers/promise.ts +++ b/src/_vendor/zod-to-json-schema/parsers/promise.ts @@ -1,4 +1,4 @@ -import { ZodPromiseDef } from 'zod'; +import { ZodPromiseDef } from 'zod/v3'; import { JsonSchema7Type, parseDef } from '../parseDef'; import { Refs } from '../Refs'; diff --git a/src/_vendor/zod-to-json-schema/parsers/readonly.ts b/src/_vendor/zod-to-json-schema/parsers/readonly.ts index cecb937d3..a2c873d3c 100644 --- a/src/_vendor/zod-to-json-schema/parsers/readonly.ts +++ b/src/_vendor/zod-to-json-schema/parsers/readonly.ts @@ -1,4 +1,4 @@ -import { ZodReadonlyDef } from 'zod'; +import { ZodReadonlyDef } from 'zod/v3'; import { parseDef } from '../parseDef'; import { Refs } from '../Refs'; diff --git a/src/_vendor/zod-to-json-schema/parsers/record.ts b/src/_vendor/zod-to-json-schema/parsers/record.ts index 7eff507fb..409297236 100644 --- a/src/_vendor/zod-to-json-schema/parsers/record.ts +++ b/src/_vendor/zod-to-json-schema/parsers/record.ts @@ -1,4 +1,4 @@ -import { ZodFirstPartyTypeKind, ZodMapDef, ZodRecordDef, ZodTypeAny } from 'zod'; +import { ZodFirstPartyTypeKind, ZodMapDef, ZodRecordDef, ZodTypeAny } from 'zod/v3'; import { JsonSchema7Type, parseDef } from '../parseDef'; import { Refs } from '../Refs'; import { JsonSchema7EnumType } from './enum'; diff --git a/src/_vendor/zod-to-json-schema/parsers/set.ts b/src/_vendor/zod-to-json-schema/parsers/set.ts index 05fa9ed79..0bd64fbe2 100644 --- a/src/_vendor/zod-to-json-schema/parsers/set.ts +++ b/src/_vendor/zod-to-json-schema/parsers/set.ts @@ -1,4 +1,4 @@ -import { ZodSetDef } from 'zod'; +import { ZodSetDef } from 'zod/v3'; import { ErrorMessages, setResponseValueAndErrors } from '../errorMessages'; import { JsonSchema7Type, parseDef } from '../parseDef'; import { Refs } from '../Refs'; diff --git a/src/_vendor/zod-to-json-schema/parsers/string.ts b/src/_vendor/zod-to-json-schema/parsers/string.ts index daa1a954a..636a7b1d4 100644 --- a/src/_vendor/zod-to-json-schema/parsers/string.ts +++ b/src/_vendor/zod-to-json-schema/parsers/string.ts @@ -1,5 +1,5 @@ // @ts-nocheck -import { ZodStringDef } from 'zod'; +import { ZodStringDef } from 'zod/v3'; import { ErrorMessages, setResponseValueAndErrors } from '../errorMessages'; import { Refs } from '../Refs'; diff --git a/src/_vendor/zod-to-json-schema/parsers/tuple.ts b/src/_vendor/zod-to-json-schema/parsers/tuple.ts index b2a824006..1e7ab3194 100644 --- a/src/_vendor/zod-to-json-schema/parsers/tuple.ts +++ b/src/_vendor/zod-to-json-schema/parsers/tuple.ts @@ -1,4 +1,4 @@ -import { ZodTupleDef, ZodTupleItems, ZodTypeAny } from 'zod'; +import { ZodTupleDef, ZodTupleItems, ZodTypeAny } from 'zod/v3'; import { JsonSchema7Type, parseDef } from '../parseDef'; import { Refs } from '../Refs'; diff --git a/src/_vendor/zod-to-json-schema/parsers/union.ts b/src/_vendor/zod-to-json-schema/parsers/union.ts index 1daf14908..9ca538a69 100644 --- a/src/_vendor/zod-to-json-schema/parsers/union.ts +++ b/src/_vendor/zod-to-json-schema/parsers/union.ts @@ -1,4 +1,4 @@ -import { ZodDiscriminatedUnionDef, ZodLiteralDef, ZodTypeAny, ZodUnionDef } from 'zod'; +import { ZodDiscriminatedUnionDef, ZodLiteralDef, ZodTypeAny, ZodUnionDef } from 'zod/v3'; import { JsonSchema7Type, parseDef } from '../parseDef'; import { Refs } from '../Refs'; diff --git a/src/_vendor/zod-to-json-schema/util.ts b/src/_vendor/zod-to-json-schema/util.ts index 870ab47a2..1c2f50105 100644 --- a/src/_vendor/zod-to-json-schema/util.ts +++ b/src/_vendor/zod-to-json-schema/util.ts @@ -1,4 +1,4 @@ -import type { ZodSchema, ZodTypeDef } from 'zod'; +import type { ZodSchema, ZodTypeDef } from 'zod/v3'; export const zodDef = (zodSchema: ZodSchema | ZodTypeDef): ZodTypeDef => { return '_def' in zodSchema ? zodSchema._def : zodSchema; diff --git a/src/_vendor/zod-to-json-schema/zodToJsonSchema.ts b/src/_vendor/zod-to-json-schema/zodToJsonSchema.ts index e0d63d525..e4a880390 100644 --- a/src/_vendor/zod-to-json-schema/zodToJsonSchema.ts +++ b/src/_vendor/zod-to-json-schema/zodToJsonSchema.ts @@ -1,4 +1,4 @@ -import { ZodSchema } from 'zod'; +import { ZodSchema } from 'zod/v3'; import { Options, Targets } from './Options'; import { JsonSchema7Type, parseDef } from './parseDef'; import { getRefs } from './Refs'; diff --git a/src/client.ts b/src/client.ts index b3c899b44..d77a85ba4 100644 --- a/src/client.ts +++ b/src/client.ts @@ -32,6 +32,7 @@ import { BatchError, BatchListParams, BatchRequestCounts, + BatchUsage, Batches, BatchesPage, } from './resources/batches'; @@ -1190,6 +1191,7 @@ export declare namespace OpenAI { type Batch as Batch, type BatchError as BatchError, type BatchRequestCounts as BatchRequestCounts, + type BatchUsage as BatchUsage, type BatchesPage as BatchesPage, type BatchCreateParams as BatchCreateParams, type BatchListParams as BatchListParams, diff --git a/src/helpers/zod.ts b/src/helpers/zod.ts index d12e7f3ca..6495cc99d 100644 --- a/src/helpers/zod.ts +++ b/src/helpers/zod.ts @@ -1,5 +1,5 @@ import { ResponseFormatJSONSchema } from '../resources/index'; -import type { infer as zodInfer, ZodType } from 'zod'; +import type { infer as zodInfer, ZodType } from 'zod/v3'; import { AutoParseableResponseFormat, AutoParseableTextFormat, diff --git a/src/resources/batches.ts b/src/resources/batches.ts index 1bd5c0f7c..ca3989ef4 100644 --- a/src/resources/batches.ts +++ b/src/resources/batches.ts @@ -143,6 +143,15 @@ export interface Batch { */ metadata?: Shared.Metadata | null; + /** + * Model ID used to process the batch, like `gpt-5-2025-08-07`. OpenAI offers a + * wide range of models with different capabilities, performance characteristics, + * and price points. Refer to the + * [model guide](https://platform.openai.com/docs/models) to browse and compare + * available models. + */ + model?: string; + /** * The ID of the file containing the outputs of successfully executed requests. */ @@ -152,6 +161,13 @@ export interface Batch { * The request counts for different statuses within the batch. */ request_counts?: BatchRequestCounts; + + /** + * Represents token usage details including input tokens, output tokens, a + * breakdown of output tokens, and the total tokens used. Only populated on batches + * created after September 7, 2025. + */ + usage?: BatchUsage; } export namespace Batch { @@ -207,6 +223,61 @@ export interface BatchRequestCounts { total: number; } +/** + * Represents token usage details including input tokens, output tokens, a + * breakdown of output tokens, and the total tokens used. Only populated on batches + * created after September 7, 2025. + */ +export interface BatchUsage { + /** + * The number of input tokens. + */ + input_tokens: number; + + /** + * A detailed breakdown of the input tokens. + */ + input_tokens_details: BatchUsage.InputTokensDetails; + + /** + * The number of output tokens. + */ + output_tokens: number; + + /** + * A detailed breakdown of the output tokens. + */ + output_tokens_details: BatchUsage.OutputTokensDetails; + + /** + * The total number of tokens used. + */ + total_tokens: number; +} + +export namespace BatchUsage { + /** + * A detailed breakdown of the input tokens. + */ + export interface InputTokensDetails { + /** + * The number of tokens that were retrieved from the cache. + * [More on prompt caching](https://platform.openai.com/docs/guides/prompt-caching). + */ + cached_tokens: number; + } + + /** + * A detailed breakdown of the output tokens. + */ + export interface OutputTokensDetails { + /** + * The number of reasoning tokens. + */ + reasoning_tokens: number; + } +} + export interface BatchCreateParams { /** * The time frame within which the batch should be processed. Currently only `24h` @@ -280,6 +351,7 @@ export declare namespace Batches { type Batch as Batch, type BatchError as BatchError, type BatchRequestCounts as BatchRequestCounts, + type BatchUsage as BatchUsage, type BatchesPage as BatchesPage, type BatchCreateParams as BatchCreateParams, type BatchListParams as BatchListParams, diff --git a/src/resources/index.ts b/src/resources/index.ts index fbbc0e3bb..5164f863d 100644 --- a/src/resources/index.ts +++ b/src/resources/index.ts @@ -8,6 +8,7 @@ export { type Batch, type BatchError, type BatchRequestCounts, + type BatchUsage, type BatchCreateParams, type BatchListParams, type BatchesPage, diff --git a/src/resources/responses/responses.ts b/src/resources/responses/responses.ts index dca13a9bb..01f3ca399 100644 --- a/src/resources/responses/responses.ts +++ b/src/resources/responses/responses.ts @@ -1536,9 +1536,10 @@ export interface ResponseCustomToolCallOutput { call_id: string; /** - * The output from the custom tool call generated by your code. + * The output from the custom tool call generated by your code. Can be a string or + * an list of output content. */ - output: string; + output: string | Array; /** * The type of the custom tool call output. Always `custom_tool_call_output`. @@ -1878,6 +1879,11 @@ export interface ResponseFunctionCallArgumentsDoneEvent { */ item_id: string; + /** + * The name of the function that was called. + */ + name: string; + /** * The index of the output item. */ @@ -1891,6 +1897,16 @@ export interface ResponseFunctionCallArgumentsDoneEvent { type: 'response.function_call_arguments.done'; } +/** + * A text input to the model. + */ +export type ResponseFunctionCallOutputItem = + | ResponseInputTextContent + | ResponseInputImageContent + | ResponseInputFileContent; + +export type ResponseFunctionCallOutputItemList = Array; + /** * A tool call to run a function. See the * [function calling guide](https://platform.openai.com/docs/guides/function-calling) @@ -1953,9 +1969,10 @@ export interface ResponseFunctionToolCallOutputItem { call_id: string; /** - * A JSON string of the output of the function tool call. + * The output from the function call generated by your code. Can be a string or an + * list of output content. */ - output: string; + output: string | Array; /** * The type of the function tool call output. Always `function_call_output`. @@ -2319,6 +2336,36 @@ export interface ResponseInputFile { filename?: string; } +/** + * A file input to the model. + */ +export interface ResponseInputFileContent { + /** + * The type of the input item. Always `input_file`. + */ + type: 'input_file'; + + /** + * The base64-encoded data of the file to be sent to the model. + */ + file_data?: string | null; + + /** + * The ID of the file to be sent to the model. + */ + file_id?: string | null; + + /** + * The URL of the file to be sent to the model. + */ + file_url?: string | null; + + /** + * The name of the file to be sent to the model. + */ + filename?: string | null; +} + /** * An image input to the model. Learn about * [image inputs](https://platform.openai.com/docs/guides/vision). @@ -2347,6 +2394,34 @@ export interface ResponseInputImage { image_url?: string | null; } +/** + * An image input to the model. Learn about + * [image inputs](https://platform.openai.com/docs/guides/vision) + */ +export interface ResponseInputImageContent { + /** + * The type of the input item. Always `input_image`. + */ + type: 'input_image'; + + /** + * The detail level of the image to be sent to the model. One of `high`, `low`, or + * `auto`. Defaults to `auto`. + */ + detail?: 'low' | 'high' | 'auto' | null; + + /** + * The ID of the file to be sent to the model. + */ + file_id?: string | null; + + /** + * The URL of the image to be sent to the model. A fully qualified URL or base64 + * encoded image in a data URL. + */ + image_url?: string | null; +} + /** * A message input to the model with a role indicating instruction following * hierarchy. Instructions given with the `developer` or `system` role take @@ -2476,9 +2551,9 @@ export namespace ResponseInputItem { call_id: string; /** - * A JSON string of the output of the function tool call. + * Text, image, or file output of the function tool call. */ - output: string; + output: string | ResponsesAPI.ResponseFunctionCallOutputItemList; /** * The type of the function tool call output. Always `function_call_output`. @@ -2838,6 +2913,21 @@ export interface ResponseInputText { type: 'input_text'; } +/** + * A text input to the model. + */ +export interface ResponseInputTextContent { + /** + * The text input to the model. + */ + text: string; + + /** + * The type of the input item. Always `input_text`. + */ + type: 'input_text'; +} + /** * Content item used to generate a response. */ @@ -5684,6 +5774,8 @@ export declare namespace Responses { type ResponseFormatTextJSONSchemaConfig as ResponseFormatTextJSONSchemaConfig, type ResponseFunctionCallArgumentsDeltaEvent as ResponseFunctionCallArgumentsDeltaEvent, type ResponseFunctionCallArgumentsDoneEvent as ResponseFunctionCallArgumentsDoneEvent, + type ResponseFunctionCallOutputItem as ResponseFunctionCallOutputItem, + type ResponseFunctionCallOutputItemList as ResponseFunctionCallOutputItemList, type ResponseFunctionToolCall as ResponseFunctionToolCall, type ResponseFunctionToolCallItem as ResponseFunctionToolCallItem, type ResponseFunctionToolCallOutputItem as ResponseFunctionToolCallOutputItem, @@ -5699,11 +5791,14 @@ export declare namespace Responses { type ResponseInputAudio as ResponseInputAudio, type ResponseInputContent as ResponseInputContent, type ResponseInputFile as ResponseInputFile, + type ResponseInputFileContent as ResponseInputFileContent, type ResponseInputImage as ResponseInputImage, + type ResponseInputImageContent as ResponseInputImageContent, type ResponseInputItem as ResponseInputItem, type ResponseInputMessageContentList as ResponseInputMessageContentList, type ResponseInputMessageItem as ResponseInputMessageItem, type ResponseInputText as ResponseInputText, + type ResponseInputTextContent as ResponseInputTextContent, type ResponseItem as ResponseItem, type ResponseMcpCallArgumentsDeltaEvent as ResponseMcpCallArgumentsDeltaEvent, type ResponseMcpCallArgumentsDoneEvent as ResponseMcpCallArgumentsDoneEvent, diff --git a/src/version.ts b/src/version.ts index 57823047d..1fbec37ea 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export const VERSION = '5.23.2'; // x-release-please-version +export const VERSION = '6.0.0'; // x-release-please-version diff --git a/tests/helpers/zod.test.ts b/tests/helpers/zod.test.ts index eb56ca778..62a8e9162 100644 --- a/tests/helpers/zod.test.ts +++ b/tests/helpers/zod.test.ts @@ -1,5 +1,5 @@ import { zodResponseFormat } from 'openai/helpers/zod'; -import { z } from 'zod'; +import { z } from 'zod/v3'; describe('zodResponseFormat', () => { it('does the thing', () => { diff --git a/tests/lib/ChatCompletionStream.test.ts b/tests/lib/ChatCompletionStream.test.ts index 2a679e06a..790736bc0 100644 --- a/tests/lib/ChatCompletionStream.test.ts +++ b/tests/lib/ChatCompletionStream.test.ts @@ -1,6 +1,6 @@ import { zodResponseFormat } from 'openai/helpers/zod'; import { ChatCompletionTokenLogprob } from 'openai/resources'; -import { z } from 'zod'; +import { z } from 'zod/v3'; import { makeStreamSnapshotRequest } from '../utils/mock-snapshots'; jest.setTimeout(1000 * 30); diff --git a/tests/lib/parser.test.ts b/tests/lib/parser.test.ts index 74cca7253..70d3ec8c6 100644 --- a/tests/lib/parser.test.ts +++ b/tests/lib/parser.test.ts @@ -1,4 +1,4 @@ -import { z } from 'zod'; +import { z } from 'zod/v3'; import { zodResponseFormat } from 'openai/helpers/zod'; import { makeSnapshotRequest } from '../utils/mock-snapshots'; diff --git a/yarn.lock b/yarn.lock index c4d9f2da1..6c1e8b378 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3523,7 +3523,7 @@ yocto-queue@^0.1.0: resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b" integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q== -zod@^3.23.8: - version "3.24.1" - resolved "https://registry.yarnpkg.com/zod/-/zod-3.24.1.tgz#27445c912738c8ad1e9de1bea0359fa44d9d35ee" - integrity sha512-muH7gBL9sI1nciMZV67X5fTKKBLtwpZ5VBp1vsOQzj1MhrBZ4wlVCm3gedKZWLp0Oyel8sIGfeiz54Su+OVT+A== +"zod@^3.25 || ^4.0": + version "4.1.11" + resolved "https://registry.yarnpkg.com/zod/-/zod-4.1.11.tgz#4aab62f76cfd45e6c6166519ba31b2ea019f75f5" + integrity sha512-WPsqwxITS2tzx1bzhIKsEs19ABD5vmCVa4xBo2tq/SrV4RNZtfws1EnCWQXM6yh8bD08a1idvkB5MZSBiZsjwg==