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 @@
{
".": "6.24.0"
".": "6.25.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: 147
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-a0aa54a302fbd7fff4ed7ad8a8547587d37b63324fc4af652bfa685ee9f8da44.yml
openapi_spec_hash: e45c5af19307cfc8b9baa4b8f8e865a0
config_hash: 2cbce279be85ff86a2fabbc85d62b011
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-6bfe886b5ded0fe3bf37ca672698814e16e0836a093ceef65dac37ae44d1ad6b.yml
openapi_spec_hash: 6b1344a59044318e824c8d1af96033c7
config_hash: 7f49c38fa3abe9b7038ffe62262c4912
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
# Changelog

## 6.25.0 (2026-02-24)

Full Changelog: [v6.24.0...v6.25.0](https://github.com/openai/openai-node/compare/v6.24.0...v6.25.0)

### Features

* **api:** add phase ([e32b853](https://github.com/openai/openai-node/commit/e32b853c3c57f2d0e4c05b09177b94677aed0e5a))


### Bug Fixes

* **api:** fix phase enum ([2ffe1be](https://github.com/openai/openai-node/commit/2ffe1be2600d0154b3355eefa61707470a341a95))
* **api:** phase docs ([7fdfa38](https://github.com/openai/openai-node/commit/7fdfa38c1fa2bd383e1171510918c6db5f0937d8))


### Chores

* **internal:** refactor sse event parsing ([0ea2380](https://github.com/openai/openai-node/commit/0ea238054c0473adc97f4173a0ad5ba8bcfa4e29))

## 6.24.0 (2026-02-24)

Full Changelog: [v6.23.0...v6.24.0](https://github.com/openai/openai-node/compare/v6.23.0...v6.24.0)
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": "6.24.0",
"version": "6.25.0",
"exports": {
".": "./index.ts",
"./helpers/zod": "./helpers/zod.ts",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "openai",
"version": "6.24.0",
"version": "6.25.0",
"description": "The official TypeScript library for the OpenAI API",
"author": "OpenAI <support@openai.com>",
"types": "dist/index.d.ts",
Expand Down
3 changes: 2 additions & 1 deletion src/core/streaming.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export class Stream<Item> implements AsyncIterable<Item> {
response: Response,
controller: AbortController,
client?: OpenAI,
synthesizeEventData?: boolean,
): Stream<Item> {
let consumed = false;
const logger = client ? loggerFor(client) : console;
Expand Down Expand Up @@ -69,7 +70,7 @@ export class Stream<Item> implements AsyncIterable<Item> {
throw new APIError(undefined, data.error, undefined, response.headers);
}

yield data;
yield synthesizeEventData ? { event: sse.event, data } : data;
} else {
let data;
try {
Expand Down
14 changes: 12 additions & 2 deletions src/internal/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,20 @@ export async function defaultParseResponse<T>(
// that if you set `stream: true` the response type must also be `Stream<T>`

if (props.options.__streamClass) {
return props.options.__streamClass.fromSSEResponse(response, props.controller, client) as any;
return props.options.__streamClass.fromSSEResponse(
response,
props.controller,
client,
props.options.__synthesizeEventData,
) as any;
}

return Stream.fromSSEResponse(response, props.controller, client) as any;
return Stream.fromSSEResponse(
response,
props.controller,
client,
props.options.__synthesizeEventData,
) as any;
}

// fetch refuses to read the body when the status code is 204.
Expand Down
1 change: 1 addition & 0 deletions src/internal/request-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export type RequestOptions = {
__metadata?: Record<string, unknown>;
__binaryResponse?: boolean | undefined;
__streamClass?: typeof Stream;
__synthesizeEventData?: boolean;
};

export type EncodedContent = { bodyHeaders: HeadersLike; body: BodyInit };
Expand Down
2 changes: 2 additions & 0 deletions src/resources/beta/threads/runs/runs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export class Runs extends APIResource {
...options,
headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
stream: params.stream ?? false,
__synthesizeEventData: true,
}) as APIPromise<Run> | APIPromise<Stream<AssistantsAPI.AssistantStreamEvent>>;
}

Expand Down Expand Up @@ -259,6 +260,7 @@ export class Runs extends APIResource {
...options,
headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
stream: params.stream ?? false,
__synthesizeEventData: true,
}) as APIPromise<Run> | APIPromise<Stream<AssistantsAPI.AssistantStreamEvent>>;
}

Expand Down
1 change: 1 addition & 0 deletions src/resources/beta/threads/threads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ export class Threads extends APIResource {
...options,
headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
stream: body.stream ?? false,
__synthesizeEventData: true,
}) as APIPromise<RunsAPI.Run> | APIPromise<Stream<AssistantsAPI.AssistantStreamEvent>>;
}

Expand Down
25 changes: 25 additions & 0 deletions src/resources/responses/responses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,16 @@ export interface EasyInputMessage {
*/
role: 'user' | 'assistant' | 'system' | 'developer';

/**
* The phase of an assistant message.
*
* Use `commentary` for an intermediate assistant message and `final_answer` for
* the final assistant message. For follow-up requests with models like
* `gpt-5.3-codex` and later, preserve and resend phase on all assistant messages.
* Omitting it can degrade performance. Not used for user messages.
*/
phase?: 'commentary' | 'final_answer' | null;

/**
* The type of the message input. Always `message`.
*/
Expand Down Expand Up @@ -4741,6 +4751,16 @@ export interface ResponseOutputMessage {
* The type of the output message. Always `message`.
*/
type: 'message';

/**
* The phase of an assistant message.
*
* Use `commentary` for an intermediate assistant message and `final_answer` for
* the final assistant message. For follow-up requests with models like
* `gpt-5.3-codex` and later, preserve and resend phase on all assistant messages.
* Omitting it can degrade performance. Not used for user messages.
*/
phase?: 'commentary' | 'final_answer' | null;
}

/**
Expand Down Expand Up @@ -7273,6 +7293,11 @@ export interface ResponseCompactParams {
* Cannot be used in conjunction with `conversation`.
*/
previous_response_id?: string | null;

/**
* A key to use when reading from or writing to the prompt cache.
*/
prompt_cache_key?: string | null;
}

Responses.InputItems = InputItems;
Expand Down
2 changes: 1 addition & 1 deletion src/version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const VERSION = '6.24.0'; // x-release-please-version
export const VERSION = '6.25.0'; // x-release-please-version
1 change: 1 addition & 0 deletions tests/api-resources/conversations/conversations.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ describe('resource conversations', () => {
{
content: 'string',
role: 'user',
phase: 'commentary',
type: 'message',
},
],
Expand Down
1 change: 1 addition & 0 deletions tests/api-resources/conversations/items.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ describe('resource items', () => {
{
content: 'string',
role: 'user',
phase: 'commentary',
type: 'message',
},
],
Expand Down
1 change: 1 addition & 0 deletions tests/api-resources/responses/responses.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ describe('resource responses', () => {
input: 'string',
instructions: 'instructions',
previous_response_id: 'resp_123',
prompt_cache_key: 'prompt_cache_key',
});
});
});