Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "5.23.2"
".": "6.0.0"
}
6 changes: 3 additions & 3 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -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
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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<ResponseInputText | ResponseInputImage | ResponseInputFile>` 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)
Expand Down
6 changes: 6 additions & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,7 @@ Types:
- <code><a href="./src/resources/batches.ts">Batch</a></code>
- <code><a href="./src/resources/batches.ts">BatchError</a></code>
- <code><a href="./src/resources/batches.ts">BatchRequestCounts</a></code>
- <code><a href="./src/resources/batches.ts">BatchUsage</a></code>

Methods:

Expand Down Expand Up @@ -688,6 +689,8 @@ Types:
- <code><a href="./src/resources/responses/responses.ts">ResponseFormatTextJSONSchemaConfig</a></code>
- <code><a href="./src/resources/responses/responses.ts">ResponseFunctionCallArgumentsDeltaEvent</a></code>
- <code><a href="./src/resources/responses/responses.ts">ResponseFunctionCallArgumentsDoneEvent</a></code>
- <code><a href="./src/resources/responses/responses.ts">ResponseFunctionCallOutputItem</a></code>
- <code><a href="./src/resources/responses/responses.ts">ResponseFunctionCallOutputItemList</a></code>
- <code><a href="./src/resources/responses/responses.ts">ResponseFunctionToolCall</a></code>
- <code><a href="./src/resources/responses/responses.ts">ResponseFunctionToolCallItem</a></code>
- <code><a href="./src/resources/responses/responses.ts">ResponseFunctionToolCallOutputItem</a></code>
Expand All @@ -703,11 +706,14 @@ Types:
- <code><a href="./src/resources/responses/responses.ts">ResponseInputAudio</a></code>
- <code><a href="./src/resources/responses/responses.ts">ResponseInputContent</a></code>
- <code><a href="./src/resources/responses/responses.ts">ResponseInputFile</a></code>
- <code><a href="./src/resources/responses/responses.ts">ResponseInputFileContent</a></code>
- <code><a href="./src/resources/responses/responses.ts">ResponseInputImage</a></code>
- <code><a href="./src/resources/responses/responses.ts">ResponseInputImageContent</a></code>
- <code><a href="./src/resources/responses/responses.ts">ResponseInputItem</a></code>
- <code><a href="./src/resources/responses/responses.ts">ResponseInputMessageContentList</a></code>
- <code><a href="./src/resources/responses/responses.ts">ResponseInputMessageItem</a></code>
- <code><a href="./src/resources/responses/responses.ts">ResponseInputText</a></code>
- <code><a href="./src/resources/responses/responses.ts">ResponseInputTextContent</a></code>
- <code><a href="./src/resources/responses/responses.ts">ResponseItem</a></code>
- <code><a href="./src/resources/responses/responses.ts">ResponseMcpCallArgumentsDeltaEvent</a></code>
- <code><a href="./src/resources/responses/responses.ts">ResponseMcpCallArgumentsDoneEvent</a></code>
Expand Down
2 changes: 1 addition & 1 deletion examples/parsing-run-tools.ts
Original file line number Diff line number Diff line change
@@ -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']);
Expand Down
2 changes: 1 addition & 1 deletion examples/parsing-stream.ts
Original file line number Diff line number Diff line change
@@ -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(),
Expand Down
2 changes: 1 addition & 1 deletion examples/parsing-tools-stream.ts
Original file line number Diff line number Diff line change
@@ -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(),
Expand Down
2 changes: 1 addition & 1 deletion examples/parsing-tools.ts
Original file line number Diff line number Diff line change
@@ -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']);

Expand Down
2 changes: 1 addition & 1 deletion examples/parsing.ts
Original file line number Diff line number Diff line change
@@ -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(),
Expand Down
2 changes: 1 addition & 1 deletion examples/responses/streaming-tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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([
Expand Down
2 changes: 1 addition & 1 deletion examples/responses/structured-outputs-tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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([
Expand Down
2 changes: 1 addition & 1 deletion examples/responses/structured-outputs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
2 changes: 1 addition & 1 deletion examples/tool-call-helpers-zod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion examples/ui-generation.ts
Original file line number Diff line number Diff line change
@@ -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();
Expand Down
6 changes: 3 additions & 3 deletions helpers.md
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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']);

Expand Down Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion jsr.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@openai/openai",
"version": "5.23.2",
"version": "6.0.0",
"exports": {
".": "./index.ts",
"./helpers/zod": "./helpers/zod.ts",
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>",
"types": "dist/index.d.ts",
Expand Down Expand Up @@ -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": {
Expand All @@ -76,7 +76,7 @@
},
"peerDependencies": {
"ws": "^8.18.0",
"zod": "^3.23.8"
"zod": "^3.25 || ^4.0"
},
"peerDependenciesMeta": {
"ws": {
Expand Down
2 changes: 1 addition & 1 deletion src/_vendor/zod-to-json-schema/Options.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ZodSchema, ZodTypeDef } from 'zod';
import { ZodSchema, ZodTypeDef } from 'zod/v3';
import { Refs, Seen } from './Refs';
import { JsonSchema7Type } from './parseDef';

Expand Down
2 changes: 1 addition & 1 deletion src/_vendor/zod-to-json-schema/Refs.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
2 changes: 1 addition & 1 deletion src/_vendor/zod-to-json-schema/parseDef.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
2 changes: 1 addition & 1 deletion src/_vendor/zod-to-json-schema/parsers/array.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
2 changes: 1 addition & 1 deletion src/_vendor/zod-to-json-schema/parsers/bigint.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ZodBigIntDef } from 'zod';
import { ZodBigIntDef } from 'zod/v3';
import { Refs } from '../Refs';
import { ErrorMessages, setResponseValueAndErrors } from '../errorMessages';

Expand Down
2 changes: 1 addition & 1 deletion src/_vendor/zod-to-json-schema/parsers/branded.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ZodBrandedDef } from 'zod';
import { ZodBrandedDef } from 'zod/v3';
import { parseDef } from '../parseDef';
import { Refs } from '../Refs';

Expand Down
2 changes: 1 addition & 1 deletion src/_vendor/zod-to-json-schema/parsers/catch.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ZodCatchDef } from 'zod';
import { ZodCatchDef } from 'zod/v3';
import { parseDef } from '../parseDef';
import { Refs } from '../Refs';

Expand Down
2 changes: 1 addition & 1 deletion src/_vendor/zod-to-json-schema/parsers/date.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
2 changes: 1 addition & 1 deletion src/_vendor/zod-to-json-schema/parsers/default.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ZodDefaultDef } from 'zod';
import { ZodDefaultDef } from 'zod/v3';
import { JsonSchema7Type, parseDef } from '../parseDef';
import { Refs } from '../Refs';

Expand Down
2 changes: 1 addition & 1 deletion src/_vendor/zod-to-json-schema/parsers/effects.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ZodEffectsDef } from 'zod';
import { ZodEffectsDef } from 'zod/v3';
import { JsonSchema7Type, parseDef } from '../parseDef';
import { Refs } from '../Refs';

Expand Down
2 changes: 1 addition & 1 deletion src/_vendor/zod-to-json-schema/parsers/enum.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ZodEnumDef } from 'zod';
import { ZodEnumDef } from 'zod/v3';

export type JsonSchema7EnumType = {
type: 'string';
Expand Down
2 changes: 1 addition & 1 deletion src/_vendor/zod-to-json-schema/parsers/intersection.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
2 changes: 1 addition & 1 deletion src/_vendor/zod-to-json-schema/parsers/literal.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ZodLiteralDef } from 'zod';
import { ZodLiteralDef } from 'zod/v3';
import { Refs } from '../Refs';

export type JsonSchema7LiteralType =
Expand Down
2 changes: 1 addition & 1 deletion src/_vendor/zod-to-json-schema/parsers/map.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
2 changes: 1 addition & 1 deletion src/_vendor/zod-to-json-schema/parsers/nativeEnum.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ZodNativeEnumDef } from 'zod';
import { ZodNativeEnumDef } from 'zod/v3';

export type JsonSchema7NativeEnumType = {
type: 'string' | 'number' | ['string', 'number'];
Expand Down
2 changes: 1 addition & 1 deletion src/_vendor/zod-to-json-schema/parsers/nullable.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
2 changes: 1 addition & 1 deletion src/_vendor/zod-to-json-schema/parsers/number.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ZodNumberDef } from 'zod';
import { ZodNumberDef } from 'zod/v3';
import { addErrorMessage, ErrorMessages, setResponseValueAndErrors } from '../errorMessages';
import { Refs } from '../Refs';

Expand Down
2 changes: 1 addition & 1 deletion src/_vendor/zod-to-json-schema/parsers/object.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ZodObjectDef } from 'zod';
import { ZodObjectDef } from 'zod/v3';
import { JsonSchema7Type, parseDef } from '../parseDef';
import { Refs } from '../Refs';

Expand Down
2 changes: 1 addition & 1 deletion src/_vendor/zod-to-json-schema/parsers/optional.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ZodOptionalDef } from 'zod';
import { ZodOptionalDef } from 'zod/v3';
import { JsonSchema7Type, parseDef } from '../parseDef';
import { Refs } from '../Refs';

Expand Down
2 changes: 1 addition & 1 deletion src/_vendor/zod-to-json-schema/parsers/pipeline.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
2 changes: 1 addition & 1 deletion src/_vendor/zod-to-json-schema/parsers/promise.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ZodPromiseDef } from 'zod';
import { ZodPromiseDef } from 'zod/v3';
import { JsonSchema7Type, parseDef } from '../parseDef';
import { Refs } from '../Refs';

Expand Down
2 changes: 1 addition & 1 deletion src/_vendor/zod-to-json-schema/parsers/readonly.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ZodReadonlyDef } from 'zod';
import { ZodReadonlyDef } from 'zod/v3';
import { parseDef } from '../parseDef';
import { Refs } from '../Refs';

Expand Down
2 changes: 1 addition & 1 deletion src/_vendor/zod-to-json-schema/parsers/record.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
2 changes: 1 addition & 1 deletion src/_vendor/zod-to-json-schema/parsers/set.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
2 changes: 1 addition & 1 deletion src/_vendor/zod-to-json-schema/parsers/string.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @ts-nocheck
import { ZodStringDef } from 'zod';
import { ZodStringDef } from 'zod/v3';
import { ErrorMessages, setResponseValueAndErrors } from '../errorMessages';
import { Refs } from '../Refs';

Expand Down
2 changes: 1 addition & 1 deletion src/_vendor/zod-to-json-schema/parsers/tuple.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
2 changes: 1 addition & 1 deletion src/_vendor/zod-to-json-schema/parsers/union.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
2 changes: 1 addition & 1 deletion src/_vendor/zod-to-json-schema/util.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/_vendor/zod-to-json-schema/zodToJsonSchema.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
Loading
Loading