diff --git a/.release-please-manifest.json b/.release-please-manifest.json
index 7bd02ca78..e7bff8e4e 100644
--- a/.release-please-manifest.json
+++ b/.release-please-manifest.json
@@ -1,3 +1,3 @@
{
- ".": "4.103.0"
+ ".": "4.104.0"
}
diff --git a/.stats.yml b/.stats.yml
index 017aa58a1..6bbd6aae7 100644
--- a/.stats.yml
+++ b/.stats.yml
@@ -1,4 +1,4 @@
configured_endpoints: 111
-openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-fc64d7c2c8f51f750813375356c3f3fdfc7fc1b1b34f19c20a5410279d445d37.yml
-openapi_spec_hash: 618285fc70199ee32b9ebe4bf72f7e4c
-config_hash: c497f6b750cc89c0bf2eefc0bc839c70
+openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-d4bcffecf0cdadf746faa6708ed1ec81fac451f9b857deabbab26f0a343b9314.yml
+openapi_spec_hash: 7c54a18b4381248bda7cc34c52142615
+config_hash: d23f847b9ebb3f427d0f198035bd3e9f
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6e9589bc1..22fe5f789 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,26 @@
# Changelog
+## 4.104.0 (2025-05-29)
+
+Full Changelog: [v4.103.0...v4.104.0](https://github.com/openai/openai-node/compare/v4.103.0...v4.104.0)
+
+### Features
+
+* **api:** Config update for pakrym-stream-param ([469ad7b](https://github.com/openai/openai-node/commit/469ad7b9d76b674aa3fd829128a54758ab7adfbd))
+
+
+### Bug Fixes
+
+* **azure:** add /images/edits to deployments endpoints ([#1509](https://github.com/openai/openai-node/issues/1509)) ([84fc31a](https://github.com/openai/openai-node/commit/84fc31aa903eceeb80815f6b17562fc463a71cfc))
+* **client:** return binary content from `get /containers/{container_id}/files/{file_id}/content` ([83129d7](https://github.com/openai/openai-node/commit/83129d7eac3dd784bb1c29fa344c5b808a59db73))
+
+
+### Chores
+
+* deprecate Assistants API ([5b34fcd](https://github.com/openai/openai-node/commit/5b34fcdd1454b8cccbaaf05ace6516afb3b09273))
+* improve publish-npm script --latest tag logic ([6207a2a](https://github.com/openai/openai-node/commit/6207a2a03d3279423de594eed18c5efb4ce321af))
+* **internal:** fix release workflows ([353349d](https://github.com/openai/openai-node/commit/353349de9ee10d32d3243cb5c60a8ae982c49d37))
+
## 4.103.0 (2025-05-22)
Full Changelog: [v4.102.0...v4.103.0](https://github.com/openai/openai-node/compare/v4.102.0...v4.103.0)
diff --git a/api.md b/api.md
index fde6fa2a3..86d6435dd 100644
--- a/api.md
+++ b/api.md
@@ -809,4 +809,4 @@ Methods:
Methods:
-- client.containers.files.content.retrieve(containerId, fileId) -> void
+- client.containers.files.content.retrieve(containerId, fileId) -> Response
diff --git a/bin/check-release-environment b/bin/check-release-environment
index e51564b7d..dbfd546bf 100644
--- a/bin/check-release-environment
+++ b/bin/check-release-environment
@@ -2,6 +2,10 @@
errors=()
+if [ -z "${STAINLESS_API_KEY}" ]; then
+ errors+=("The STAINLESS_API_KEY secret has not been set. Please contact Stainless for an API key & set it in your organization secrets on GitHub.")
+fi
+
if [ -z "${NPM_TOKEN}" ]; then
errors+=("The OPENAI_NPM_TOKEN secret has not been set. Please set it in either this repository's secrets or your organization secrets")
fi
diff --git a/bin/publish-npm b/bin/publish-npm
index 4c21181bb..2505decac 100644
--- a/bin/publish-npm
+++ b/bin/publish-npm
@@ -4,19 +4,35 @@ set -eux
npm config set '//registry.npmjs.org/:_authToken' "$NPM_TOKEN"
-# Build the project
yarn build
-
-# Navigate to the dist directory
cd dist
-# Get the version from package.json
+# Get latest version from npm
+#
+# If the package doesn't exist, yarn will return
+# {"type":"error","data":"Received invalid response from npm."}
+# where .data.version doesn't exist so LAST_VERSION will be an empty string.
+LAST_VERSION="$(yarn info --json 2> /dev/null | jq -r '.data.version')"
+
+# Get current version from package.json
VERSION="$(node -p "require('./package.json').version")"
-# Extract the pre-release tag if it exists
+# Check if current version is pre-release (e.g. alpha / beta / rc)
+CURRENT_IS_PRERELEASE=false
if [[ "$VERSION" =~ -([a-zA-Z]+) ]]; then
- # Extract the part before any dot in the pre-release identifier
- TAG="${BASH_REMATCH[1]}"
+ CURRENT_IS_PRERELEASE=true
+ CURRENT_TAG="${BASH_REMATCH[1]}"
+fi
+
+# Check if last version is a stable release
+LAST_IS_STABLE_RELEASE=true
+if [[ -z "$LAST_VERSION" || "$LAST_VERSION" =~ -([a-zA-Z]+) ]]; then
+ LAST_IS_STABLE_RELEASE=false
+fi
+
+# Use a corresponding alpha/beta tag if there already is a stable release and we're publishing a prerelease.
+if $CURRENT_IS_PRERELEASE && $LAST_IS_STABLE_RELEASE; then
+ TAG="$CURRENT_TAG"
else
TAG="latest"
fi
diff --git a/jsr.json b/jsr.json
index b35a86451..64467ad45 100644
--- a/jsr.json
+++ b/jsr.json
@@ -1,6 +1,6 @@
{
"name": "@openai/openai",
- "version": "4.103.0",
+ "version": "4.104.0",
"exports": {
".": "./index.ts",
"./helpers/zod": "./helpers/zod.ts",
diff --git a/package.json b/package.json
index ba999c878..7fd868a34 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "openai",
- "version": "4.103.0",
+ "version": "4.104.0",
"description": "The official TypeScript library for the OpenAI API",
"author": "OpenAI ",
"types": "dist/index.d.ts",
diff --git a/src/index.ts b/src/index.ts
index 3b4b9a574..3a25ad3ef 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -772,6 +772,7 @@ const _deployments_endpoints = new Set([
'/audio/translations',
'/audio/speech',
'/images/generations',
+ '/images/edits',
]);
const API_KEY_SENTINEL = '';
diff --git a/src/resources/beta/realtime/realtime.ts b/src/resources/beta/realtime/realtime.ts
index 5ced1574f..b9a1788ac 100644
--- a/src/resources/beta/realtime/realtime.ts
+++ b/src/resources/beta/realtime/realtime.ts
@@ -2094,6 +2094,11 @@ export namespace SessionUpdateEvent {
* Realtime session object configuration.
*/
export interface Session {
+ /**
+ * Configuration options for the generated client secret.
+ */
+ client_secret?: Session.ClientSecret;
+
/**
* The format of input audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`. For
* `pcm16`, input audio must be 16-bit PCM at a 24kHz sample rate, single channel
@@ -2219,6 +2224,35 @@ export namespace SessionUpdateEvent {
}
export namespace Session {
+ /**
+ * Configuration options for the generated client secret.
+ */
+ export interface ClientSecret {
+ /**
+ * Configuration for the ephemeral token expiration.
+ */
+ expires_at?: ClientSecret.ExpiresAt;
+ }
+
+ export namespace ClientSecret {
+ /**
+ * Configuration for the ephemeral token expiration.
+ */
+ export interface ExpiresAt {
+ /**
+ * The anchor point for the ephemeral token expiration. Only `created_at` is
+ * currently supported.
+ */
+ anchor?: 'created_at';
+
+ /**
+ * The number of seconds from the anchor point to the expiration. Select a value
+ * between `10` and `7200`.
+ */
+ seconds?: number;
+ }
+ }
+
/**
* Configuration for input audio noise reduction. This can be set to `null` to turn
* off. Noise reduction filters audio added to the input audio buffer before it is
@@ -2399,6 +2433,11 @@ export namespace TranscriptionSessionUpdate {
* Realtime transcription session object configuration.
*/
export interface Session {
+ /**
+ * Configuration options for the generated client secret.
+ */
+ client_secret?: Session.ClientSecret;
+
/**
* The set of items to include in the transcription. Current available items are:
*
@@ -2451,6 +2490,35 @@ export namespace TranscriptionSessionUpdate {
}
export namespace Session {
+ /**
+ * Configuration options for the generated client secret.
+ */
+ export interface ClientSecret {
+ /**
+ * Configuration for the ephemeral token expiration.
+ */
+ expires_at?: ClientSecret.ExpiresAt;
+ }
+
+ export namespace ClientSecret {
+ /**
+ * Configuration for the ephemeral token expiration.
+ */
+ export interface ExpiresAt {
+ /**
+ * The anchor point for the ephemeral token expiration. Only `created_at` is
+ * currently supported.
+ */
+ anchor?: 'created_at';
+
+ /**
+ * The number of seconds from the anchor point to the expiration. Select a value
+ * between `10` and `7200`.
+ */
+ seconds?: number;
+ }
+ }
+
/**
* Configuration for input audio noise reduction. This can be set to `null` to turn
* off. Noise reduction filters audio added to the input audio buffer before it is
diff --git a/src/resources/beta/realtime/sessions.ts b/src/resources/beta/realtime/sessions.ts
index a55a2678c..d6fb1135e 100644
--- a/src/resources/beta/realtime/sessions.ts
+++ b/src/resources/beta/realtime/sessions.ts
@@ -485,6 +485,11 @@ export namespace SessionCreateResponse {
}
export interface SessionCreateParams {
+ /**
+ * Configuration options for the generated client secret.
+ */
+ client_secret?: SessionCreateParams.ClientSecret;
+
/**
* The format of input audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`. For
* `pcm16`, input audio must be 16-bit PCM at a 24kHz sample rate, single channel
@@ -610,6 +615,35 @@ export interface SessionCreateParams {
}
export namespace SessionCreateParams {
+ /**
+ * Configuration options for the generated client secret.
+ */
+ export interface ClientSecret {
+ /**
+ * Configuration for the ephemeral token expiration.
+ */
+ expires_at?: ClientSecret.ExpiresAt;
+ }
+
+ export namespace ClientSecret {
+ /**
+ * Configuration for the ephemeral token expiration.
+ */
+ export interface ExpiresAt {
+ /**
+ * The anchor point for the ephemeral token expiration. Only `created_at` is
+ * currently supported.
+ */
+ anchor?: 'created_at';
+
+ /**
+ * The number of seconds from the anchor point to the expiration. Select a value
+ * between `10` and `7200`.
+ */
+ seconds?: number;
+ }
+ }
+
/**
* Configuration for input audio noise reduction. This can be set to `null` to turn
* off. Noise reduction filters audio added to the input audio buffer before it is
diff --git a/src/resources/beta/realtime/transcription-sessions.ts b/src/resources/beta/realtime/transcription-sessions.ts
index 83e8c47ad..5c14540f8 100644
--- a/src/resources/beta/realtime/transcription-sessions.ts
+++ b/src/resources/beta/realtime/transcription-sessions.ts
@@ -149,6 +149,11 @@ export namespace TranscriptionSession {
}
export interface TranscriptionSessionCreateParams {
+ /**
+ * Configuration options for the generated client secret.
+ */
+ client_secret?: TranscriptionSessionCreateParams.ClientSecret;
+
/**
* The set of items to include in the transcription. Current available items are:
*
@@ -201,6 +206,35 @@ export interface TranscriptionSessionCreateParams {
}
export namespace TranscriptionSessionCreateParams {
+ /**
+ * Configuration options for the generated client secret.
+ */
+ export interface ClientSecret {
+ /**
+ * Configuration for the ephemeral token expiration.
+ */
+ expires_at?: ClientSecret.ExpiresAt;
+ }
+
+ export namespace ClientSecret {
+ /**
+ * Configuration for the ephemeral token expiration.
+ */
+ export interface ExpiresAt {
+ /**
+ * The anchor point for the ephemeral token expiration. Only `created_at` is
+ * currently supported.
+ */
+ anchor?: 'created_at';
+
+ /**
+ * The number of seconds from the anchor point to the expiration. Select a value
+ * between `10` and `7200`.
+ */
+ seconds?: number;
+ }
+ }
+
/**
* Configuration for input audio noise reduction. This can be set to `null` to turn
* off. Noise reduction filters audio added to the input audio buffer before it is
diff --git a/src/resources/beta/threads/messages.ts b/src/resources/beta/threads/messages.ts
index c3834ebe6..43779d427 100644
--- a/src/resources/beta/threads/messages.ts
+++ b/src/resources/beta/threads/messages.ts
@@ -7,17 +7,14 @@ import * as Shared from '../../shared';
import * as AssistantsAPI from '../assistants';
import { CursorPage, type CursorPageParams } from '../../../pagination';
+/**
+ * @deprecated The Assistants API is deprecated in favor of the Responses API
+ */
export class Messages extends APIResource {
/**
* Create a message.
*
- * @example
- * ```ts
- * const message = await client.beta.threads.messages.create(
- * 'thread_id',
- * { content: 'string', role: 'user' },
- * );
- * ```
+ * @deprecated The Assistants API is deprecated in favor of the Responses API
*/
create(
threadId: string,
@@ -34,13 +31,7 @@ export class Messages extends APIResource {
/**
* Retrieve a message.
*
- * @example
- * ```ts
- * const message = await client.beta.threads.messages.retrieve(
- * 'thread_id',
- * 'message_id',
- * );
- * ```
+ * @deprecated The Assistants API is deprecated in favor of the Responses API
*/
retrieve(threadId: string, messageId: string, options?: Core.RequestOptions): Core.APIPromise {
return this._client.get(`/threads/${threadId}/messages/${messageId}`, {
@@ -52,13 +43,7 @@ export class Messages extends APIResource {
/**
* Modifies a message.
*
- * @example
- * ```ts
- * const message = await client.beta.threads.messages.update(
- * 'thread_id',
- * 'message_id',
- * );
- * ```
+ * @deprecated The Assistants API is deprecated in favor of the Responses API
*/
update(
threadId: string,
@@ -76,15 +61,7 @@ export class Messages extends APIResource {
/**
* Returns a list of messages for a given thread.
*
- * @example
- * ```ts
- * // Automatically fetches more pages as needed.
- * for await (const message of client.beta.threads.messages.list(
- * 'thread_id',
- * )) {
- * // ...
- * }
- * ```
+ * @deprecated The Assistants API is deprecated in favor of the Responses API
*/
list(
threadId: string,
@@ -110,14 +87,7 @@ export class Messages extends APIResource {
/**
* Deletes a message.
*
- * @example
- * ```ts
- * const messageDeleted =
- * await client.beta.threads.messages.del(
- * 'thread_id',
- * 'message_id',
- * );
- * ```
+ * @deprecated The Assistants API is deprecated in favor of the Responses API
*/
del(threadId: string, messageId: string, options?: Core.RequestOptions): Core.APIPromise {
return this._client.delete(`/threads/${threadId}/messages/${messageId}`, {
diff --git a/src/resources/beta/threads/runs/runs.ts b/src/resources/beta/threads/runs/runs.ts
index 25356df3c..fd5d82457 100644
--- a/src/resources/beta/threads/runs/runs.ts
+++ b/src/resources/beta/threads/runs/runs.ts
@@ -40,19 +40,16 @@ import {
import { CursorPage, type CursorPageParams } from '../../../../pagination';
import { Stream } from '../../../../streaming';
+/**
+ * @deprecated The Assistants API is deprecated in favor of the Responses API
+ */
export class Runs extends APIResource {
steps: StepsAPI.Steps = new StepsAPI.Steps(this._client);
/**
* Create a run.
*
- * @example
- * ```ts
- * const run = await client.beta.threads.runs.create(
- * 'thread_id',
- * { assistant_id: 'assistant_id' },
- * );
- * ```
+ * @deprecated The Assistants API is deprecated in favor of the Responses API
*/
create(
threadId: string,
@@ -87,13 +84,7 @@ export class Runs extends APIResource {
/**
* Retrieves a run.
*
- * @example
- * ```ts
- * const run = await client.beta.threads.runs.retrieve(
- * 'thread_id',
- * 'run_id',
- * );
- * ```
+ * @deprecated The Assistants API is deprecated in favor of the Responses API
*/
retrieve(threadId: string, runId: string, options?: Core.RequestOptions): Core.APIPromise {
return this._client.get(`/threads/${threadId}/runs/${runId}`, {
@@ -105,13 +96,7 @@ export class Runs extends APIResource {
/**
* Modifies a run.
*
- * @example
- * ```ts
- * const run = await client.beta.threads.runs.update(
- * 'thread_id',
- * 'run_id',
- * );
- * ```
+ * @deprecated The Assistants API is deprecated in favor of the Responses API
*/
update(
threadId: string,
@@ -129,15 +114,7 @@ export class Runs extends APIResource {
/**
* Returns a list of runs belonging to a thread.
*
- * @example
- * ```ts
- * // Automatically fetches more pages as needed.
- * for await (const run of client.beta.threads.runs.list(
- * 'thread_id',
- * )) {
- * // ...
- * }
- * ```
+ * @deprecated The Assistants API is deprecated in favor of the Responses API
*/
list(
threadId: string,
@@ -163,13 +140,7 @@ export class Runs extends APIResource {
/**
* Cancels a run that is `in_progress`.
*
- * @example
- * ```ts
- * const run = await client.beta.threads.runs.cancel(
- * 'thread_id',
- * 'run_id',
- * );
- * ```
+ * @deprecated The Assistants API is deprecated in favor of the Responses API
*/
cancel(threadId: string, runId: string, options?: Core.RequestOptions): Core.APIPromise {
return this._client.post(`/threads/${threadId}/runs/${runId}/cancel`, {
@@ -272,15 +243,7 @@ export class Runs extends APIResource {
* tool calls once they're all completed. All outputs must be submitted in a single
* request.
*
- * @example
- * ```ts
- * const run =
- * await client.beta.threads.runs.submitToolOutputs(
- * 'thread_id',
- * 'run_id',
- * { tool_outputs: [{}] },
- * );
- * ```
+ * @deprecated The Assistants API is deprecated in favor of the Responses API
*/
submitToolOutputs(
threadId: string,
diff --git a/src/resources/beta/threads/runs/steps.ts b/src/resources/beta/threads/runs/steps.ts
index abd8d40ed..0907f69c4 100644
--- a/src/resources/beta/threads/runs/steps.ts
+++ b/src/resources/beta/threads/runs/steps.ts
@@ -7,19 +7,14 @@ import * as StepsAPI from './steps';
import * as Shared from '../../../shared';
import { CursorPage, type CursorPageParams } from '../../../../pagination';
+/**
+ * @deprecated The Assistants API is deprecated in favor of the Responses API
+ */
export class Steps extends APIResource {
/**
* Retrieves a run step.
*
- * @example
- * ```ts
- * const runStep =
- * await client.beta.threads.runs.steps.retrieve(
- * 'thread_id',
- * 'run_id',
- * 'step_id',
- * );
- * ```
+ * @deprecated The Assistants API is deprecated in favor of the Responses API
*/
retrieve(
threadId: string,
@@ -54,16 +49,7 @@ export class Steps extends APIResource {
/**
* Returns a list of run steps belonging to a run.
*
- * @example
- * ```ts
- * // Automatically fetches more pages as needed.
- * for await (const runStep of client.beta.threads.runs.steps.list(
- * 'thread_id',
- * 'run_id',
- * )) {
- * // ...
- * }
- * ```
+ * @deprecated The Assistants API is deprecated in favor of the Responses API
*/
list(
threadId: string,
diff --git a/src/resources/beta/threads/threads.ts b/src/resources/beta/threads/threads.ts
index c0c6bc8e4..b27729371 100644
--- a/src/resources/beta/threads/threads.ts
+++ b/src/resources/beta/threads/threads.ts
@@ -67,6 +67,9 @@ import {
} from './runs/runs';
import { Stream } from '../../../streaming';
+/**
+ * @deprecated The Assistants API is deprecated in favor of the Responses API
+ */
export class Threads extends APIResource {
runs: RunsAPI.Runs = new RunsAPI.Runs(this._client);
messages: MessagesAPI.Messages = new MessagesAPI.Messages(this._client);
@@ -74,10 +77,7 @@ export class Threads extends APIResource {
/**
* Create a thread.
*
- * @example
- * ```ts
- * const thread = await client.beta.threads.create();
- * ```
+ * @deprecated The Assistants API is deprecated in favor of the Responses API
*/
create(body?: ThreadCreateParams, options?: Core.RequestOptions): Core.APIPromise;
create(options?: Core.RequestOptions): Core.APIPromise;
@@ -98,12 +98,7 @@ export class Threads extends APIResource {
/**
* Retrieves a thread.
*
- * @example
- * ```ts
- * const thread = await client.beta.threads.retrieve(
- * 'thread_id',
- * );
- * ```
+ * @deprecated The Assistants API is deprecated in favor of the Responses API
*/
retrieve(threadId: string, options?: Core.RequestOptions): Core.APIPromise {
return this._client.get(`/threads/${threadId}`, {
@@ -115,12 +110,7 @@ export class Threads extends APIResource {
/**
* Modifies a thread.
*
- * @example
- * ```ts
- * const thread = await client.beta.threads.update(
- * 'thread_id',
- * );
- * ```
+ * @deprecated The Assistants API is deprecated in favor of the Responses API
*/
update(threadId: string, body: ThreadUpdateParams, options?: Core.RequestOptions): Core.APIPromise {
return this._client.post(`/threads/${threadId}`, {
@@ -133,12 +123,7 @@ export class Threads extends APIResource {
/**
* Delete a thread.
*
- * @example
- * ```ts
- * const threadDeleted = await client.beta.threads.del(
- * 'thread_id',
- * );
- * ```
+ * @deprecated The Assistants API is deprecated in favor of the Responses API
*/
del(threadId: string, options?: Core.RequestOptions): Core.APIPromise {
return this._client.delete(`/threads/${threadId}`, {
@@ -150,12 +135,7 @@ export class Threads extends APIResource {
/**
* Create a thread and run it in one request.
*
- * @example
- * ```ts
- * const run = await client.beta.threads.createAndRun({
- * assistant_id: 'assistant_id',
- * });
- * ```
+ * @deprecated The Assistants API is deprecated in favor of the Responses API
*/
createAndRun(
body: ThreadCreateAndRunParamsNonStreaming,
diff --git a/src/resources/containers/files/content.ts b/src/resources/containers/files/content.ts
index efb33a87f..e99d75459 100644
--- a/src/resources/containers/files/content.ts
+++ b/src/resources/containers/files/content.ts
@@ -2,15 +2,17 @@
import { APIResource } from '../../../resource';
import * as Core from '../../../core';
+import { type Response } from '../../../_shims/index';
export class Content extends APIResource {
/**
* Retrieve Container File Content
*/
- retrieve(containerId: string, fileId: string, options?: Core.RequestOptions): Core.APIPromise {
+ retrieve(containerId: string, fileId: string, options?: Core.RequestOptions): Core.APIPromise {
return this._client.get(`/containers/${containerId}/files/${fileId}/content`, {
...options,
- headers: { Accept: '*/*', ...options?.headers },
+ headers: { Accept: 'application/binary', ...options?.headers },
+ __binaryResponse: true,
});
}
}
diff --git a/src/resources/responses/responses.ts b/src/resources/responses/responses.ts
index a0839e432..eeaff8a11 100644
--- a/src/resources/responses/responses.ts
+++ b/src/resources/responses/responses.ts
@@ -7,7 +7,7 @@ import {
addOutputText,
} from '../../lib/ResponsesParser';
import * as Core from '../../core';
-import { APIPromise, isRequestOptions } from '../../core';
+import { APIPromise } from '../../core';
import { APIResource } from '../../resource';
import * as Shared from '../shared';
import * as InputItemsAPI from './input-items';
@@ -117,38 +117,26 @@ export class Responses extends APIResource {
responseId: string,
query?: ResponseRetrieveParamsNonStreaming,
options?: Core.RequestOptions,
- ): Core.APIPromise;
+ ): APIPromise;
retrieve(
responseId: string,
- query?: ResponseRetrieveParamsStreaming,
+ query: ResponseRetrieveParamsStreaming,
options?: Core.RequestOptions,
- ): Core.APIPromise>;
- retrieve(responseId: string, options?: Core.RequestOptions): Core.APIPromise;
+ ): APIPromise>;
retrieve(
responseId: string,
- query: ResponseRetrieveParams | Core.RequestOptions,
+ query?: ResponseRetrieveParamsBase | undefined,
options?: Core.RequestOptions,
- ): Core.APIPromise | Core.APIPromise>;
+ ): APIPromise | Response>;
retrieve(
responseId: string,
- query: ResponseRetrieveParams | Core.RequestOptions = {},
+ query: ResponseRetrieveParams | undefined = {},
options?: Core.RequestOptions,
- ): Core.APIPromise | Core.APIPromise> {
- if (isRequestOptions(query) && options === undefined) {
- return this.retrieve(responseId, {}, query);
- }
- return (
- this._client.get(`/responses/${responseId}`, {
- query,
- ...options,
- stream: query.stream ?? false,
- }) as APIPromise | APIPromise>
- )._thenUnwrap((rsp) => {
- if ('object' in rsp && rsp.object === 'response') {
- addOutputText(rsp as Response);
- }
-
- return rsp;
+ ): APIPromise | APIPromise> {
+ return this._client.get(`/responses/${responseId}`, {
+ query,
+ ...options,
+ stream: query?.stream ?? false,
}) as APIPromise | APIPromise>;
}
@@ -3320,6 +3308,8 @@ export interface ResponseOutputText {
* The type of the output text. Always `output_text`.
*/
type: 'output_text';
+
+ logprobs?: Array;
}
export namespace ResponseOutputText {
@@ -3392,6 +3382,32 @@ export namespace ResponseOutputText {
*/
type: 'file_path';
}
+
+ /**
+ * The log probability of a token.
+ */
+ export interface Logprob {
+ token: string;
+
+ bytes: Array;
+
+ logprob: number;
+
+ top_logprobs: Array;
+ }
+
+ export namespace Logprob {
+ /**
+ * The top log probability of a token.
+ */
+ export interface TopLogprob {
+ token: string;
+
+ bytes: Array;
+
+ logprob: number;
+ }
+ }
}
/**
@@ -4742,7 +4758,8 @@ export interface ResponseCreateParamsStreaming extends ResponseCreateParamsBase
stream: true;
}
-export type ResponseRetrieveParams = ResponseRetrieveParamsStreaming | ResponseRetrieveParamsNonStreaming;
+export type ResponseRetrieveParams = ResponseRetrieveParamsNonStreaming | ResponseRetrieveParamsStreaming;
+
export interface ResponseRetrieveParamsBase {
/**
* Additional fields to include in the response. See the `include` parameter for
@@ -4750,21 +4767,51 @@ export interface ResponseRetrieveParamsBase {
*/
include?: Array;
- starting_after?: number | null;
- stream?: boolean | null;
+ /**
+ * The sequence number of the event after which to start streaming.
+ */
+ starting_after?: number;
+
+ /**
+ * If set to true, the model response data will be streamed to the client as it is
+ * generated using
+ * [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format).
+ * See the
+ * [Streaming section below](https://platform.openai.com/docs/api-reference/responses-streaming)
+ * for more information.
+ */
+ stream?: boolean;
}
-export interface ResponseRetrieveParamsStreaming extends ResponseRetrieveParamsBase {
- stream: true;
+export namespace ResponseRetrieveParams {
+ export type ResponseRetrieveParamsNonStreaming = ResponsesAPI.ResponseRetrieveParamsNonStreaming;
+ export type ResponseRetrieveParamsStreaming = ResponsesAPI.ResponseRetrieveParamsStreaming;
}
+
export interface ResponseRetrieveParamsNonStreaming extends ResponseRetrieveParamsBase {
- stream?: false | null;
+ /**
+ * If set to true, the model response data will be streamed to the client as it is
+ * generated using
+ * [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format).
+ * See the
+ * [Streaming section below](https://platform.openai.com/docs/api-reference/responses-streaming)
+ * for more information.
+ */
+ stream?: false;
}
-export namespace ResponseRetrieveParams {
- export type ResponseRetrieveParamsStreaming = ResponsesAPI.ResponseRetrieveParamsStreaming;
- export type ResponseRetrieveParamsNonStreaming = ResponsesAPI.ResponseRetrieveParamsNonStreaming;
+export interface ResponseRetrieveParamsStreaming extends ResponseRetrieveParamsBase {
+ /**
+ * If set to true, the model response data will be streamed to the client as it is
+ * generated using
+ * [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format).
+ * See the
+ * [Streaming section below](https://platform.openai.com/docs/api-reference/responses-streaming)
+ * for more information.
+ */
+ stream: true;
}
+
Responses.InputItems = InputItems;
export declare namespace Responses {
@@ -4870,6 +4917,8 @@ export declare namespace Responses {
type ResponseCreateParamsNonStreaming as ResponseCreateParamsNonStreaming,
type ResponseCreateParamsStreaming as ResponseCreateParamsStreaming,
type ResponseRetrieveParams as ResponseRetrieveParams,
+ type ResponseRetrieveParamsNonStreaming as ResponseRetrieveParamsNonStreaming,
+ type ResponseRetrieveParamsStreaming as ResponseRetrieveParamsStreaming,
};
export {
diff --git a/src/version.ts b/src/version.ts
index 81be9e239..42c4cab74 100644
--- a/src/version.ts
+++ b/src/version.ts
@@ -1 +1 @@
-export const VERSION = '4.103.0'; // x-release-please-version
+export const VERSION = '4.104.0'; // x-release-please-version
diff --git a/tests/api-resources/containers/files/content.test.ts b/tests/api-resources/containers/files/content.test.ts
index 9215c001a..c4b10fdf4 100644
--- a/tests/api-resources/containers/files/content.test.ts
+++ b/tests/api-resources/containers/files/content.test.ts
@@ -1,7 +1,6 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import OpenAI from 'openai';
-import { Response } from 'node-fetch';
const client = new OpenAI({
apiKey: 'My API Key',
@@ -9,17 +8,6 @@ const client = new OpenAI({
});
describe('resource content', () => {
- test('retrieve', async () => {
- const responsePromise = client.containers.files.content.retrieve('container_id', 'file_id');
- const rawResponse = await responsePromise.asResponse();
- expect(rawResponse).toBeInstanceOf(Response);
- const response = await responsePromise;
- expect(response).not.toBeInstanceOf(Response);
- const dataAndResponse = await responsePromise.withResponse();
- expect(dataAndResponse.data).toBe(response);
- expect(dataAndResponse.response).toBe(rawResponse);
- });
-
test('retrieve: request options instead of 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(
diff --git a/tests/api-resources/responses/responses.test.ts b/tests/api-resources/responses/responses.test.ts
index f8e653c52..97847b28a 100644
--- a/tests/api-resources/responses/responses.test.ts
+++ b/tests/api-resources/responses/responses.test.ts
@@ -64,21 +64,12 @@ describe('resource responses', () => {
expect(dataAndResponse.response).toBe(rawResponse);
});
- test('retrieve: request options instead of 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.responses.retrieve('resp_677efb5139a88190b512bc3fef8e535d', {
- path: '/_stainless_unknown_path',
- }),
- ).rejects.toThrow(OpenAI.NotFoundError);
- });
-
test('retrieve: 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.responses.retrieve(
'resp_677efb5139a88190b512bc3fef8e535d',
- { include: ['file_search_call.results'] },
+ { include: ['file_search_call.results'], starting_after: 0, stream: false },
{ path: '/_stainless_unknown_path' },
),
).rejects.toThrow(OpenAI.NotFoundError);