公众号验证码功能完成 yeah!!!
This commit is contained in:
2
node_modules/openai/src/_vendor/zod-to-json-schema/Options.ts
generated
vendored
2
node_modules/openai/src/_vendor/zod-to-json-schema/Options.ts
generated
vendored
@@ -1,4 +1,4 @@
|
||||
import { ZodSchema, ZodTypeDef } from 'zod';
|
||||
import { ZodSchema, ZodTypeDef } from 'zod/v3';
|
||||
import { Refs, Seen } from './Refs';
|
||||
import { JsonSchema7Type } from './parseDef';
|
||||
|
||||
|
||||
2
node_modules/openai/src/_vendor/zod-to-json-schema/Refs.ts
generated
vendored
2
node_modules/openai/src/_vendor/zod-to-json-schema/Refs.ts
generated
vendored
@@ -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';
|
||||
|
||||
2
node_modules/openai/src/_vendor/zod-to-json-schema/parseDef.ts
generated
vendored
2
node_modules/openai/src/_vendor/zod-to-json-schema/parseDef.ts
generated
vendored
@@ -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';
|
||||
|
||||
2
node_modules/openai/src/_vendor/zod-to-json-schema/parsers/array.ts
generated
vendored
2
node_modules/openai/src/_vendor/zod-to-json-schema/parsers/array.ts
generated
vendored
@@ -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';
|
||||
|
||||
2
node_modules/openai/src/_vendor/zod-to-json-schema/parsers/bigint.ts
generated
vendored
2
node_modules/openai/src/_vendor/zod-to-json-schema/parsers/bigint.ts
generated
vendored
@@ -1,4 +1,4 @@
|
||||
import { ZodBigIntDef } from 'zod';
|
||||
import { ZodBigIntDef } from 'zod/v3';
|
||||
import { Refs } from '../Refs';
|
||||
import { ErrorMessages, setResponseValueAndErrors } from '../errorMessages';
|
||||
|
||||
|
||||
2
node_modules/openai/src/_vendor/zod-to-json-schema/parsers/branded.ts
generated
vendored
2
node_modules/openai/src/_vendor/zod-to-json-schema/parsers/branded.ts
generated
vendored
@@ -1,4 +1,4 @@
|
||||
import { ZodBrandedDef } from 'zod';
|
||||
import { ZodBrandedDef } from 'zod/v3';
|
||||
import { parseDef } from '../parseDef';
|
||||
import { Refs } from '../Refs';
|
||||
|
||||
|
||||
2
node_modules/openai/src/_vendor/zod-to-json-schema/parsers/catch.ts
generated
vendored
2
node_modules/openai/src/_vendor/zod-to-json-schema/parsers/catch.ts
generated
vendored
@@ -1,4 +1,4 @@
|
||||
import { ZodCatchDef } from 'zod';
|
||||
import { ZodCatchDef } from 'zod/v3';
|
||||
import { parseDef } from '../parseDef';
|
||||
import { Refs } from '../Refs';
|
||||
|
||||
|
||||
2
node_modules/openai/src/_vendor/zod-to-json-schema/parsers/date.ts
generated
vendored
2
node_modules/openai/src/_vendor/zod-to-json-schema/parsers/date.ts
generated
vendored
@@ -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';
|
||||
|
||||
2
node_modules/openai/src/_vendor/zod-to-json-schema/parsers/default.ts
generated
vendored
2
node_modules/openai/src/_vendor/zod-to-json-schema/parsers/default.ts
generated
vendored
@@ -1,4 +1,4 @@
|
||||
import { ZodDefaultDef } from 'zod';
|
||||
import { ZodDefaultDef } from 'zod/v3';
|
||||
import { JsonSchema7Type, parseDef } from '../parseDef';
|
||||
import { Refs } from '../Refs';
|
||||
|
||||
|
||||
2
node_modules/openai/src/_vendor/zod-to-json-schema/parsers/effects.ts
generated
vendored
2
node_modules/openai/src/_vendor/zod-to-json-schema/parsers/effects.ts
generated
vendored
@@ -1,4 +1,4 @@
|
||||
import { ZodEffectsDef } from 'zod';
|
||||
import { ZodEffectsDef } from 'zod/v3';
|
||||
import { JsonSchema7Type, parseDef } from '../parseDef';
|
||||
import { Refs } from '../Refs';
|
||||
|
||||
|
||||
2
node_modules/openai/src/_vendor/zod-to-json-schema/parsers/enum.ts
generated
vendored
2
node_modules/openai/src/_vendor/zod-to-json-schema/parsers/enum.ts
generated
vendored
@@ -1,4 +1,4 @@
|
||||
import { ZodEnumDef } from 'zod';
|
||||
import { ZodEnumDef } from 'zod/v3';
|
||||
|
||||
export type JsonSchema7EnumType = {
|
||||
type: 'string';
|
||||
|
||||
2
node_modules/openai/src/_vendor/zod-to-json-schema/parsers/intersection.ts
generated
vendored
2
node_modules/openai/src/_vendor/zod-to-json-schema/parsers/intersection.ts
generated
vendored
@@ -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';
|
||||
|
||||
2
node_modules/openai/src/_vendor/zod-to-json-schema/parsers/literal.ts
generated
vendored
2
node_modules/openai/src/_vendor/zod-to-json-schema/parsers/literal.ts
generated
vendored
@@ -1,4 +1,4 @@
|
||||
import { ZodLiteralDef } from 'zod';
|
||||
import { ZodLiteralDef } from 'zod/v3';
|
||||
import { Refs } from '../Refs';
|
||||
|
||||
export type JsonSchema7LiteralType =
|
||||
|
||||
2
node_modules/openai/src/_vendor/zod-to-json-schema/parsers/map.ts
generated
vendored
2
node_modules/openai/src/_vendor/zod-to-json-schema/parsers/map.ts
generated
vendored
@@ -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';
|
||||
|
||||
2
node_modules/openai/src/_vendor/zod-to-json-schema/parsers/nativeEnum.ts
generated
vendored
2
node_modules/openai/src/_vendor/zod-to-json-schema/parsers/nativeEnum.ts
generated
vendored
@@ -1,4 +1,4 @@
|
||||
import { ZodNativeEnumDef } from 'zod';
|
||||
import { ZodNativeEnumDef } from 'zod/v3';
|
||||
|
||||
export type JsonSchema7NativeEnumType = {
|
||||
type: 'string' | 'number' | ['string', 'number'];
|
||||
|
||||
2
node_modules/openai/src/_vendor/zod-to-json-schema/parsers/nullable.ts
generated
vendored
2
node_modules/openai/src/_vendor/zod-to-json-schema/parsers/nullable.ts
generated
vendored
@@ -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';
|
||||
|
||||
2
node_modules/openai/src/_vendor/zod-to-json-schema/parsers/number.ts
generated
vendored
2
node_modules/openai/src/_vendor/zod-to-json-schema/parsers/number.ts
generated
vendored
@@ -1,4 +1,4 @@
|
||||
import { ZodNumberDef } from 'zod';
|
||||
import { ZodNumberDef } from 'zod/v3';
|
||||
import { addErrorMessage, ErrorMessages, setResponseValueAndErrors } from '../errorMessages';
|
||||
import { Refs } from '../Refs';
|
||||
|
||||
|
||||
2
node_modules/openai/src/_vendor/zod-to-json-schema/parsers/object.ts
generated
vendored
2
node_modules/openai/src/_vendor/zod-to-json-schema/parsers/object.ts
generated
vendored
@@ -1,4 +1,4 @@
|
||||
import { ZodObjectDef } from 'zod';
|
||||
import { ZodObjectDef } from 'zod/v3';
|
||||
import { JsonSchema7Type, parseDef } from '../parseDef';
|
||||
import { Refs } from '../Refs';
|
||||
|
||||
|
||||
2
node_modules/openai/src/_vendor/zod-to-json-schema/parsers/optional.ts
generated
vendored
2
node_modules/openai/src/_vendor/zod-to-json-schema/parsers/optional.ts
generated
vendored
@@ -1,4 +1,4 @@
|
||||
import { ZodOptionalDef } from 'zod';
|
||||
import { ZodOptionalDef } from 'zod/v3';
|
||||
import { JsonSchema7Type, parseDef } from '../parseDef';
|
||||
import { Refs } from '../Refs';
|
||||
|
||||
|
||||
2
node_modules/openai/src/_vendor/zod-to-json-schema/parsers/pipeline.ts
generated
vendored
2
node_modules/openai/src/_vendor/zod-to-json-schema/parsers/pipeline.ts
generated
vendored
@@ -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';
|
||||
|
||||
2
node_modules/openai/src/_vendor/zod-to-json-schema/parsers/promise.ts
generated
vendored
2
node_modules/openai/src/_vendor/zod-to-json-schema/parsers/promise.ts
generated
vendored
@@ -1,4 +1,4 @@
|
||||
import { ZodPromiseDef } from 'zod';
|
||||
import { ZodPromiseDef } from 'zod/v3';
|
||||
import { JsonSchema7Type, parseDef } from '../parseDef';
|
||||
import { Refs } from '../Refs';
|
||||
|
||||
|
||||
2
node_modules/openai/src/_vendor/zod-to-json-schema/parsers/readonly.ts
generated
vendored
2
node_modules/openai/src/_vendor/zod-to-json-schema/parsers/readonly.ts
generated
vendored
@@ -1,4 +1,4 @@
|
||||
import { ZodReadonlyDef } from 'zod';
|
||||
import { ZodReadonlyDef } from 'zod/v3';
|
||||
import { parseDef } from '../parseDef';
|
||||
import { Refs } from '../Refs';
|
||||
|
||||
|
||||
2
node_modules/openai/src/_vendor/zod-to-json-schema/parsers/record.ts
generated
vendored
2
node_modules/openai/src/_vendor/zod-to-json-schema/parsers/record.ts
generated
vendored
@@ -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';
|
||||
|
||||
2
node_modules/openai/src/_vendor/zod-to-json-schema/parsers/set.ts
generated
vendored
2
node_modules/openai/src/_vendor/zod-to-json-schema/parsers/set.ts
generated
vendored
@@ -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';
|
||||
|
||||
2
node_modules/openai/src/_vendor/zod-to-json-schema/parsers/string.ts
generated
vendored
2
node_modules/openai/src/_vendor/zod-to-json-schema/parsers/string.ts
generated
vendored
@@ -1,5 +1,5 @@
|
||||
// @ts-nocheck
|
||||
import { ZodStringDef } from 'zod';
|
||||
import { ZodStringDef } from 'zod/v3';
|
||||
import { ErrorMessages, setResponseValueAndErrors } from '../errorMessages';
|
||||
import { Refs } from '../Refs';
|
||||
|
||||
|
||||
2
node_modules/openai/src/_vendor/zod-to-json-schema/parsers/tuple.ts
generated
vendored
2
node_modules/openai/src/_vendor/zod-to-json-schema/parsers/tuple.ts
generated
vendored
@@ -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';
|
||||
|
||||
|
||||
2
node_modules/openai/src/_vendor/zod-to-json-schema/parsers/union.ts
generated
vendored
2
node_modules/openai/src/_vendor/zod-to-json-schema/parsers/union.ts
generated
vendored
@@ -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';
|
||||
|
||||
|
||||
2
node_modules/openai/src/_vendor/zod-to-json-schema/util.ts
generated
vendored
2
node_modules/openai/src/_vendor/zod-to-json-schema/util.ts
generated
vendored
@@ -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;
|
||||
|
||||
2
node_modules/openai/src/_vendor/zod-to-json-schema/zodToJsonSchema.ts
generated
vendored
2
node_modules/openai/src/_vendor/zod-to-json-schema/zodToJsonSchema.ts
generated
vendored
@@ -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';
|
||||
|
||||
52
node_modules/openai/src/azure.ts
generated
vendored
52
node_modules/openai/src/azure.ts
generated
vendored
@@ -1,9 +1,10 @@
|
||||
import type { RequestInit } from './internal/builtin-types';
|
||||
import type { NullableHeaders } from './internal/headers';
|
||||
import { buildHeaders } from './internal/headers';
|
||||
import * as Errors from './error';
|
||||
import { FinalRequestOptions } from './internal/request-options';
|
||||
import { isObj, readEnv } from './internal/utils';
|
||||
import { ClientOptions, OpenAI } from './client';
|
||||
import { buildHeaders, NullableHeaders } from './internal/headers';
|
||||
|
||||
/** API Client for interfacing with the Azure OpenAI API. */
|
||||
export interface AzureClientOptions extends ClientOptions {
|
||||
@@ -37,7 +38,6 @@ export interface AzureClientOptions extends ClientOptions {
|
||||
|
||||
/** API Client for interfacing with the Azure OpenAI API. */
|
||||
export class AzureOpenAI extends OpenAI {
|
||||
private _azureADTokenProvider: (() => Promise<string>) | undefined;
|
||||
deploymentName: string | undefined;
|
||||
apiVersion: string = '';
|
||||
|
||||
@@ -90,9 +90,6 @@ export class AzureOpenAI extends OpenAI {
|
||||
);
|
||||
}
|
||||
|
||||
// define a sentinel value to avoid any typing issues
|
||||
apiKey ??= API_KEY_SENTINEL;
|
||||
|
||||
opts.defaultQuery = { ...opts.defaultQuery, 'api-version': apiVersion };
|
||||
|
||||
if (!baseURL) {
|
||||
@@ -114,13 +111,12 @@ export class AzureOpenAI extends OpenAI {
|
||||
}
|
||||
|
||||
super({
|
||||
apiKey,
|
||||
apiKey: azureADTokenProvider ?? apiKey,
|
||||
baseURL,
|
||||
...opts,
|
||||
...(dangerouslyAllowBrowser !== undefined ? { dangerouslyAllowBrowser } : {}),
|
||||
});
|
||||
|
||||
this._azureADTokenProvider = azureADTokenProvider;
|
||||
this.apiVersion = apiVersion;
|
||||
this.deploymentName = deployment;
|
||||
}
|
||||
@@ -141,45 +137,11 @@ export class AzureOpenAI extends OpenAI {
|
||||
return super.buildRequest(options, props);
|
||||
}
|
||||
|
||||
async _getAzureADToken(): Promise<string | undefined> {
|
||||
if (typeof this._azureADTokenProvider === 'function') {
|
||||
const token = await this._azureADTokenProvider();
|
||||
if (!token || typeof token !== 'string') {
|
||||
throw new Errors.OpenAIError(
|
||||
`Expected 'azureADTokenProvider' argument to return a string but it returned ${token}`,
|
||||
);
|
||||
}
|
||||
return token;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
protected override async authHeaders(opts: FinalRequestOptions): Promise<NullableHeaders | undefined> {
|
||||
return;
|
||||
}
|
||||
|
||||
protected override async prepareOptions(opts: FinalRequestOptions): Promise<void> {
|
||||
opts.headers = buildHeaders([opts.headers]);
|
||||
|
||||
/**
|
||||
* The user should provide a bearer token provider if they want
|
||||
* to use Azure AD authentication. The user shouldn't set the
|
||||
* Authorization header manually because the header is overwritten
|
||||
* with the Azure AD token if a bearer token provider is provided.
|
||||
*/
|
||||
if (opts.headers.values.get('Authorization') || opts.headers.values.get('api-key')) {
|
||||
return super.prepareOptions(opts);
|
||||
if (typeof this._options.apiKey === 'string') {
|
||||
return buildHeaders([{ 'api-key': this.apiKey }]);
|
||||
}
|
||||
|
||||
const token = await this._getAzureADToken();
|
||||
if (token) {
|
||||
opts.headers.values.set('Authorization', `Bearer ${token}`);
|
||||
} else if (this.apiKey !== API_KEY_SENTINEL) {
|
||||
opts.headers.values.set('api-key', this.apiKey);
|
||||
} else {
|
||||
throw new Errors.OpenAIError('Unable to handle auth');
|
||||
}
|
||||
return super.prepareOptions(opts);
|
||||
return super.authHeaders(opts);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,5 +156,3 @@ const _deployments_endpoints = new Set([
|
||||
'/batches',
|
||||
'/images/edits',
|
||||
]);
|
||||
|
||||
const API_KEY_SENTINEL = '<Missing Key>';
|
||||
|
||||
39
node_modules/openai/src/beta/realtime/websocket.ts
generated
vendored
39
node_modules/openai/src/beta/realtime/websocket.ts
generated
vendored
@@ -31,16 +31,17 @@ export class OpenAIRealtimeWebSocket extends OpenAIRealtimeEmitter {
|
||||
* @internal
|
||||
*/
|
||||
onURL?: (url: URL) => void;
|
||||
/** Indicates the token was resolved by the factory just before connecting. @internal */
|
||||
__resolvedApiKey?: boolean;
|
||||
},
|
||||
client?: Pick<OpenAI, 'apiKey' | 'baseURL'>,
|
||||
) {
|
||||
super();
|
||||
|
||||
const hasProvider = typeof (client as any)?._options?.apiKey === 'function';
|
||||
const dangerouslyAllowBrowser =
|
||||
props.dangerouslyAllowBrowser ??
|
||||
(client as any)?._options?.dangerouslyAllowBrowser ??
|
||||
(client?.apiKey.startsWith('ek_') ? true : null);
|
||||
|
||||
(client?.apiKey?.startsWith('ek_') ? true : null);
|
||||
if (!dangerouslyAllowBrowser && isRunningInBrowser()) {
|
||||
throw new OpenAIError(
|
||||
"It looks like you're running in a browser-like environment.\n\nThis is disabled by default, as it risks exposing your secret API credentials to attackers.\n\nYou can avoid this error by creating an ephemeral session token:\nhttps://platform.openai.com/docs/api-reference/realtime-sessions\n",
|
||||
@@ -49,6 +50,16 @@ export class OpenAIRealtimeWebSocket extends OpenAIRealtimeEmitter {
|
||||
|
||||
client ??= new OpenAI({ dangerouslyAllowBrowser });
|
||||
|
||||
if (hasProvider && !props?.__resolvedApiKey) {
|
||||
throw new Error(
|
||||
[
|
||||
'Cannot open Realtime WebSocket with a function-based apiKey.',
|
||||
'Use the .create() method so that the key is resolved before connecting:',
|
||||
'await OpenAIRealtimeWebSocket.create(client, { model })',
|
||||
].join('\n'),
|
||||
);
|
||||
}
|
||||
|
||||
this.url = buildRealtimeURL(client, props.model);
|
||||
props.onURL?.(this.url);
|
||||
|
||||
@@ -94,20 +105,23 @@ export class OpenAIRealtimeWebSocket extends OpenAIRealtimeEmitter {
|
||||
}
|
||||
}
|
||||
|
||||
static async create(
|
||||
client: Pick<OpenAI, 'apiKey' | 'baseURL' | '_callApiKey'>,
|
||||
props: { model: string; dangerouslyAllowBrowser?: boolean },
|
||||
): Promise<OpenAIRealtimeWebSocket> {
|
||||
return new OpenAIRealtimeWebSocket({ ...props, __resolvedApiKey: await client._callApiKey() }, client);
|
||||
}
|
||||
|
||||
static async azure(
|
||||
client: Pick<AzureOpenAI, '_getAzureADToken' | 'apiVersion' | 'apiKey' | 'baseURL' | 'deploymentName'>,
|
||||
client: Pick<AzureOpenAI, '_callApiKey' | 'apiVersion' | 'apiKey' | 'baseURL' | 'deploymentName'>,
|
||||
options: { deploymentName?: string; dangerouslyAllowBrowser?: boolean } = {},
|
||||
): Promise<OpenAIRealtimeWebSocket> {
|
||||
const token = await client._getAzureADToken();
|
||||
const isApiKeyProvider = await client._callApiKey();
|
||||
function onURL(url: URL) {
|
||||
if (client.apiKey !== '<Missing Key>') {
|
||||
url.searchParams.set('api-key', client.apiKey);
|
||||
if (isApiKeyProvider) {
|
||||
url.searchParams.set('Authorization', `Bearer ${client.apiKey}`);
|
||||
} else {
|
||||
if (token) {
|
||||
url.searchParams.set('Authorization', `Bearer ${token}`);
|
||||
} else {
|
||||
throw new Error('AzureOpenAI is not instantiated correctly. No API key or token provided.');
|
||||
}
|
||||
url.searchParams.set('api-key', client.apiKey);
|
||||
}
|
||||
}
|
||||
const deploymentName = options.deploymentName ?? client.deploymentName;
|
||||
@@ -120,6 +134,7 @@ export class OpenAIRealtimeWebSocket extends OpenAIRealtimeEmitter {
|
||||
model: deploymentName,
|
||||
onURL,
|
||||
...(dangerouslyAllowBrowser ? { dangerouslyAllowBrowser } : {}),
|
||||
__resolvedApiKey: isApiKeyProvider,
|
||||
},
|
||||
client,
|
||||
);
|
||||
|
||||
60
node_modules/openai/src/beta/realtime/ws.ts
generated
vendored
60
node_modules/openai/src/beta/realtime/ws.ts
generated
vendored
@@ -8,18 +8,31 @@ export class OpenAIRealtimeWS extends OpenAIRealtimeEmitter {
|
||||
socket: WS.WebSocket;
|
||||
|
||||
constructor(
|
||||
props: { model: string; options?: WS.ClientOptions | undefined },
|
||||
props: {
|
||||
model: string;
|
||||
options?: WS.ClientOptions | undefined;
|
||||
/** @internal */ __resolvedApiKey?: boolean;
|
||||
},
|
||||
client?: Pick<OpenAI, 'apiKey' | 'baseURL'>,
|
||||
) {
|
||||
super();
|
||||
client ??= new OpenAI();
|
||||
|
||||
const hasProvider = typeof (client as any)?._options?.apiKey === 'function';
|
||||
if (hasProvider && !props.__resolvedApiKey) {
|
||||
throw new Error(
|
||||
[
|
||||
'Cannot open Realtime WebSocket with a function-based apiKey.',
|
||||
'Use the .create() method so that the key is resolved before connecting:',
|
||||
'await OpenAIRealtimeWS.create(client, { model })',
|
||||
].join('\n'),
|
||||
);
|
||||
}
|
||||
this.url = buildRealtimeURL(client, props.model);
|
||||
this.socket = new WS.WebSocket(this.url, {
|
||||
...props.options,
|
||||
headers: {
|
||||
...props.options?.headers,
|
||||
...(isAzure(client) ? {} : { Authorization: `Bearer ${client.apiKey}` }),
|
||||
...(isAzure(client) && !props.__resolvedApiKey ? {} : { Authorization: `Bearer ${client.apiKey}` }),
|
||||
'OpenAI-Beta': 'realtime=v1',
|
||||
},
|
||||
});
|
||||
@@ -51,16 +64,34 @@ export class OpenAIRealtimeWS extends OpenAIRealtimeEmitter {
|
||||
});
|
||||
}
|
||||
|
||||
static async azure(
|
||||
client: Pick<AzureOpenAI, '_getAzureADToken' | 'apiVersion' | 'apiKey' | 'baseURL' | 'deploymentName'>,
|
||||
options: { deploymentName?: string; options?: WS.ClientOptions | undefined } = {},
|
||||
static async create(
|
||||
client: Pick<OpenAI, 'apiKey' | 'baseURL' | '_callApiKey'>,
|
||||
props: { model: string; options?: WS.ClientOptions | undefined },
|
||||
): Promise<OpenAIRealtimeWS> {
|
||||
const deploymentName = options.deploymentName ?? client.deploymentName;
|
||||
return new OpenAIRealtimeWS({ ...props, __resolvedApiKey: await client._callApiKey() }, client);
|
||||
}
|
||||
|
||||
static async azure(
|
||||
client: Pick<AzureOpenAI, '_callApiKey' | 'apiVersion' | 'apiKey' | 'baseURL' | 'deploymentName'>,
|
||||
props: { deploymentName?: string; options?: WS.ClientOptions | undefined } = {},
|
||||
): Promise<OpenAIRealtimeWS> {
|
||||
const isApiKeyProvider = await client._callApiKey();
|
||||
const deploymentName = props.deploymentName ?? client.deploymentName;
|
||||
if (!deploymentName) {
|
||||
throw new Error('No deployment name provided');
|
||||
}
|
||||
return new OpenAIRealtimeWS(
|
||||
{ model: deploymentName, options: { headers: await getAzureHeaders(client) } },
|
||||
{
|
||||
model: deploymentName,
|
||||
options: {
|
||||
...props.options,
|
||||
headers: {
|
||||
...props.options?.headers,
|
||||
...(isApiKeyProvider ? {} : { 'api-key': client.apiKey }),
|
||||
},
|
||||
},
|
||||
__resolvedApiKey: isApiKeyProvider,
|
||||
},
|
||||
client,
|
||||
);
|
||||
}
|
||||
@@ -81,16 +112,3 @@ export class OpenAIRealtimeWS extends OpenAIRealtimeEmitter {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function getAzureHeaders(client: Pick<AzureOpenAI, '_getAzureADToken' | 'apiKey'>) {
|
||||
if (client.apiKey !== '<Missing Key>') {
|
||||
return { 'api-key': client.apiKey };
|
||||
} else {
|
||||
const token = await client._getAzureADToken();
|
||||
if (token) {
|
||||
return { Authorization: `Bearer ${token}` };
|
||||
} else {
|
||||
throw new Error('AzureOpenAI is not instantiated correctly. No API key or token provided.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
90
node_modules/openai/src/client.ts
generated
vendored
90
node_modules/openai/src/client.ts
generated
vendored
@@ -32,6 +32,7 @@ import {
|
||||
BatchError,
|
||||
BatchListParams,
|
||||
BatchRequestCounts,
|
||||
BatchUsage,
|
||||
Batches,
|
||||
BatchesPage,
|
||||
} from './resources/batches';
|
||||
@@ -91,6 +92,20 @@ import {
|
||||
ModerationTextInput,
|
||||
Moderations,
|
||||
} from './resources/moderations';
|
||||
import {
|
||||
Video,
|
||||
VideoCreateError,
|
||||
VideoCreateParams,
|
||||
VideoDeleteResponse,
|
||||
VideoDownloadContentParams,
|
||||
VideoListParams,
|
||||
VideoModel,
|
||||
VideoRemixParams,
|
||||
VideoSeconds,
|
||||
VideoSize,
|
||||
Videos,
|
||||
VideosPage,
|
||||
} from './resources/videos';
|
||||
import { Webhooks } from './resources/webhooks';
|
||||
import { Audio, AudioModel, AudioResponseFormat } from './resources/audio/audio';
|
||||
import { Beta } from './resources/beta/beta';
|
||||
@@ -121,6 +136,7 @@ import {
|
||||
} from './resources/evals/evals';
|
||||
import { FineTuning } from './resources/fine-tuning/fine-tuning';
|
||||
import { Graders } from './resources/graders/graders';
|
||||
import { Realtime } from './resources/realtime/realtime';
|
||||
import { Responses } from './resources/responses/responses';
|
||||
import {
|
||||
Upload,
|
||||
@@ -206,12 +222,21 @@ import {
|
||||
} from './internal/utils/log';
|
||||
import { isEmptyObj } from './internal/utils/values';
|
||||
|
||||
export type ApiKeySetter = () => Promise<string>;
|
||||
|
||||
export interface ClientOptions {
|
||||
/**
|
||||
* Defaults to process.env['OPENAI_API_KEY'].
|
||||
* API key used for authentication.
|
||||
*
|
||||
* - Accepts either a static string or an async function that resolves to a string.
|
||||
* - Defaults to process.env['OPENAI_API_KEY'].
|
||||
* - When a function is provided, it is invoked before each request so you can rotate
|
||||
* or refresh credentials at runtime.
|
||||
* - The function must return a non-empty string; otherwise an OpenAIError is thrown.
|
||||
* - If the function throws, the error is wrapped in an OpenAIError with the original
|
||||
* error available as `cause`.
|
||||
*/
|
||||
apiKey?: string | undefined;
|
||||
|
||||
apiKey?: string | ApiKeySetter | undefined;
|
||||
/**
|
||||
* Defaults to process.env['OPENAI_ORG_ID'].
|
||||
*/
|
||||
@@ -321,7 +346,7 @@ export class OpenAI {
|
||||
private fetch: Fetch;
|
||||
#encoder: Opts.RequestEncoder;
|
||||
protected idempotencyHeader?: string;
|
||||
private _options: ClientOptions;
|
||||
protected _options: ClientOptions;
|
||||
|
||||
/**
|
||||
* API Client for interfacing with the OpenAI API.
|
||||
@@ -349,7 +374,7 @@ export class OpenAI {
|
||||
}: ClientOptions = {}) {
|
||||
if (apiKey === undefined) {
|
||||
throw new Errors.OpenAIError(
|
||||
"The OPENAI_API_KEY environment variable is missing or empty; either provide it, or instantiate the OpenAI client with an apiKey option, like new OpenAI({ apiKey: 'My API Key' }).",
|
||||
'Missing credentials. Please pass an `apiKey`, or set the `OPENAI_API_KEY` environment variable.',
|
||||
);
|
||||
}
|
||||
|
||||
@@ -385,7 +410,7 @@ export class OpenAI {
|
||||
|
||||
this._options = options;
|
||||
|
||||
this.apiKey = apiKey;
|
||||
this.apiKey = typeof apiKey === 'string' ? apiKey : 'Missing Key';
|
||||
this.organization = organization;
|
||||
this.project = project;
|
||||
this.webhookSecret = webhookSecret;
|
||||
@@ -453,6 +478,31 @@ export class OpenAI {
|
||||
return Errors.APIError.generate(status, error, message, headers);
|
||||
}
|
||||
|
||||
async _callApiKey(): Promise<boolean> {
|
||||
const apiKey = this._options.apiKey;
|
||||
if (typeof apiKey !== 'function') return false;
|
||||
|
||||
let token: unknown;
|
||||
try {
|
||||
token = await apiKey();
|
||||
} catch (err: any) {
|
||||
if (err instanceof Errors.OpenAIError) throw err;
|
||||
throw new Errors.OpenAIError(
|
||||
`Failed to get token from 'apiKey' function: ${err.message}`,
|
||||
// @ts-ignore
|
||||
{ cause: err },
|
||||
);
|
||||
}
|
||||
|
||||
if (typeof token !== 'string' || !token) {
|
||||
throw new Errors.OpenAIError(
|
||||
`Expected 'apiKey' function argument to return a string but it returned ${token}`,
|
||||
);
|
||||
}
|
||||
this.apiKey = token;
|
||||
return true;
|
||||
}
|
||||
|
||||
buildURL(
|
||||
path: string,
|
||||
query: Record<string, unknown> | null | undefined,
|
||||
@@ -479,7 +529,9 @@ export class OpenAI {
|
||||
/**
|
||||
* Used as a callback for mutating the given `FinalRequestOptions` object.
|
||||
*/
|
||||
protected async prepareOptions(options: FinalRequestOptions): Promise<void> {}
|
||||
protected async prepareOptions(options: FinalRequestOptions): Promise<void> {
|
||||
await this._callApiKey();
|
||||
}
|
||||
|
||||
/**
|
||||
* Used as a callback for mutating the given `RequestInit` object.
|
||||
@@ -574,7 +626,7 @@ export class OpenAI {
|
||||
const response = await this.fetchWithTimeout(url, req, timeout, controller).catch(castToError);
|
||||
const headersTime = Date.now();
|
||||
|
||||
if (response instanceof Error) {
|
||||
if (response instanceof globalThis.Error) {
|
||||
const retryMessage = `retrying, ${retriesRemaining} attempts remaining`;
|
||||
if (options.signal?.aborted) {
|
||||
throw new Errors.APIUserAbortError();
|
||||
@@ -962,9 +1014,11 @@ export class OpenAI {
|
||||
batches: API.Batches = new API.Batches(this);
|
||||
uploads: API.Uploads = new API.Uploads(this);
|
||||
responses: API.Responses = new API.Responses(this);
|
||||
realtime: API.Realtime = new API.Realtime(this);
|
||||
conversations: API.Conversations = new API.Conversations(this);
|
||||
evals: API.Evals = new API.Evals(this);
|
||||
containers: API.Containers = new API.Containers(this);
|
||||
videos: API.Videos = new API.Videos(this);
|
||||
}
|
||||
|
||||
OpenAI.Completions = Completions;
|
||||
@@ -983,9 +1037,11 @@ OpenAI.Beta = Beta;
|
||||
OpenAI.Batches = Batches;
|
||||
OpenAI.Uploads = UploadsAPIUploads;
|
||||
OpenAI.Responses = Responses;
|
||||
OpenAI.Realtime = Realtime;
|
||||
OpenAI.Conversations = Conversations;
|
||||
OpenAI.Evals = Evals;
|
||||
OpenAI.Containers = Containers;
|
||||
OpenAI.Videos = Videos;
|
||||
|
||||
export declare namespace OpenAI {
|
||||
export type RequestOptions = Opts.RequestOptions;
|
||||
@@ -1151,6 +1207,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,
|
||||
@@ -1165,6 +1222,8 @@ export declare namespace OpenAI {
|
||||
|
||||
export { Responses as Responses };
|
||||
|
||||
export { Realtime as Realtime };
|
||||
|
||||
export { Conversations as Conversations };
|
||||
|
||||
export {
|
||||
@@ -1192,6 +1251,21 @@ export declare namespace OpenAI {
|
||||
type ContainerListParams as ContainerListParams,
|
||||
};
|
||||
|
||||
export {
|
||||
Videos as Videos,
|
||||
type Video as Video,
|
||||
type VideoCreateError as VideoCreateError,
|
||||
type VideoModel as VideoModel,
|
||||
type VideoSeconds as VideoSeconds,
|
||||
type VideoSize as VideoSize,
|
||||
type VideoDeleteResponse as VideoDeleteResponse,
|
||||
type VideosPage as VideosPage,
|
||||
type VideoCreateParams as VideoCreateParams,
|
||||
type VideoListParams as VideoListParams,
|
||||
type VideoDownloadContentParams as VideoDownloadContentParams,
|
||||
type VideoRemixParams as VideoRemixParams,
|
||||
};
|
||||
|
||||
export type AllModels = API.AllModels;
|
||||
export type ChatModel = API.ChatModel;
|
||||
export type ComparisonFilter = API.ComparisonFilter;
|
||||
|
||||
58
node_modules/openai/src/helpers/zod.ts
generated
vendored
58
node_modules/openai/src/helpers/zod.ts
generated
vendored
@@ -1,5 +1,6 @@
|
||||
import { ResponseFormatJSONSchema } from '../resources/index';
|
||||
import type { infer as zodInfer, ZodType } from 'zod';
|
||||
import * as z3 from 'zod/v3';
|
||||
import * as z4 from 'zod/v4';
|
||||
import {
|
||||
AutoParseableResponseFormat,
|
||||
AutoParseableTextFormat,
|
||||
@@ -11,8 +12,15 @@ import {
|
||||
import { zodToJsonSchema as _zodToJsonSchema } from '../_vendor/zod-to-json-schema';
|
||||
import { AutoParseableResponseTool, makeParseableResponseTool } from '../lib/ResponsesParser';
|
||||
import { type ResponseFormatTextJSONSchemaConfig } from '../resources/responses/responses';
|
||||
import { toStrictJsonSchema } from '../lib/transform';
|
||||
import { JSONSchema } from '../lib/jsonschema';
|
||||
|
||||
function zodToJsonSchema(schema: ZodType, options: { name: string }): Record<string, unknown> {
|
||||
type InferZodType<T> =
|
||||
T extends z4.ZodType ? z4.infer<T>
|
||||
: T extends z3.ZodType ? z3.infer<T>
|
||||
: never;
|
||||
|
||||
function zodV3ToJsonSchema(schema: z3.ZodType, options: { name: string }): Record<string, unknown> {
|
||||
return _zodToJsonSchema(schema, {
|
||||
openaiStrictMode: true,
|
||||
name: options.name,
|
||||
@@ -22,6 +30,18 @@ function zodToJsonSchema(schema: ZodType, options: { name: string }): Record<str
|
||||
});
|
||||
}
|
||||
|
||||
function zodV4ToJsonSchema(schema: z4.ZodType): Record<string, unknown> {
|
||||
return toStrictJsonSchema(
|
||||
z4.toJSONSchema(schema, {
|
||||
target: 'draft-7',
|
||||
}) as JSONSchema,
|
||||
) as Record<string, unknown>;
|
||||
}
|
||||
|
||||
function isZodV4(zodObject: z3.ZodType | z4.ZodType): zodObject is z4.ZodType {
|
||||
return '_zod' in zodObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a chat completion `JSONSchema` response format object from
|
||||
* the given Zod schema.
|
||||
@@ -59,11 +79,11 @@ function zodToJsonSchema(schema: ZodType, options: { name: string }): Record<str
|
||||
* This can be passed directly to the `.create()` method but will not
|
||||
* result in any automatic parsing, you'll have to parse the response yourself.
|
||||
*/
|
||||
export function zodResponseFormat<ZodInput extends ZodType>(
|
||||
export function zodResponseFormat<ZodInput extends z3.ZodType | z4.ZodType>(
|
||||
zodObject: ZodInput,
|
||||
name: string,
|
||||
props?: Omit<ResponseFormatJSONSchema.JSONSchema, 'schema' | 'strict' | 'name'>,
|
||||
): AutoParseableResponseFormat<zodInfer<ZodInput>> {
|
||||
): AutoParseableResponseFormat<InferZodType<ZodInput>> {
|
||||
return makeParseableResponseFormat(
|
||||
{
|
||||
type: 'json_schema',
|
||||
@@ -71,25 +91,25 @@ export function zodResponseFormat<ZodInput extends ZodType>(
|
||||
...props,
|
||||
name,
|
||||
strict: true,
|
||||
schema: zodToJsonSchema(zodObject, { name }),
|
||||
schema: isZodV4(zodObject) ? zodV4ToJsonSchema(zodObject) : zodV3ToJsonSchema(zodObject, { name }),
|
||||
},
|
||||
},
|
||||
(content) => zodObject.parse(JSON.parse(content)),
|
||||
);
|
||||
}
|
||||
|
||||
export function zodTextFormat<ZodInput extends ZodType>(
|
||||
export function zodTextFormat<ZodInput extends z3.ZodType | z4.ZodType>(
|
||||
zodObject: ZodInput,
|
||||
name: string,
|
||||
props?: Omit<ResponseFormatTextJSONSchemaConfig, 'schema' | 'type' | 'strict' | 'name'>,
|
||||
): AutoParseableTextFormat<zodInfer<ZodInput>> {
|
||||
): AutoParseableTextFormat<InferZodType<ZodInput>> {
|
||||
return makeParseableTextFormat(
|
||||
{
|
||||
type: 'json_schema',
|
||||
...props,
|
||||
name,
|
||||
strict: true,
|
||||
schema: zodToJsonSchema(zodObject, { name }),
|
||||
schema: isZodV4(zodObject) ? zodV4ToJsonSchema(zodObject) : zodV3ToJsonSchema(zodObject, { name }),
|
||||
},
|
||||
(content) => zodObject.parse(JSON.parse(content)),
|
||||
);
|
||||
@@ -100,15 +120,15 @@ export function zodTextFormat<ZodInput extends ZodType>(
|
||||
* automatically by the chat completion `.runTools()` method or automatically
|
||||
* parsed by `.parse()` / `.stream()`.
|
||||
*/
|
||||
export function zodFunction<Parameters extends ZodType>(options: {
|
||||
export function zodFunction<Parameters extends z3.ZodType | z4.ZodType>(options: {
|
||||
name: string;
|
||||
parameters: Parameters;
|
||||
function?: ((args: zodInfer<Parameters>) => unknown | Promise<unknown>) | undefined;
|
||||
function?: ((args: InferZodType<Parameters>) => unknown | Promise<unknown>) | undefined;
|
||||
description?: string | undefined;
|
||||
}): AutoParseableTool<{
|
||||
arguments: Parameters;
|
||||
name: string;
|
||||
function: (args: zodInfer<Parameters>) => unknown;
|
||||
function: (args: InferZodType<Parameters>) => unknown;
|
||||
}> {
|
||||
// @ts-expect-error TODO
|
||||
return makeParseableTool<any>(
|
||||
@@ -116,7 +136,10 @@ export function zodFunction<Parameters extends ZodType>(options: {
|
||||
type: 'function',
|
||||
function: {
|
||||
name: options.name,
|
||||
parameters: zodToJsonSchema(options.parameters, { name: options.name }),
|
||||
parameters:
|
||||
isZodV4(options.parameters) ?
|
||||
zodV4ToJsonSchema(options.parameters)
|
||||
: zodV3ToJsonSchema(options.parameters, { name: options.name }),
|
||||
strict: true,
|
||||
...(options.description ? { description: options.description } : undefined),
|
||||
},
|
||||
@@ -128,21 +151,24 @@ export function zodFunction<Parameters extends ZodType>(options: {
|
||||
);
|
||||
}
|
||||
|
||||
export function zodResponsesFunction<Parameters extends ZodType>(options: {
|
||||
export function zodResponsesFunction<Parameters extends z3.ZodType | z4.ZodType>(options: {
|
||||
name: string;
|
||||
parameters: Parameters;
|
||||
function?: ((args: zodInfer<Parameters>) => unknown | Promise<unknown>) | undefined;
|
||||
function?: ((args: InferZodType<Parameters>) => unknown | Promise<unknown>) | undefined;
|
||||
description?: string | undefined;
|
||||
}): AutoParseableResponseTool<{
|
||||
arguments: Parameters;
|
||||
name: string;
|
||||
function: (args: zodInfer<Parameters>) => unknown;
|
||||
function: (args: InferZodType<Parameters>) => unknown;
|
||||
}> {
|
||||
return makeParseableResponseTool<any>(
|
||||
{
|
||||
type: 'function',
|
||||
name: options.name,
|
||||
parameters: zodToJsonSchema(options.parameters, { name: options.name }),
|
||||
parameters:
|
||||
isZodV4(options.parameters) ?
|
||||
zodV4ToJsonSchema(options.parameters)
|
||||
: zodV3ToJsonSchema(options.parameters, { name: options.name }),
|
||||
strict: true,
|
||||
...(options.description ? { description: options.description } : undefined),
|
||||
},
|
||||
|
||||
2
node_modules/openai/src/internal/to-file.ts
generated
vendored
2
node_modules/openai/src/internal/to-file.ts
generated
vendored
@@ -73,7 +73,7 @@ export type ToFileInput =
|
||||
|
||||
/**
|
||||
* Helper for creating a {@link File} to pass to an SDK upload method from a variety of different data formats
|
||||
* @param value the raw content of the file. Can be an {@link Uploadable}, {@link BlobLikePart}, or {@link AsyncIterable} of {@link BlobLikePart}s
|
||||
* @param value the raw content of the file. Can be an {@link Uploadable}, BlobLikePart, or AsyncIterable of BlobLikeParts
|
||||
* @param {string=} name the name of the file. If omitted, toFile will try to determine a file name from bits if possible
|
||||
* @param {Object=} options additional properties
|
||||
* @param {string=} options.type the MIME type of the content
|
||||
|
||||
6
node_modules/openai/src/internal/utils/values.ts
generated
vendored
6
node_modules/openai/src/internal/utils/values.ts
generated
vendored
@@ -76,21 +76,21 @@ export const coerceBoolean = (value: unknown): boolean => {
|
||||
};
|
||||
|
||||
export const maybeCoerceInteger = (value: unknown): number | undefined => {
|
||||
if (value === undefined) {
|
||||
if (value == null) {
|
||||
return undefined;
|
||||
}
|
||||
return coerceInteger(value);
|
||||
};
|
||||
|
||||
export const maybeCoerceFloat = (value: unknown): number | undefined => {
|
||||
if (value === undefined) {
|
||||
if (value == null) {
|
||||
return undefined;
|
||||
}
|
||||
return coerceFloat(value);
|
||||
};
|
||||
|
||||
export const maybeCoerceBoolean = (value: unknown): boolean | undefined => {
|
||||
if (value === undefined) {
|
||||
if (value == null) {
|
||||
return undefined;
|
||||
}
|
||||
return coerceBoolean(value);
|
||||
|
||||
24
node_modules/openai/src/lib/jsonschema.ts
generated
vendored
24
node_modules/openai/src/lib/jsonschema.ts
generated
vendored
@@ -131,6 +131,30 @@ export interface JSONSchema {
|
||||
oneOf?: JSONSchemaDefinition[] | undefined;
|
||||
not?: JSONSchemaDefinition | undefined;
|
||||
|
||||
/**
|
||||
* @see https://json-schema.org/draft/2020-12/json-schema-core.html#section-8.2.4
|
||||
*/
|
||||
$defs?:
|
||||
| {
|
||||
[key: string]: JSONSchemaDefinition;
|
||||
}
|
||||
| undefined;
|
||||
|
||||
/**
|
||||
* @deprecated Use $defs instead (draft 2019-09+)
|
||||
* @see https://tools.ietf.org/doc/html/draft-handrews-json-schema-validation-01#page-22
|
||||
*/
|
||||
definitions?:
|
||||
| {
|
||||
[key: string]: JSONSchemaDefinition;
|
||||
}
|
||||
| undefined;
|
||||
|
||||
/**
|
||||
* @see https://json-schema.org/draft/2020-12/json-schema-core#ref
|
||||
*/
|
||||
$ref?: string | undefined;
|
||||
|
||||
/**
|
||||
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-7
|
||||
*/
|
||||
|
||||
28
node_modules/openai/src/lib/responses/ResponseStream.ts
generated
vendored
28
node_modules/openai/src/lib/responses/ResponseStream.ts
generated
vendored
@@ -222,8 +222,15 @@ export class ResponseStream<ParsedT = null>
|
||||
if (!output) {
|
||||
throw new OpenAIError(`missing output at index ${event.output_index}`);
|
||||
}
|
||||
if (output.type === 'message') {
|
||||
output.content.push(event.part);
|
||||
const type = output.type;
|
||||
const part = event.part;
|
||||
if (type === 'message' && part.type !== 'reasoning_text') {
|
||||
output.content.push(part);
|
||||
} else if (type === 'reasoning' && part.type === 'reasoning_text') {
|
||||
if (!output.content) {
|
||||
output.content = [];
|
||||
}
|
||||
output.content.push(part);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -254,6 +261,23 @@ export class ResponseStream<ParsedT = null>
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'response.reasoning_text.delta': {
|
||||
const output = snapshot.output[event.output_index];
|
||||
if (!output) {
|
||||
throw new OpenAIError(`missing output at index ${event.output_index}`);
|
||||
}
|
||||
if (output.type === 'reasoning') {
|
||||
const content = output.content?.[event.content_index];
|
||||
if (!content) {
|
||||
throw new OpenAIError(`missing content at index ${event.content_index}`);
|
||||
}
|
||||
if (content.type !== 'reasoning_text') {
|
||||
throw new OpenAIError(`expected content to be 'reasoning_text', got ${content.type}`);
|
||||
}
|
||||
content.text += event.delta;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'response.completed': {
|
||||
this.#currentResponseSnapshot = event.response;
|
||||
break;
|
||||
|
||||
193
node_modules/openai/src/lib/transform.ts
generated
vendored
Normal file
193
node_modules/openai/src/lib/transform.ts
generated
vendored
Normal file
@@ -0,0 +1,193 @@
|
||||
import type { JSONSchema, JSONSchemaDefinition } from './jsonschema';
|
||||
|
||||
export function toStrictJsonSchema(schema: JSONSchema): JSONSchema {
|
||||
if (schema.type !== 'object') {
|
||||
throw new Error(
|
||||
`Root schema must have type: 'object' but got type: ${schema.type ? `'${schema.type}'` : 'undefined'}`,
|
||||
);
|
||||
}
|
||||
|
||||
const schemaCopy = structuredClone(schema);
|
||||
return ensureStrictJsonSchema(schemaCopy, [], schemaCopy);
|
||||
}
|
||||
|
||||
function isNullable(schema: JSONSchemaDefinition): boolean {
|
||||
if (typeof schema === 'boolean') {
|
||||
return false;
|
||||
}
|
||||
if (schema.type === 'null') {
|
||||
return true;
|
||||
}
|
||||
for (const oneOfVariant of schema.oneOf ?? []) {
|
||||
if (isNullable(oneOfVariant)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
for (const allOfVariant of schema.anyOf ?? []) {
|
||||
if (isNullable(allOfVariant)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mutates the given JSON schema to ensure it conforms to the `strict` standard
|
||||
* that the API expects.
|
||||
*/
|
||||
function ensureStrictJsonSchema(
|
||||
jsonSchema: JSONSchemaDefinition,
|
||||
path: string[],
|
||||
root: JSONSchema,
|
||||
): JSONSchema {
|
||||
if (typeof jsonSchema === 'boolean') {
|
||||
throw new TypeError(`Expected object schema but got boolean; path=${path.join('/')}`);
|
||||
}
|
||||
|
||||
if (!isObject(jsonSchema)) {
|
||||
throw new TypeError(`Expected ${JSON.stringify(jsonSchema)} to be an object; path=${path.join('/')}`);
|
||||
}
|
||||
|
||||
// Handle $defs (non-standard but sometimes used)
|
||||
const defs = (jsonSchema as any).$defs;
|
||||
if (isObject(defs)) {
|
||||
for (const [defName, defSchema] of Object.entries(defs)) {
|
||||
ensureStrictJsonSchema(defSchema as JSONSchema, [...path, '$defs', defName], root);
|
||||
}
|
||||
}
|
||||
|
||||
// Handle definitions (draft-04 style, deprecated in draft-07 but still used)
|
||||
const definitions = (jsonSchema as any).definitions;
|
||||
if (isObject(definitions)) {
|
||||
for (const [definitionName, definitionSchema] of Object.entries(definitions)) {
|
||||
ensureStrictJsonSchema(definitionSchema as JSONSchema, [...path, 'definitions', definitionName], root);
|
||||
}
|
||||
}
|
||||
|
||||
// Add additionalProperties: false to object types
|
||||
const typ = jsonSchema.type;
|
||||
if (typ === 'object' && !('additionalProperties' in jsonSchema)) {
|
||||
jsonSchema.additionalProperties = false;
|
||||
}
|
||||
|
||||
const required = jsonSchema.required ?? [];
|
||||
|
||||
// Handle object properties
|
||||
const properties = jsonSchema.properties;
|
||||
if (isObject(properties)) {
|
||||
for (const [key, value] of Object.entries(properties)) {
|
||||
if (!isNullable(value) && !required.includes(key)) {
|
||||
throw new Error(
|
||||
`Zod field at \`${[...path, 'properties', key].join(
|
||||
'/',
|
||||
)}\` uses \`.optional()\` without \`.nullable()\` which is not supported by the API. See: https://platform.openai.com/docs/guides/structured-outputs?api-mode=responses#all-fields-must-be-required`,
|
||||
);
|
||||
}
|
||||
}
|
||||
jsonSchema.required = Object.keys(properties);
|
||||
jsonSchema.properties = Object.fromEntries(
|
||||
Object.entries(properties).map(([key, propSchema]) => [
|
||||
key,
|
||||
ensureStrictJsonSchema(propSchema, [...path, 'properties', key], root),
|
||||
]),
|
||||
);
|
||||
}
|
||||
|
||||
// Handle arrays
|
||||
const items = jsonSchema.items;
|
||||
if (isObject(items)) {
|
||||
jsonSchema.items = ensureStrictJsonSchema(items, [...path, 'items'], root);
|
||||
}
|
||||
|
||||
// Handle unions (anyOf)
|
||||
const anyOf = jsonSchema.anyOf;
|
||||
if (Array.isArray(anyOf)) {
|
||||
jsonSchema.anyOf = anyOf.map((variant, i) =>
|
||||
ensureStrictJsonSchema(variant, [...path, 'anyOf', String(i)], root),
|
||||
);
|
||||
}
|
||||
|
||||
// Handle intersections (allOf)
|
||||
const allOf = jsonSchema.allOf;
|
||||
if (Array.isArray(allOf)) {
|
||||
if (allOf.length === 1) {
|
||||
const resolved = ensureStrictJsonSchema(allOf[0]!, [...path, 'allOf', '0'], root);
|
||||
Object.assign(jsonSchema, resolved);
|
||||
delete jsonSchema.allOf;
|
||||
} else {
|
||||
jsonSchema.allOf = allOf.map((entry, i) =>
|
||||
ensureStrictJsonSchema(entry, [...path, 'allOf', String(i)], root),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Strip `null` defaults as there's no meaningful distinction
|
||||
if (jsonSchema.default === null) {
|
||||
delete jsonSchema.default;
|
||||
}
|
||||
|
||||
// Handle $ref with additional properties
|
||||
const ref = (jsonSchema as any).$ref;
|
||||
if (ref && hasMoreThanNKeys(jsonSchema, 1)) {
|
||||
if (typeof ref !== 'string') {
|
||||
throw new TypeError(`Received non-string $ref - ${ref}; path=${path.join('/')}`);
|
||||
}
|
||||
|
||||
const resolved = resolveRef(root, ref);
|
||||
if (typeof resolved === 'boolean') {
|
||||
throw new Error(`Expected \`$ref: ${ref}\` to resolve to an object schema but got boolean`);
|
||||
}
|
||||
if (!isObject(resolved)) {
|
||||
throw new Error(
|
||||
`Expected \`$ref: ${ref}\` to resolve to an object but got ${JSON.stringify(resolved)}`,
|
||||
);
|
||||
}
|
||||
|
||||
// Properties from the json schema take priority over the ones on the `$ref`
|
||||
Object.assign(jsonSchema, { ...resolved, ...jsonSchema });
|
||||
delete (jsonSchema as any).$ref;
|
||||
|
||||
// Since the schema expanded from `$ref` might not have `additionalProperties: false` applied,
|
||||
// we call `ensureStrictJsonSchema` again to fix the inlined schema and ensure it's valid.
|
||||
return ensureStrictJsonSchema(jsonSchema, path, root);
|
||||
}
|
||||
|
||||
return jsonSchema;
|
||||
}
|
||||
|
||||
function resolveRef(root: JSONSchema, ref: string): JSONSchemaDefinition {
|
||||
if (!ref.startsWith('#/')) {
|
||||
throw new Error(`Unexpected $ref format ${JSON.stringify(ref)}; Does not start with #/`);
|
||||
}
|
||||
|
||||
const pathParts = ref.slice(2).split('/');
|
||||
let resolved: any = root;
|
||||
|
||||
for (const key of pathParts) {
|
||||
if (!isObject(resolved)) {
|
||||
throw new Error(`encountered non-object entry while resolving ${ref} - ${JSON.stringify(resolved)}`);
|
||||
}
|
||||
const value = resolved[key];
|
||||
if (value === undefined) {
|
||||
throw new Error(`Key ${key} not found while resolving ${ref}`);
|
||||
}
|
||||
resolved = value;
|
||||
}
|
||||
|
||||
return resolved;
|
||||
}
|
||||
|
||||
function isObject<T>(obj: T | Array<any>): obj is Extract<T, Record<string, any>> {
|
||||
return typeof obj === 'object' && obj !== null && !Array.isArray(obj);
|
||||
}
|
||||
|
||||
function hasMoreThanNKeys(obj: Record<string, any>, n: number): boolean {
|
||||
let i = 0;
|
||||
for (const _ in obj) {
|
||||
i++;
|
||||
if (i > n) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
1
node_modules/openai/src/realtime/index.ts
generated
vendored
Normal file
1
node_modules/openai/src/realtime/index.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export { OpenAIRealtimeError } from './internal-base';
|
||||
98
node_modules/openai/src/realtime/internal-base.ts
generated
vendored
Normal file
98
node_modules/openai/src/realtime/internal-base.ts
generated
vendored
Normal file
@@ -0,0 +1,98 @@
|
||||
import {
|
||||
RealtimeClientEvent,
|
||||
RealtimeServerEvent,
|
||||
RealtimeErrorEvent,
|
||||
RealtimeError,
|
||||
} from '../resources/realtime/realtime';
|
||||
import { EventEmitter } from '../lib/EventEmitter';
|
||||
import { OpenAIError } from '../error';
|
||||
import OpenAI, { AzureOpenAI } from '../index';
|
||||
|
||||
export class OpenAIRealtimeError extends OpenAIError {
|
||||
/**
|
||||
* The error data that the API sent back in an `error` event.
|
||||
*/
|
||||
error?: RealtimeError | undefined;
|
||||
|
||||
/**
|
||||
* The unique ID of the server event.
|
||||
*/
|
||||
event_id?: string | undefined;
|
||||
|
||||
constructor(message: string, event: RealtimeErrorEvent | null) {
|
||||
super(message);
|
||||
|
||||
this.error = event?.error;
|
||||
this.event_id = event?.event_id;
|
||||
}
|
||||
}
|
||||
|
||||
type Simplify<T> = { [KeyType in keyof T]: T[KeyType] } & {};
|
||||
|
||||
type RealtimeEvents = Simplify<
|
||||
{
|
||||
event: (event: RealtimeServerEvent) => void;
|
||||
error: (error: OpenAIRealtimeError) => void;
|
||||
} & {
|
||||
[EventType in Exclude<RealtimeServerEvent['type'], 'error'>]: (
|
||||
event: Extract<RealtimeServerEvent, { type: EventType }>,
|
||||
) => unknown;
|
||||
}
|
||||
>;
|
||||
|
||||
export abstract class OpenAIRealtimeEmitter extends EventEmitter<RealtimeEvents> {
|
||||
/**
|
||||
* Send an event to the API.
|
||||
*/
|
||||
abstract send(event: RealtimeClientEvent): void;
|
||||
|
||||
/**
|
||||
* Close the websocket connection.
|
||||
*/
|
||||
abstract close(props?: { code: number; reason: string }): void;
|
||||
|
||||
protected _onError(event: null, message: string, cause: any): void;
|
||||
protected _onError(event: RealtimeErrorEvent, message?: string | undefined): void;
|
||||
protected _onError(event: RealtimeErrorEvent | null, message?: string | undefined, cause?: any): void {
|
||||
message =
|
||||
event?.error ?
|
||||
`${event.error.message} code=${event.error.code} param=${event.error.param} type=${event.error.type} event_id=${event.error.event_id}`
|
||||
: message ?? 'unknown error';
|
||||
|
||||
if (!this._hasListener('error')) {
|
||||
const error = new OpenAIRealtimeError(
|
||||
message +
|
||||
`\n\nTo resolve these unhandled rejection errors you should bind an \`error\` callback, e.g. \`rt.on('error', (error) => ...)\` `,
|
||||
event,
|
||||
);
|
||||
// @ts-ignore
|
||||
error.cause = cause;
|
||||
Promise.reject(error);
|
||||
return;
|
||||
}
|
||||
|
||||
const error = new OpenAIRealtimeError(message, event);
|
||||
// @ts-ignore
|
||||
error.cause = cause;
|
||||
|
||||
this._emit('error', error);
|
||||
}
|
||||
}
|
||||
|
||||
export function isAzure(client: Pick<OpenAI, 'apiKey' | 'baseURL'>): client is AzureOpenAI {
|
||||
return client instanceof AzureOpenAI;
|
||||
}
|
||||
|
||||
export function buildRealtimeURL(client: Pick<OpenAI, 'apiKey' | 'baseURL'>, model: string): URL {
|
||||
const path = '/realtime';
|
||||
const baseURL = client.baseURL;
|
||||
const url = new URL(baseURL + (baseURL.endsWith('/') ? path.slice(1) : path));
|
||||
url.protocol = 'wss';
|
||||
if (isAzure(client)) {
|
||||
url.searchParams.set('api-version', client.apiVersion);
|
||||
url.searchParams.set('deployment', model);
|
||||
} else {
|
||||
url.searchParams.set('model', model);
|
||||
}
|
||||
return url;
|
||||
}
|
||||
157
node_modules/openai/src/realtime/websocket.ts
generated
vendored
Normal file
157
node_modules/openai/src/realtime/websocket.ts
generated
vendored
Normal file
@@ -0,0 +1,157 @@
|
||||
import { AzureOpenAI, OpenAI } from '../index';
|
||||
import { OpenAIError } from '../error';
|
||||
import type { RealtimeClientEvent, RealtimeServerEvent } from '../resources/realtime/realtime';
|
||||
import { OpenAIRealtimeEmitter, buildRealtimeURL, isAzure } from './internal-base';
|
||||
import { isRunningInBrowser } from '../internal/detect-platform';
|
||||
|
||||
interface MessageEvent {
|
||||
data: string;
|
||||
}
|
||||
|
||||
type _WebSocket =
|
||||
typeof globalThis extends (
|
||||
{
|
||||
WebSocket: infer ws extends abstract new (...args: any) => any;
|
||||
}
|
||||
) ?
|
||||
// @ts-ignore
|
||||
InstanceType<ws>
|
||||
: any;
|
||||
|
||||
export class OpenAIRealtimeWebSocket extends OpenAIRealtimeEmitter {
|
||||
url: URL;
|
||||
socket: _WebSocket;
|
||||
|
||||
constructor(
|
||||
props: {
|
||||
model: string;
|
||||
dangerouslyAllowBrowser?: boolean;
|
||||
/**
|
||||
* Callback to mutate the URL, needed for Azure.
|
||||
* @internal
|
||||
*/
|
||||
onURL?: (url: URL) => void;
|
||||
/** Indicates the token was resolved by the factory just before connecting. @internal */
|
||||
__resolvedApiKey?: boolean;
|
||||
},
|
||||
client?: Pick<OpenAI, 'apiKey' | 'baseURL'>,
|
||||
) {
|
||||
super();
|
||||
const hasProvider = typeof (client as any)?._options?.apiKey === 'function';
|
||||
const dangerouslyAllowBrowser =
|
||||
props.dangerouslyAllowBrowser ??
|
||||
(client as any)?._options?.dangerouslyAllowBrowser ??
|
||||
(client?.apiKey?.startsWith('ek_') ? true : null);
|
||||
if (!dangerouslyAllowBrowser && isRunningInBrowser()) {
|
||||
throw new OpenAIError(
|
||||
"It looks like you're running in a browser-like environment.\n\nThis is disabled by default, as it risks exposing your secret API credentials to attackers.\n\nYou can avoid this error by creating an ephemeral session token:\nhttps://platform.openai.com/docs/api-reference/realtime-sessions\n",
|
||||
);
|
||||
}
|
||||
|
||||
client ??= new OpenAI({ dangerouslyAllowBrowser });
|
||||
|
||||
if (hasProvider && !props?.__resolvedApiKey) {
|
||||
throw new Error(
|
||||
[
|
||||
'Cannot open Realtime WebSocket with a function-based apiKey.',
|
||||
'Use the .create() method so that the key is resolved before connecting:',
|
||||
'await OpenAIRealtimeWebSocket.create(client, { model })',
|
||||
].join('\n'),
|
||||
);
|
||||
}
|
||||
|
||||
this.url = buildRealtimeURL(client, props.model);
|
||||
props.onURL?.(this.url);
|
||||
|
||||
// @ts-ignore
|
||||
this.socket = new WebSocket(this.url.toString(), [
|
||||
'realtime',
|
||||
...(isAzure(client) ? [] : [`openai-insecure-api-key.${client.apiKey}`]),
|
||||
]);
|
||||
|
||||
this.socket.addEventListener('message', (websocketEvent: MessageEvent) => {
|
||||
const event = (() => {
|
||||
try {
|
||||
return JSON.parse(websocketEvent.data.toString()) as RealtimeServerEvent;
|
||||
} catch (err) {
|
||||
this._onError(null, 'could not parse websocket event', err);
|
||||
return null;
|
||||
}
|
||||
})();
|
||||
|
||||
if (event) {
|
||||
this._emit('event', event);
|
||||
|
||||
if (event.type === 'error') {
|
||||
this._onError(event);
|
||||
} else {
|
||||
// @ts-expect-error TS isn't smart enough to get the relationship right here
|
||||
this._emit(event.type, event);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
this.socket.addEventListener('error', (event: any) => {
|
||||
this._onError(null, event.message, null);
|
||||
});
|
||||
|
||||
if (isAzure(client)) {
|
||||
if (this.url.searchParams.get('Authorization') !== null) {
|
||||
this.url.searchParams.set('Authorization', '<REDACTED>');
|
||||
} else {
|
||||
this.url.searchParams.set('api-key', '<REDACTED>');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static async create(
|
||||
client: Pick<OpenAI, 'apiKey' | 'baseURL' | '_callApiKey'>,
|
||||
props: { model: string; dangerouslyAllowBrowser?: boolean },
|
||||
): Promise<OpenAIRealtimeWebSocket> {
|
||||
return new OpenAIRealtimeWebSocket({ ...props, __resolvedApiKey: await client._callApiKey() }, client);
|
||||
}
|
||||
|
||||
static async azure(
|
||||
client: Pick<AzureOpenAI, '_callApiKey' | 'apiVersion' | 'apiKey' | 'baseURL' | 'deploymentName'>,
|
||||
options: { deploymentName?: string; dangerouslyAllowBrowser?: boolean } = {},
|
||||
): Promise<OpenAIRealtimeWebSocket> {
|
||||
const isApiKeyProvider = await client._callApiKey();
|
||||
function onURL(url: URL) {
|
||||
if (isApiKeyProvider) {
|
||||
url.searchParams.set('Authorization', `Bearer ${client.apiKey}`);
|
||||
} else {
|
||||
url.searchParams.set('api-key', client.apiKey);
|
||||
}
|
||||
}
|
||||
const deploymentName = options.deploymentName ?? client.deploymentName;
|
||||
if (!deploymentName) {
|
||||
throw new Error('No deployment name provided');
|
||||
}
|
||||
const { dangerouslyAllowBrowser } = options;
|
||||
return new OpenAIRealtimeWebSocket(
|
||||
{
|
||||
model: deploymentName,
|
||||
onURL,
|
||||
...(dangerouslyAllowBrowser ? { dangerouslyAllowBrowser } : {}),
|
||||
__resolvedApiKey: isApiKeyProvider,
|
||||
},
|
||||
client,
|
||||
);
|
||||
}
|
||||
|
||||
send(event: RealtimeClientEvent) {
|
||||
try {
|
||||
this.socket.send(JSON.stringify(event));
|
||||
} catch (err) {
|
||||
this._onError(null, 'could not send data', err);
|
||||
}
|
||||
}
|
||||
|
||||
close(props?: { code: number; reason: string }) {
|
||||
try {
|
||||
this.socket.close(props?.code ?? 1000, props?.reason ?? 'OK');
|
||||
} catch (err) {
|
||||
this._onError(null, 'could not close the connection', err);
|
||||
}
|
||||
}
|
||||
}
|
||||
113
node_modules/openai/src/realtime/ws.ts
generated
vendored
Normal file
113
node_modules/openai/src/realtime/ws.ts
generated
vendored
Normal file
@@ -0,0 +1,113 @@
|
||||
import * as WS from 'ws';
|
||||
import { AzureOpenAI, OpenAI } from '../index';
|
||||
import type { RealtimeClientEvent, RealtimeServerEvent } from '../resources/realtime/realtime';
|
||||
import { OpenAIRealtimeEmitter, buildRealtimeURL, isAzure } from './internal-base';
|
||||
|
||||
export class OpenAIRealtimeWS extends OpenAIRealtimeEmitter {
|
||||
url: URL;
|
||||
socket: WS.WebSocket;
|
||||
|
||||
constructor(
|
||||
props: {
|
||||
model: string;
|
||||
options?: WS.ClientOptions | undefined;
|
||||
/** @internal */ __resolvedApiKey?: boolean;
|
||||
},
|
||||
client?: Pick<OpenAI, 'apiKey' | 'baseURL'>,
|
||||
) {
|
||||
super();
|
||||
client ??= new OpenAI();
|
||||
const hasProvider = typeof (client as any)?._options?.apiKey === 'function';
|
||||
if (hasProvider && !props.__resolvedApiKey) {
|
||||
throw new Error(
|
||||
[
|
||||
'Cannot open Realtime WebSocket with a function-based apiKey.',
|
||||
'Use the .create() method so that the key is resolved before connecting:',
|
||||
'await OpenAIRealtimeWS.create(client, { model })',
|
||||
].join('\n'),
|
||||
);
|
||||
}
|
||||
this.url = buildRealtimeURL(client, props.model);
|
||||
this.socket = new WS.WebSocket(this.url, {
|
||||
...props.options,
|
||||
headers: {
|
||||
...props.options?.headers,
|
||||
...(isAzure(client) && !props.__resolvedApiKey ? {} : { Authorization: `Bearer ${client.apiKey}` }),
|
||||
},
|
||||
});
|
||||
|
||||
this.socket.on('message', (wsEvent) => {
|
||||
const event = (() => {
|
||||
try {
|
||||
return JSON.parse(wsEvent.toString()) as RealtimeServerEvent;
|
||||
} catch (err) {
|
||||
this._onError(null, 'could not parse websocket event', err);
|
||||
return null;
|
||||
}
|
||||
})();
|
||||
|
||||
if (event) {
|
||||
this._emit('event', event);
|
||||
|
||||
if (event.type === 'error') {
|
||||
this._onError(event);
|
||||
} else {
|
||||
// @ts-expect-error TS isn't smart enough to get the relationship right here
|
||||
this._emit(event.type, event);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
this.socket.on('error', (err) => {
|
||||
this._onError(null, err.message, err);
|
||||
});
|
||||
}
|
||||
|
||||
static async create(
|
||||
client: Pick<OpenAI, 'apiKey' | 'baseURL' | '_callApiKey'>,
|
||||
props: { model: string; options?: WS.ClientOptions | undefined },
|
||||
): Promise<OpenAIRealtimeWS> {
|
||||
return new OpenAIRealtimeWS({ ...props, __resolvedApiKey: await client._callApiKey() }, client);
|
||||
}
|
||||
|
||||
static async azure(
|
||||
client: Pick<AzureOpenAI, '_callApiKey' | 'apiVersion' | 'apiKey' | 'baseURL' | 'deploymentName'>,
|
||||
props: { deploymentName?: string; options?: WS.ClientOptions | undefined } = {},
|
||||
): Promise<OpenAIRealtimeWS> {
|
||||
const isApiKeyProvider = await client._callApiKey();
|
||||
const deploymentName = props.deploymentName ?? client.deploymentName;
|
||||
if (!deploymentName) {
|
||||
throw new Error('No deployment name provided');
|
||||
}
|
||||
return new OpenAIRealtimeWS(
|
||||
{
|
||||
model: deploymentName,
|
||||
options: {
|
||||
...props.options,
|
||||
headers: {
|
||||
...props.options?.headers,
|
||||
...(isApiKeyProvider ? {} : { 'api-key': client.apiKey }),
|
||||
},
|
||||
},
|
||||
__resolvedApiKey: isApiKeyProvider,
|
||||
},
|
||||
client,
|
||||
);
|
||||
}
|
||||
|
||||
send(event: RealtimeClientEvent) {
|
||||
try {
|
||||
this.socket.send(JSON.stringify(event));
|
||||
} catch (err) {
|
||||
this._onError(null, 'could not send data', err);
|
||||
}
|
||||
}
|
||||
|
||||
close(props?: { code: number; reason: string }) {
|
||||
try {
|
||||
this.socket.close(props?.code ?? 1000, props?.reason ?? 'OK');
|
||||
} catch (err) {
|
||||
this._onError(null, 'could not close the connection', err);
|
||||
}
|
||||
}
|
||||
}
|
||||
20
node_modules/openai/src/resources/audio/audio.ts
generated
vendored
20
node_modules/openai/src/resources/audio/audio.ts
generated
vendored
@@ -10,11 +10,14 @@ import {
|
||||
TranscriptionCreateParamsNonStreaming,
|
||||
TranscriptionCreateParamsStreaming,
|
||||
TranscriptionCreateResponse,
|
||||
TranscriptionDiarized,
|
||||
TranscriptionDiarizedSegment,
|
||||
TranscriptionInclude,
|
||||
TranscriptionSegment,
|
||||
TranscriptionStreamEvent,
|
||||
TranscriptionTextDeltaEvent,
|
||||
TranscriptionTextDoneEvent,
|
||||
TranscriptionTextSegmentEvent,
|
||||
TranscriptionVerbose,
|
||||
TranscriptionWord,
|
||||
Transcriptions,
|
||||
@@ -34,14 +37,20 @@ export class Audio extends APIResource {
|
||||
speech: SpeechAPI.Speech = new SpeechAPI.Speech(this._client);
|
||||
}
|
||||
|
||||
export type AudioModel = 'whisper-1' | 'gpt-4o-transcribe' | 'gpt-4o-mini-transcribe';
|
||||
export type AudioModel =
|
||||
| 'whisper-1'
|
||||
| 'gpt-4o-transcribe'
|
||||
| 'gpt-4o-mini-transcribe'
|
||||
| 'gpt-4o-transcribe-diarize';
|
||||
|
||||
/**
|
||||
* The format of the output, in one of these options: `json`, `text`, `srt`,
|
||||
* `verbose_json`, or `vtt`. For `gpt-4o-transcribe` and `gpt-4o-mini-transcribe`,
|
||||
* the only supported format is `json`.
|
||||
* `verbose_json`, `vtt`, or `diarized_json`. For `gpt-4o-transcribe` and
|
||||
* `gpt-4o-mini-transcribe`, the only supported format is `json`. For
|
||||
* `gpt-4o-transcribe-diarize`, the supported formats are `json`, `text`, and
|
||||
* `diarized_json`, with `diarized_json` required to receive speaker annotations.
|
||||
*/
|
||||
export type AudioResponseFormat = 'json' | 'text' | 'srt' | 'verbose_json' | 'vtt';
|
||||
export type AudioResponseFormat = 'json' | 'text' | 'srt' | 'verbose_json' | 'vtt' | 'diarized_json';
|
||||
|
||||
Audio.Transcriptions = Transcriptions;
|
||||
Audio.Translations = Translations;
|
||||
@@ -53,11 +62,14 @@ export declare namespace Audio {
|
||||
export {
|
||||
Transcriptions as Transcriptions,
|
||||
type Transcription as Transcription,
|
||||
type TranscriptionDiarized as TranscriptionDiarized,
|
||||
type TranscriptionDiarizedSegment as TranscriptionDiarizedSegment,
|
||||
type TranscriptionInclude as TranscriptionInclude,
|
||||
type TranscriptionSegment as TranscriptionSegment,
|
||||
type TranscriptionStreamEvent as TranscriptionStreamEvent,
|
||||
type TranscriptionTextDeltaEvent as TranscriptionTextDeltaEvent,
|
||||
type TranscriptionTextDoneEvent as TranscriptionTextDoneEvent,
|
||||
type TranscriptionTextSegmentEvent as TranscriptionTextSegmentEvent,
|
||||
type TranscriptionVerbose as TranscriptionVerbose,
|
||||
type TranscriptionWord as TranscriptionWord,
|
||||
type TranscriptionCreateResponse as TranscriptionCreateResponse,
|
||||
|
||||
3
node_modules/openai/src/resources/audio/index.ts
generated
vendored
3
node_modules/openai/src/resources/audio/index.ts
generated
vendored
@@ -5,11 +5,14 @@ export { Speech, type SpeechModel, type SpeechCreateParams } from './speech';
|
||||
export {
|
||||
Transcriptions,
|
||||
type Transcription,
|
||||
type TranscriptionDiarized,
|
||||
type TranscriptionDiarizedSegment,
|
||||
type TranscriptionInclude,
|
||||
type TranscriptionSegment,
|
||||
type TranscriptionStreamEvent,
|
||||
type TranscriptionTextDeltaEvent,
|
||||
type TranscriptionTextDoneEvent,
|
||||
type TranscriptionTextSegmentEvent,
|
||||
type TranscriptionVerbose,
|
||||
type TranscriptionWord,
|
||||
type TranscriptionCreateResponse,
|
||||
|
||||
13
node_modules/openai/src/resources/audio/speech.ts
generated
vendored
13
node_modules/openai/src/resources/audio/speech.ts
generated
vendored
@@ -51,7 +51,18 @@ export interface SpeechCreateParams {
|
||||
* `verse`. Previews of the voices are available in the
|
||||
* [Text to speech guide](https://platform.openai.com/docs/guides/text-to-speech#voice-options).
|
||||
*/
|
||||
voice: (string & {}) | 'alloy' | 'ash' | 'ballad' | 'coral' | 'echo' | 'sage' | 'shimmer' | 'verse';
|
||||
voice:
|
||||
| (string & {})
|
||||
| 'alloy'
|
||||
| 'ash'
|
||||
| 'ballad'
|
||||
| 'coral'
|
||||
| 'echo'
|
||||
| 'sage'
|
||||
| 'shimmer'
|
||||
| 'verse'
|
||||
| 'marin'
|
||||
| 'cedar';
|
||||
|
||||
/**
|
||||
* Control the voice of your generated audio with additional instructions. Does not
|
||||
|
||||
229
node_modules/openai/src/resources/audio/transcriptions.ts
generated
vendored
229
node_modules/openai/src/resources/audio/transcriptions.ts
generated
vendored
@@ -166,6 +166,138 @@ export namespace Transcription {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a diarized transcription response returned by the model, including
|
||||
* the combined transcript and speaker-segment annotations.
|
||||
*/
|
||||
export interface TranscriptionDiarized {
|
||||
/**
|
||||
* Duration of the input audio in seconds.
|
||||
*/
|
||||
duration: number;
|
||||
|
||||
/**
|
||||
* Segments of the transcript annotated with timestamps and speaker labels.
|
||||
*/
|
||||
segments: Array<TranscriptionDiarizedSegment>;
|
||||
|
||||
/**
|
||||
* The type of task that was run. Always `transcribe`.
|
||||
*/
|
||||
task: 'transcribe';
|
||||
|
||||
/**
|
||||
* The concatenated transcript text for the entire audio input.
|
||||
*/
|
||||
text: string;
|
||||
|
||||
/**
|
||||
* Token or duration usage statistics for the request.
|
||||
*/
|
||||
usage?: TranscriptionDiarized.Tokens | TranscriptionDiarized.Duration;
|
||||
}
|
||||
|
||||
export namespace TranscriptionDiarized {
|
||||
/**
|
||||
* Usage statistics for models billed by token usage.
|
||||
*/
|
||||
export interface Tokens {
|
||||
/**
|
||||
* Number of input tokens billed for this request.
|
||||
*/
|
||||
input_tokens: number;
|
||||
|
||||
/**
|
||||
* Number of output tokens generated.
|
||||
*/
|
||||
output_tokens: number;
|
||||
|
||||
/**
|
||||
* Total number of tokens used (input + output).
|
||||
*/
|
||||
total_tokens: number;
|
||||
|
||||
/**
|
||||
* The type of the usage object. Always `tokens` for this variant.
|
||||
*/
|
||||
type: 'tokens';
|
||||
|
||||
/**
|
||||
* Details about the input tokens billed for this request.
|
||||
*/
|
||||
input_token_details?: Tokens.InputTokenDetails;
|
||||
}
|
||||
|
||||
export namespace Tokens {
|
||||
/**
|
||||
* Details about the input tokens billed for this request.
|
||||
*/
|
||||
export interface InputTokenDetails {
|
||||
/**
|
||||
* Number of audio tokens billed for this request.
|
||||
*/
|
||||
audio_tokens?: number;
|
||||
|
||||
/**
|
||||
* Number of text tokens billed for this request.
|
||||
*/
|
||||
text_tokens?: number;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Usage statistics for models billed by audio input duration.
|
||||
*/
|
||||
export interface Duration {
|
||||
/**
|
||||
* Duration of the input audio in seconds.
|
||||
*/
|
||||
seconds: number;
|
||||
|
||||
/**
|
||||
* The type of the usage object. Always `duration` for this variant.
|
||||
*/
|
||||
type: 'duration';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A segment of diarized transcript text with speaker metadata.
|
||||
*/
|
||||
export interface TranscriptionDiarizedSegment {
|
||||
/**
|
||||
* Unique identifier for the segment.
|
||||
*/
|
||||
id: string;
|
||||
|
||||
/**
|
||||
* End timestamp of the segment in seconds.
|
||||
*/
|
||||
end: number;
|
||||
|
||||
/**
|
||||
* Speaker label for this segment. When known speakers are provided, the label
|
||||
* matches `known_speaker_names[]`. Otherwise speakers are labeled sequentially
|
||||
* using capital letters (`A`, `B`, ...).
|
||||
*/
|
||||
speaker: string;
|
||||
|
||||
/**
|
||||
* Start timestamp of the segment in seconds.
|
||||
*/
|
||||
start: number;
|
||||
|
||||
/**
|
||||
* Transcript text for this segment.
|
||||
*/
|
||||
text: string;
|
||||
|
||||
/**
|
||||
* The type of the segment. Always `transcript.text.segment`.
|
||||
*/
|
||||
type: 'transcript.text.segment';
|
||||
}
|
||||
|
||||
export type TranscriptionInclude = 'logprobs';
|
||||
|
||||
export interface TranscriptionSegment {
|
||||
@@ -224,12 +356,15 @@ export interface TranscriptionSegment {
|
||||
}
|
||||
|
||||
/**
|
||||
* Emitted when there is an additional text delta. This is also the first event
|
||||
* emitted when the transcription starts. Only emitted when you
|
||||
* Emitted when a diarized transcription returns a completed segment with speaker
|
||||
* information. Only emitted when you
|
||||
* [create a transcription](https://platform.openai.com/docs/api-reference/audio/create-transcription)
|
||||
* with the `Stream` parameter set to `true`.
|
||||
* with `stream` set to `true` and `response_format` set to `diarized_json`.
|
||||
*/
|
||||
export type TranscriptionStreamEvent = TranscriptionTextDeltaEvent | TranscriptionTextDoneEvent;
|
||||
export type TranscriptionStreamEvent =
|
||||
| TranscriptionTextSegmentEvent
|
||||
| TranscriptionTextDeltaEvent
|
||||
| TranscriptionTextDoneEvent;
|
||||
|
||||
/**
|
||||
* Emitted when there is an additional text delta. This is also the first event
|
||||
@@ -254,6 +389,12 @@ export interface TranscriptionTextDeltaEvent {
|
||||
* with the `include[]` parameter set to `logprobs`.
|
||||
*/
|
||||
logprobs?: Array<TranscriptionTextDeltaEvent.Logprob>;
|
||||
|
||||
/**
|
||||
* Identifier of the diarized segment that this delta belongs to. Only present when
|
||||
* using `gpt-4o-transcribe-diarize`.
|
||||
*/
|
||||
segment_id?: string;
|
||||
}
|
||||
|
||||
export namespace TranscriptionTextDeltaEvent {
|
||||
@@ -372,6 +513,44 @@ export namespace TranscriptionTextDoneEvent {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Emitted when a diarized transcription returns a completed segment with speaker
|
||||
* information. Only emitted when you
|
||||
* [create a transcription](https://platform.openai.com/docs/api-reference/audio/create-transcription)
|
||||
* with `stream` set to `true` and `response_format` set to `diarized_json`.
|
||||
*/
|
||||
export interface TranscriptionTextSegmentEvent {
|
||||
/**
|
||||
* Unique identifier for the segment.
|
||||
*/
|
||||
id: string;
|
||||
|
||||
/**
|
||||
* End timestamp of the segment in seconds.
|
||||
*/
|
||||
end: number;
|
||||
|
||||
/**
|
||||
* Speaker label for this segment.
|
||||
*/
|
||||
speaker: string;
|
||||
|
||||
/**
|
||||
* Start timestamp of the segment in seconds.
|
||||
*/
|
||||
start: number;
|
||||
|
||||
/**
|
||||
* Transcript text for this segment.
|
||||
*/
|
||||
text: string;
|
||||
|
||||
/**
|
||||
* The type of the event. Always `transcript.text.segment`.
|
||||
*/
|
||||
type: 'transcript.text.segment';
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a verbose json transcription response returned by model, based on the
|
||||
* provided input.
|
||||
@@ -446,7 +625,7 @@ export interface TranscriptionWord {
|
||||
* Represents a transcription response returned by model, based on the provided
|
||||
* input.
|
||||
*/
|
||||
export type TranscriptionCreateResponse = Transcription | TranscriptionVerbose;
|
||||
export type TranscriptionCreateResponse = Transcription | TranscriptionDiarized | TranscriptionVerbose;
|
||||
|
||||
export type TranscriptionCreateParams<
|
||||
ResponseFormat extends AudioAPI.AudioResponseFormat | undefined = AudioAPI.AudioResponseFormat | undefined,
|
||||
@@ -463,8 +642,8 @@ export interface TranscriptionCreateParamsBase<
|
||||
|
||||
/**
|
||||
* ID of the model to use. The options are `gpt-4o-transcribe`,
|
||||
* `gpt-4o-mini-transcribe`, and `whisper-1` (which is powered by our open source
|
||||
* Whisper V2 model).
|
||||
* `gpt-4o-mini-transcribe`, `whisper-1` (which is powered by our open source
|
||||
* Whisper V2 model), and `gpt-4o-transcribe-diarize`.
|
||||
*/
|
||||
model: (string & {}) | AudioAPI.AudioModel;
|
||||
|
||||
@@ -473,6 +652,8 @@ export interface TranscriptionCreateParamsBase<
|
||||
* first normalizes loudness and then uses voice activity detection (VAD) to choose
|
||||
* boundaries. `server_vad` object can be provided to tweak VAD detection
|
||||
* parameters manually. If unset, the audio is transcribed as a single block.
|
||||
* Required when using `gpt-4o-transcribe-diarize` for inputs longer than 30
|
||||
* seconds.
|
||||
*/
|
||||
chunking_strategy?: 'auto' | TranscriptionCreateParams.VadConfig | null;
|
||||
|
||||
@@ -481,10 +662,27 @@ export interface TranscriptionCreateParamsBase<
|
||||
* return the log probabilities of the tokens in the response to understand the
|
||||
* model's confidence in the transcription. `logprobs` only works with
|
||||
* response_format set to `json` and only with the models `gpt-4o-transcribe` and
|
||||
* `gpt-4o-mini-transcribe`.
|
||||
* `gpt-4o-mini-transcribe`. This field is not supported when using
|
||||
* `gpt-4o-transcribe-diarize`.
|
||||
*/
|
||||
include?: Array<TranscriptionInclude>;
|
||||
|
||||
/**
|
||||
* Optional list of speaker names that correspond to the audio samples provided in
|
||||
* `known_speaker_references[]`. Each entry should be a short identifier (for
|
||||
* example `customer` or `agent`). Up to 4 speakers are supported.
|
||||
*/
|
||||
known_speaker_names?: Array<string>;
|
||||
|
||||
/**
|
||||
* Optional list of audio samples (as
|
||||
* [data URLs](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URLs))
|
||||
* that contain known speaker references matching `known_speaker_names[]`. Each
|
||||
* sample must be between 2 and 10 seconds, and can use any of the same input audio
|
||||
* formats supported by `file`.
|
||||
*/
|
||||
known_speaker_references?: Array<string>;
|
||||
|
||||
/**
|
||||
* The language of the input audio. Supplying the input language in
|
||||
* [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. `en`)
|
||||
@@ -496,14 +694,17 @@ export interface TranscriptionCreateParamsBase<
|
||||
* An optional text to guide the model's style or continue a previous audio
|
||||
* segment. The
|
||||
* [prompt](https://platform.openai.com/docs/guides/speech-to-text#prompting)
|
||||
* should match the audio language.
|
||||
* should match the audio language. This field is not supported when using
|
||||
* `gpt-4o-transcribe-diarize`.
|
||||
*/
|
||||
prompt?: string;
|
||||
|
||||
/**
|
||||
* The format of the output, in one of these options: `json`, `text`, `srt`,
|
||||
* `verbose_json`, or `vtt`. For `gpt-4o-transcribe` and `gpt-4o-mini-transcribe`,
|
||||
* the only supported format is `json`.
|
||||
* `verbose_json`, `vtt`, or `diarized_json`. For `gpt-4o-transcribe` and
|
||||
* `gpt-4o-mini-transcribe`, the only supported format is `json`. For
|
||||
* `gpt-4o-transcribe-diarize`, the supported formats are `json`, `text`, and
|
||||
* `diarized_json`, with `diarized_json` required to receive speaker annotations.
|
||||
*/
|
||||
response_format?: ResponseFormat;
|
||||
|
||||
@@ -533,7 +734,8 @@ export interface TranscriptionCreateParamsBase<
|
||||
* `response_format` must be set `verbose_json` to use timestamp granularities.
|
||||
* Either or both of these options are supported: `word`, or `segment`. Note: There
|
||||
* is no additional latency for segment timestamps, but generating word timestamps
|
||||
* incurs additional latency.
|
||||
* incurs additional latency. This option is not available for
|
||||
* `gpt-4o-transcribe-diarize`.
|
||||
*/
|
||||
timestamp_granularities?: Array<'word' | 'segment'>;
|
||||
}
|
||||
@@ -602,11 +804,14 @@ export interface TranscriptionCreateParamsStreaming extends TranscriptionCreateP
|
||||
export declare namespace Transcriptions {
|
||||
export {
|
||||
type Transcription as Transcription,
|
||||
type TranscriptionDiarized as TranscriptionDiarized,
|
||||
type TranscriptionDiarizedSegment as TranscriptionDiarizedSegment,
|
||||
type TranscriptionInclude as TranscriptionInclude,
|
||||
type TranscriptionSegment as TranscriptionSegment,
|
||||
type TranscriptionStreamEvent as TranscriptionStreamEvent,
|
||||
type TranscriptionTextDeltaEvent as TranscriptionTextDeltaEvent,
|
||||
type TranscriptionTextDoneEvent as TranscriptionTextDoneEvent,
|
||||
type TranscriptionTextSegmentEvent as TranscriptionTextSegmentEvent,
|
||||
type TranscriptionVerbose as TranscriptionVerbose,
|
||||
type TranscriptionWord as TranscriptionWord,
|
||||
type TranscriptionCreateResponse as TranscriptionCreateResponse,
|
||||
|
||||
86
node_modules/openai/src/resources/batches.ts
generated
vendored
86
node_modules/openai/src/resources/batches.ts
generated
vendored
@@ -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`
|
||||
@@ -216,11 +287,17 @@ export interface BatchCreateParams {
|
||||
|
||||
/**
|
||||
* The endpoint to be used for all requests in the batch. Currently
|
||||
* `/v1/responses`, `/v1/chat/completions`, `/v1/embeddings`, and `/v1/completions`
|
||||
* are supported. Note that `/v1/embeddings` batches are also restricted to a
|
||||
* maximum of 50,000 embedding inputs across all requests in the batch.
|
||||
* `/v1/responses`, `/v1/chat/completions`, `/v1/embeddings`, `/v1/completions`,
|
||||
* and `/v1/moderations` are supported. Note that `/v1/embeddings` batches are also
|
||||
* restricted to a maximum of 50,000 embedding inputs across all requests in the
|
||||
* batch.
|
||||
*/
|
||||
endpoint: '/v1/responses' | '/v1/chat/completions' | '/v1/embeddings' | '/v1/completions';
|
||||
endpoint:
|
||||
| '/v1/responses'
|
||||
| '/v1/chat/completions'
|
||||
| '/v1/embeddings'
|
||||
| '/v1/completions'
|
||||
| '/v1/moderations';
|
||||
|
||||
/**
|
||||
* The ID of an uploaded file that contains requests for the new batch.
|
||||
@@ -280,6 +357,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,
|
||||
|
||||
26
node_modules/openai/src/resources/beta/assistants.ts
generated
vendored
26
node_modules/openai/src/resources/beta/assistants.ts
generated
vendored
@@ -1160,9 +1160,16 @@ export interface AssistantCreateParams {
|
||||
/**
|
||||
* Constrains effort on reasoning for
|
||||
* [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently
|
||||
* supported values are `minimal`, `low`, `medium`, and `high`. Reducing reasoning
|
||||
* effort can result in faster responses and fewer tokens used on reasoning in a
|
||||
* response.
|
||||
* supported values are `none`, `minimal`, `low`, `medium`, and `high`. Reducing
|
||||
* reasoning effort can result in faster responses and fewer tokens used on
|
||||
* reasoning in a response.
|
||||
*
|
||||
* - `gpt-5.1` defaults to `none`, which does not perform reasoning. The supported
|
||||
* reasoning values for `gpt-5.1` are `none`, `low`, `medium`, and `high`. Tool
|
||||
* calls are supported for all reasoning values in gpt-5.1.
|
||||
* - All models before `gpt-5.1` default to `medium` reasoning effort, and do not
|
||||
* support `none`.
|
||||
* - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort.
|
||||
*/
|
||||
reasoning_effort?: Shared.ReasoningEffort | null;
|
||||
|
||||
@@ -1413,9 +1420,16 @@ export interface AssistantUpdateParams {
|
||||
/**
|
||||
* Constrains effort on reasoning for
|
||||
* [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently
|
||||
* supported values are `minimal`, `low`, `medium`, and `high`. Reducing reasoning
|
||||
* effort can result in faster responses and fewer tokens used on reasoning in a
|
||||
* response.
|
||||
* supported values are `none`, `minimal`, `low`, `medium`, and `high`. Reducing
|
||||
* reasoning effort can result in faster responses and fewer tokens used on
|
||||
* reasoning in a response.
|
||||
*
|
||||
* - `gpt-5.1` defaults to `none`, which does not perform reasoning. The supported
|
||||
* reasoning values for `gpt-5.1` are `none`, `low`, `medium`, and `high`. Tool
|
||||
* calls are supported for all reasoning values in gpt-5.1.
|
||||
* - All models before `gpt-5.1` default to `medium` reasoning effort, and do not
|
||||
* support `none`.
|
||||
* - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort.
|
||||
*/
|
||||
reasoning_effort?: Shared.ReasoningEffort | null;
|
||||
|
||||
|
||||
6
node_modules/openai/src/resources/beta/beta.ts
generated
vendored
6
node_modules/openai/src/resources/beta/beta.ts
generated
vendored
@@ -73,6 +73,8 @@ import {
|
||||
TranscriptionSessionUpdate,
|
||||
TranscriptionSessionUpdatedEvent,
|
||||
} from './realtime/realtime';
|
||||
import * as ChatKitAPI from './chatkit/chatkit';
|
||||
import { ChatKit, ChatKitWorkflow } from './chatkit/chatkit';
|
||||
import * as ThreadsAPI from './threads/threads';
|
||||
import {
|
||||
AssistantResponseFormatOption,
|
||||
@@ -93,11 +95,13 @@ import {
|
||||
|
||||
export class Beta extends APIResource {
|
||||
realtime: RealtimeAPI.Realtime = new RealtimeAPI.Realtime(this._client);
|
||||
chatkit: ChatKitAPI.ChatKit = new ChatKitAPI.ChatKit(this._client);
|
||||
assistants: AssistantsAPI.Assistants = new AssistantsAPI.Assistants(this._client);
|
||||
threads: ThreadsAPI.Threads = new ThreadsAPI.Threads(this._client);
|
||||
}
|
||||
|
||||
Beta.Realtime = Realtime;
|
||||
Beta.ChatKit = ChatKit;
|
||||
Beta.Assistants = Assistants;
|
||||
Beta.Threads = Threads;
|
||||
|
||||
@@ -153,6 +157,8 @@ export declare namespace Beta {
|
||||
type SessionUpdatedEvent as SessionUpdatedEvent,
|
||||
type TranscriptionSessionUpdate as TranscriptionSessionUpdate,
|
||||
type TranscriptionSessionUpdatedEvent as TranscriptionSessionUpdatedEvent,
|
||||
ChatKit as ChatKit,
|
||||
type ChatKitWorkflow as ChatKitWorkflow,
|
||||
};
|
||||
|
||||
export {
|
||||
|
||||
3
node_modules/openai/src/resources/beta/chatkit.ts
generated
vendored
Normal file
3
node_modules/openai/src/resources/beta/chatkit.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
export * from './chatkit/index';
|
||||
112
node_modules/openai/src/resources/beta/chatkit/chatkit.ts
generated
vendored
Normal file
112
node_modules/openai/src/resources/beta/chatkit/chatkit.ts
generated
vendored
Normal file
@@ -0,0 +1,112 @@
|
||||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
import { APIResource } from '../../../core/resource';
|
||||
import * as SessionsAPI from './sessions';
|
||||
import { SessionCreateParams, Sessions } from './sessions';
|
||||
import * as ThreadsAPI from './threads';
|
||||
import {
|
||||
ChatKitAttachment,
|
||||
ChatKitResponseOutputText,
|
||||
ChatKitThread,
|
||||
ChatKitThreadAssistantMessageItem,
|
||||
ChatKitThreadItemList,
|
||||
ChatKitThreadItemListDataPage,
|
||||
ChatKitThreadUserMessageItem,
|
||||
ChatKitThreadsPage,
|
||||
ChatKitWidgetItem,
|
||||
ChatSession,
|
||||
ChatSessionAutomaticThreadTitling,
|
||||
ChatSessionChatKitConfiguration,
|
||||
ChatSessionChatKitConfigurationParam,
|
||||
ChatSessionExpiresAfterParam,
|
||||
ChatSessionFileUpload,
|
||||
ChatSessionHistory,
|
||||
ChatSessionRateLimits,
|
||||
ChatSessionRateLimitsParam,
|
||||
ChatSessionStatus,
|
||||
ChatSessionWorkflowParam,
|
||||
ThreadDeleteResponse,
|
||||
ThreadListItemsParams,
|
||||
ThreadListParams,
|
||||
Threads,
|
||||
} from './threads';
|
||||
|
||||
export class ChatKit extends APIResource {
|
||||
sessions: SessionsAPI.Sessions = new SessionsAPI.Sessions(this._client);
|
||||
threads: ThreadsAPI.Threads = new ThreadsAPI.Threads(this._client);
|
||||
}
|
||||
|
||||
/**
|
||||
* Workflow metadata and state returned for the session.
|
||||
*/
|
||||
export interface ChatKitWorkflow {
|
||||
/**
|
||||
* Identifier of the workflow backing the session.
|
||||
*/
|
||||
id: string;
|
||||
|
||||
/**
|
||||
* State variable key-value pairs applied when invoking the workflow. Defaults to
|
||||
* null when no overrides were provided.
|
||||
*/
|
||||
state_variables: { [key: string]: string | boolean | number } | null;
|
||||
|
||||
/**
|
||||
* Tracing settings applied to the workflow.
|
||||
*/
|
||||
tracing: ChatKitWorkflow.Tracing;
|
||||
|
||||
/**
|
||||
* Specific workflow version used for the session. Defaults to null when using the
|
||||
* latest deployment.
|
||||
*/
|
||||
version: string | null;
|
||||
}
|
||||
|
||||
export namespace ChatKitWorkflow {
|
||||
/**
|
||||
* Tracing settings applied to the workflow.
|
||||
*/
|
||||
export interface Tracing {
|
||||
/**
|
||||
* Indicates whether tracing is enabled.
|
||||
*/
|
||||
enabled: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
ChatKit.Sessions = Sessions;
|
||||
ChatKit.Threads = Threads;
|
||||
|
||||
export declare namespace ChatKit {
|
||||
export { type ChatKitWorkflow as ChatKitWorkflow };
|
||||
|
||||
export { Sessions as Sessions, type SessionCreateParams as SessionCreateParams };
|
||||
|
||||
export {
|
||||
Threads as Threads,
|
||||
type ChatSession as ChatSession,
|
||||
type ChatSessionAutomaticThreadTitling as ChatSessionAutomaticThreadTitling,
|
||||
type ChatSessionChatKitConfiguration as ChatSessionChatKitConfiguration,
|
||||
type ChatSessionChatKitConfigurationParam as ChatSessionChatKitConfigurationParam,
|
||||
type ChatSessionExpiresAfterParam as ChatSessionExpiresAfterParam,
|
||||
type ChatSessionFileUpload as ChatSessionFileUpload,
|
||||
type ChatSessionHistory as ChatSessionHistory,
|
||||
type ChatSessionRateLimits as ChatSessionRateLimits,
|
||||
type ChatSessionRateLimitsParam as ChatSessionRateLimitsParam,
|
||||
type ChatSessionStatus as ChatSessionStatus,
|
||||
type ChatSessionWorkflowParam as ChatSessionWorkflowParam,
|
||||
type ChatKitAttachment as ChatKitAttachment,
|
||||
type ChatKitResponseOutputText as ChatKitResponseOutputText,
|
||||
type ChatKitThread as ChatKitThread,
|
||||
type ChatKitThreadAssistantMessageItem as ChatKitThreadAssistantMessageItem,
|
||||
type ChatKitThreadItemList as ChatKitThreadItemList,
|
||||
type ChatKitThreadUserMessageItem as ChatKitThreadUserMessageItem,
|
||||
type ChatKitWidgetItem as ChatKitWidgetItem,
|
||||
type ThreadDeleteResponse as ThreadDeleteResponse,
|
||||
type ChatKitThreadsPage as ChatKitThreadsPage,
|
||||
type ChatKitThreadItemListDataPage as ChatKitThreadItemListDataPage,
|
||||
type ThreadListParams as ThreadListParams,
|
||||
type ThreadListItemsParams as ThreadListItemsParams,
|
||||
};
|
||||
}
|
||||
30
node_modules/openai/src/resources/beta/chatkit/index.ts
generated
vendored
Normal file
30
node_modules/openai/src/resources/beta/chatkit/index.ts
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
export { ChatKit, type ChatKitWorkflow } from './chatkit';
|
||||
export { Sessions, type SessionCreateParams } from './sessions';
|
||||
export {
|
||||
Threads,
|
||||
type ChatSession,
|
||||
type ChatSessionAutomaticThreadTitling,
|
||||
type ChatSessionChatKitConfiguration,
|
||||
type ChatSessionChatKitConfigurationParam,
|
||||
type ChatSessionExpiresAfterParam,
|
||||
type ChatSessionFileUpload,
|
||||
type ChatSessionHistory,
|
||||
type ChatSessionRateLimits,
|
||||
type ChatSessionRateLimitsParam,
|
||||
type ChatSessionStatus,
|
||||
type ChatSessionWorkflowParam,
|
||||
type ChatKitAttachment,
|
||||
type ChatKitResponseOutputText,
|
||||
type ChatKitThread,
|
||||
type ChatKitThreadAssistantMessageItem,
|
||||
type ChatKitThreadItemList,
|
||||
type ChatKitThreadUserMessageItem,
|
||||
type ChatKitWidgetItem,
|
||||
type ThreadDeleteResponse,
|
||||
type ThreadListParams,
|
||||
type ThreadListItemsParams,
|
||||
type ChatKitThreadsPage,
|
||||
type ChatKitThreadItemListDataPage,
|
||||
} from './threads';
|
||||
79
node_modules/openai/src/resources/beta/chatkit/sessions.ts
generated
vendored
Normal file
79
node_modules/openai/src/resources/beta/chatkit/sessions.ts
generated
vendored
Normal file
@@ -0,0 +1,79 @@
|
||||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
import { APIResource } from '../../../core/resource';
|
||||
import * as ThreadsAPI from './threads';
|
||||
import { APIPromise } from '../../../core/api-promise';
|
||||
import { buildHeaders } from '../../../internal/headers';
|
||||
import { RequestOptions } from '../../../internal/request-options';
|
||||
import { path } from '../../../internal/utils/path';
|
||||
|
||||
export class Sessions extends APIResource {
|
||||
/**
|
||||
* Create a ChatKit session
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* const chatSession =
|
||||
* await client.beta.chatkit.sessions.create({
|
||||
* user: 'x',
|
||||
* workflow: { id: 'id' },
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
create(body: SessionCreateParams, options?: RequestOptions): APIPromise<ThreadsAPI.ChatSession> {
|
||||
return this._client.post('/chatkit/sessions', {
|
||||
body,
|
||||
...options,
|
||||
headers: buildHeaders([{ 'OpenAI-Beta': 'chatkit_beta=v1' }, options?.headers]),
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancel a ChatKit session
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* const chatSession =
|
||||
* await client.beta.chatkit.sessions.cancel('cksess_123');
|
||||
* ```
|
||||
*/
|
||||
cancel(sessionID: string, options?: RequestOptions): APIPromise<ThreadsAPI.ChatSession> {
|
||||
return this._client.post(path`/chatkit/sessions/${sessionID}/cancel`, {
|
||||
...options,
|
||||
headers: buildHeaders([{ 'OpenAI-Beta': 'chatkit_beta=v1' }, options?.headers]),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export interface SessionCreateParams {
|
||||
/**
|
||||
* A free-form string that identifies your end user; ensures this Session can
|
||||
* access other objects that have the same `user` scope.
|
||||
*/
|
||||
user: string;
|
||||
|
||||
/**
|
||||
* Workflow that powers the session.
|
||||
*/
|
||||
workflow: ThreadsAPI.ChatSessionWorkflowParam;
|
||||
|
||||
/**
|
||||
* Optional overrides for ChatKit runtime configuration features
|
||||
*/
|
||||
chatkit_configuration?: ThreadsAPI.ChatSessionChatKitConfigurationParam;
|
||||
|
||||
/**
|
||||
* Optional override for session expiration timing in seconds from creation.
|
||||
* Defaults to 10 minutes.
|
||||
*/
|
||||
expires_after?: ThreadsAPI.ChatSessionExpiresAfterParam;
|
||||
|
||||
/**
|
||||
* Optional override for per-minute request limits. When omitted, defaults to 10.
|
||||
*/
|
||||
rate_limits?: ThreadsAPI.ChatSessionRateLimitsParam;
|
||||
}
|
||||
|
||||
export declare namespace Sessions {
|
||||
export { type SessionCreateParams as SessionCreateParams };
|
||||
}
|
||||
1037
node_modules/openai/src/resources/beta/chatkit/threads.ts
generated
vendored
Normal file
1037
node_modules/openai/src/resources/beta/chatkit/threads.ts
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
node_modules/openai/src/resources/beta/index.ts
generated
vendored
1
node_modules/openai/src/resources/beta/index.ts
generated
vendored
@@ -20,6 +20,7 @@ export {
|
||||
} from './assistants';
|
||||
export { Beta } from './beta';
|
||||
export { Realtime } from './realtime/index';
|
||||
export { ChatKit, type ChatKitWorkflow } from './chatkit/index';
|
||||
export {
|
||||
Threads,
|
||||
type AssistantResponseFormatOption,
|
||||
|
||||
3
node_modules/openai/src/resources/beta/realtime/realtime.ts
generated
vendored
3
node_modules/openai/src/resources/beta/realtime/realtime.ts
generated
vendored
@@ -17,6 +17,9 @@ import {
|
||||
TranscriptionSessions,
|
||||
} from './transcription-sessions';
|
||||
|
||||
/**
|
||||
* @deprecated Realtime has now launched and is generally available. The old beta API is now deprecated.
|
||||
*/
|
||||
export class Realtime extends APIResource {
|
||||
sessions: SessionsAPI.Sessions = new SessionsAPI.Sessions(this._client);
|
||||
transcriptionSessions: TranscriptionSessionsAPI.TranscriptionSessions =
|
||||
|
||||
13
node_modules/openai/src/resources/beta/threads/runs/runs.ts
generated
vendored
13
node_modules/openai/src/resources/beta/threads/runs/runs.ts
generated
vendored
@@ -725,9 +725,16 @@ export interface RunCreateParamsBase {
|
||||
/**
|
||||
* Body param: Constrains effort on reasoning for
|
||||
* [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently
|
||||
* supported values are `minimal`, `low`, `medium`, and `high`. Reducing reasoning
|
||||
* effort can result in faster responses and fewer tokens used on reasoning in a
|
||||
* response.
|
||||
* supported values are `none`, `minimal`, `low`, `medium`, and `high`. Reducing
|
||||
* reasoning effort can result in faster responses and fewer tokens used on
|
||||
* reasoning in a response.
|
||||
*
|
||||
* - `gpt-5.1` defaults to `none`, which does not perform reasoning. The supported
|
||||
* reasoning values for `gpt-5.1` are `none`, `low`, `medium`, and `high`. Tool
|
||||
* calls are supported for all reasoning values in gpt-5.1.
|
||||
* - All models before `gpt-5.1` default to `medium` reasoning effort, and do not
|
||||
* support `none`.
|
||||
* - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort.
|
||||
*/
|
||||
reasoning_effort?: Shared.ReasoningEffort | null;
|
||||
|
||||
|
||||
41
node_modules/openai/src/resources/chat/completions/completions.ts
generated
vendored
41
node_modules/openai/src/resources/chat/completions/completions.ts
generated
vendored
@@ -489,7 +489,18 @@ export interface ChatCompletionAudioParam {
|
||||
* The voice the model uses to respond. Supported voices are `alloy`, `ash`,
|
||||
* `ballad`, `coral`, `echo`, `fable`, `nova`, `onyx`, `sage`, and `shimmer`.
|
||||
*/
|
||||
voice: (string & {}) | 'alloy' | 'ash' | 'ballad' | 'coral' | 'echo' | 'sage' | 'shimmer' | 'verse';
|
||||
voice:
|
||||
| (string & {})
|
||||
| 'alloy'
|
||||
| 'ash'
|
||||
| 'ballad'
|
||||
| 'coral'
|
||||
| 'echo'
|
||||
| 'sage'
|
||||
| 'shimmer'
|
||||
| 'verse'
|
||||
| 'marin'
|
||||
| 'cedar';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1627,12 +1638,27 @@ export interface ChatCompletionCreateParamsBase {
|
||||
*/
|
||||
prompt_cache_key?: string;
|
||||
|
||||
/**
|
||||
* The retention policy for the prompt cache. Set to `24h` to enable extended
|
||||
* prompt caching, which keeps cached prefixes active for longer, up to a maximum
|
||||
* of 24 hours.
|
||||
* [Learn more](https://platform.openai.com/docs/guides/prompt-caching#prompt-cache-retention).
|
||||
*/
|
||||
prompt_cache_retention?: 'in-memory' | '24h' | null;
|
||||
|
||||
/**
|
||||
* Constrains effort on reasoning for
|
||||
* [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently
|
||||
* supported values are `minimal`, `low`, `medium`, and `high`. Reducing reasoning
|
||||
* effort can result in faster responses and fewer tokens used on reasoning in a
|
||||
* response.
|
||||
* supported values are `none`, `minimal`, `low`, `medium`, and `high`. Reducing
|
||||
* reasoning effort can result in faster responses and fewer tokens used on
|
||||
* reasoning in a response.
|
||||
*
|
||||
* - `gpt-5.1` defaults to `none`, which does not perform reasoning. The supported
|
||||
* reasoning values for `gpt-5.1` are `none`, `low`, `medium`, and `high`. Tool
|
||||
* calls are supported for all reasoning values in gpt-5.1.
|
||||
* - All models before `gpt-5.1` default to `medium` reasoning effort, and do not
|
||||
* support `none`.
|
||||
* - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort.
|
||||
*/
|
||||
reasoning_effort?: Shared.ReasoningEffort | null;
|
||||
|
||||
@@ -1935,9 +1961,12 @@ export interface ChatCompletionUpdateParams {
|
||||
|
||||
export interface ChatCompletionListParams extends CursorPageParams {
|
||||
/**
|
||||
* A list of metadata keys to filter the Chat Completions by. Example:
|
||||
* Set of 16 key-value pairs that can be attached to an object. This can be useful
|
||||
* for storing additional information about the object in a structured format, and
|
||||
* querying for objects via API or the dashboard.
|
||||
*
|
||||
* `metadata[key1]=value1&metadata[key2]=value2`
|
||||
* Keys are strings with a maximum length of 64 characters. Values are strings with
|
||||
* a maximum length of 512 characters.
|
||||
*/
|
||||
metadata?: Shared.Metadata | null;
|
||||
|
||||
|
||||
267
node_modules/openai/src/resources/conversations/conversations.ts
generated
vendored
267
node_modules/openai/src/resources/conversations/conversations.ts
generated
vendored
@@ -24,19 +24,22 @@ export class Conversations extends APIResource {
|
||||
/**
|
||||
* Create a conversation.
|
||||
*/
|
||||
create(body: ConversationCreateParams, options?: RequestOptions): APIPromise<Conversation> {
|
||||
create(
|
||||
body: ConversationCreateParams | null | undefined = {},
|
||||
options?: RequestOptions,
|
||||
): APIPromise<Conversation> {
|
||||
return this._client.post('/conversations', { body, ...options });
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a conversation with the given ID.
|
||||
* Get a conversation
|
||||
*/
|
||||
retrieve(conversationID: string, options?: RequestOptions): APIPromise<Conversation> {
|
||||
return this._client.get(path`/conversations/${conversationID}`, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a conversation's metadata with the given ID.
|
||||
* Update a conversation
|
||||
*/
|
||||
update(
|
||||
conversationID: string,
|
||||
@@ -47,13 +50,16 @@ export class Conversations extends APIResource {
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a conversation with the given ID.
|
||||
* Delete a conversation. Items in the conversation will not be deleted.
|
||||
*/
|
||||
delete(conversationID: string, options?: RequestOptions): APIPromise<ConversationDeletedResource> {
|
||||
return this._client.delete(path`/conversations/${conversationID}`, options);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A screenshot of a computer.
|
||||
*/
|
||||
export interface ComputerScreenshotContent {
|
||||
/**
|
||||
* The identifier of an uploaded file that contains the screenshot.
|
||||
@@ -72,38 +78,6 @@ export interface ComputerScreenshotContent {
|
||||
type: 'computer_screenshot';
|
||||
}
|
||||
|
||||
export interface ContainerFileCitationBody {
|
||||
/**
|
||||
* The ID of the container file.
|
||||
*/
|
||||
container_id: string;
|
||||
|
||||
/**
|
||||
* The index of the last character of the container file citation in the message.
|
||||
*/
|
||||
end_index: number;
|
||||
|
||||
/**
|
||||
* The ID of the file.
|
||||
*/
|
||||
file_id: string;
|
||||
|
||||
/**
|
||||
* The filename of the container file cited.
|
||||
*/
|
||||
filename: string;
|
||||
|
||||
/**
|
||||
* The index of the first character of the container file citation in the message.
|
||||
*/
|
||||
start_index: number;
|
||||
|
||||
/**
|
||||
* The type of the container file citation. Always `container_file_citation`.
|
||||
*/
|
||||
type: 'container_file_citation';
|
||||
}
|
||||
|
||||
export interface Conversation {
|
||||
/**
|
||||
* The unique ID of the conversation.
|
||||
@@ -147,96 +121,9 @@ export interface ConversationDeletedResource {
|
||||
object: 'conversation.deleted';
|
||||
}
|
||||
|
||||
export interface FileCitationBody {
|
||||
/**
|
||||
* The ID of the file.
|
||||
*/
|
||||
file_id: string;
|
||||
|
||||
/**
|
||||
* The filename of the file cited.
|
||||
*/
|
||||
filename: string;
|
||||
|
||||
/**
|
||||
* The index of the file in the list of files.
|
||||
*/
|
||||
index: number;
|
||||
|
||||
/**
|
||||
* The type of the file citation. Always `file_citation`.
|
||||
*/
|
||||
type: 'file_citation';
|
||||
}
|
||||
|
||||
export interface InputFileContent {
|
||||
/**
|
||||
* The ID of the file to be sent to the model.
|
||||
*/
|
||||
file_id: string | null;
|
||||
|
||||
/**
|
||||
* The type of the input item. Always `input_file`.
|
||||
*/
|
||||
type: 'input_file';
|
||||
|
||||
/**
|
||||
* The URL of the file to be sent to the model.
|
||||
*/
|
||||
file_url?: string;
|
||||
|
||||
/**
|
||||
* The name of the file to be sent to the model.
|
||||
*/
|
||||
filename?: string;
|
||||
}
|
||||
|
||||
export interface InputImageContent {
|
||||
/**
|
||||
* 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';
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* The type of the input item. Always `input_image`.
|
||||
*/
|
||||
type: 'input_image';
|
||||
}
|
||||
|
||||
export interface InputTextContent {
|
||||
/**
|
||||
* The text input to the model.
|
||||
*/
|
||||
text: string;
|
||||
|
||||
/**
|
||||
* The type of the input item. Always `input_text`.
|
||||
*/
|
||||
type: 'input_text';
|
||||
}
|
||||
|
||||
export interface LobProb {
|
||||
token: string;
|
||||
|
||||
bytes: Array<number>;
|
||||
|
||||
logprob: number;
|
||||
|
||||
top_logprobs: Array<TopLogProb>;
|
||||
}
|
||||
|
||||
/**
|
||||
* A message to or from the model.
|
||||
*/
|
||||
export interface Message {
|
||||
/**
|
||||
* The unique ID of the message.
|
||||
@@ -247,14 +134,15 @@ export interface Message {
|
||||
* The content of the message
|
||||
*/
|
||||
content: Array<
|
||||
| InputTextContent
|
||||
| OutputTextContent
|
||||
| ResponsesAPI.ResponseInputText
|
||||
| ResponsesAPI.ResponseOutputText
|
||||
| TextContent
|
||||
| SummaryTextContent
|
||||
| RefusalContent
|
||||
| InputImageContent
|
||||
| Message.ReasoningText
|
||||
| ResponsesAPI.ResponseOutputRefusal
|
||||
| ResponsesAPI.ResponseInputImage
|
||||
| ComputerScreenshotContent
|
||||
| InputFileContent
|
||||
| ResponsesAPI.ResponseInputFile
|
||||
>;
|
||||
|
||||
/**
|
||||
@@ -275,83 +163,56 @@ export interface Message {
|
||||
type: 'message';
|
||||
}
|
||||
|
||||
export interface OutputTextContent {
|
||||
export namespace Message {
|
||||
/**
|
||||
* The annotations of the text output.
|
||||
* Reasoning text from the model.
|
||||
*/
|
||||
annotations: Array<FileCitationBody | URLCitationBody | ContainerFileCitationBody>;
|
||||
export interface ReasoningText {
|
||||
/**
|
||||
* The reasoning text from the model.
|
||||
*/
|
||||
text: string;
|
||||
|
||||
/**
|
||||
* The text output from the model.
|
||||
*/
|
||||
text: string;
|
||||
|
||||
/**
|
||||
* The type of the output text. Always `output_text`.
|
||||
*/
|
||||
type: 'output_text';
|
||||
|
||||
logprobs?: Array<LobProb>;
|
||||
}
|
||||
|
||||
export interface RefusalContent {
|
||||
/**
|
||||
* The refusal explanation from the model.
|
||||
*/
|
||||
refusal: string;
|
||||
|
||||
/**
|
||||
* The type of the refusal. Always `refusal`.
|
||||
*/
|
||||
type: 'refusal';
|
||||
/**
|
||||
* The type of the reasoning text. Always `reasoning_text`.
|
||||
*/
|
||||
type: 'reasoning_text';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A summary text from the model.
|
||||
*/
|
||||
export interface SummaryTextContent {
|
||||
/**
|
||||
* A summary of the reasoning output from the model so far.
|
||||
*/
|
||||
text: string;
|
||||
|
||||
/**
|
||||
* The type of the object. Always `summary_text`.
|
||||
*/
|
||||
type: 'summary_text';
|
||||
}
|
||||
|
||||
/**
|
||||
* A text content.
|
||||
*/
|
||||
export interface TextContent {
|
||||
text: string;
|
||||
|
||||
type: 'text';
|
||||
}
|
||||
|
||||
export interface TopLogProb {
|
||||
token: string;
|
||||
export type InputTextContent = ResponsesAPI.ResponseInputText;
|
||||
|
||||
bytes: Array<number>;
|
||||
export type OutputTextContent = ResponsesAPI.ResponseOutputText;
|
||||
|
||||
logprob: number;
|
||||
}
|
||||
export type RefusalContent = ResponsesAPI.ResponseOutputRefusal;
|
||||
|
||||
export interface URLCitationBody {
|
||||
/**
|
||||
* The index of the last character of the URL citation in the message.
|
||||
*/
|
||||
end_index: number;
|
||||
export type InputImageContent = ResponsesAPI.ResponseInputImage;
|
||||
|
||||
/**
|
||||
* The index of the first character of the URL citation in the message.
|
||||
*/
|
||||
start_index: number;
|
||||
|
||||
/**
|
||||
* The title of the web resource.
|
||||
*/
|
||||
title: string;
|
||||
|
||||
/**
|
||||
* The type of the URL citation. Always `url_citation`.
|
||||
*/
|
||||
type: 'url_citation';
|
||||
|
||||
/**
|
||||
* The URL of the web resource.
|
||||
*/
|
||||
url: string;
|
||||
}
|
||||
export type InputFileContent = ResponsesAPI.ResponseInputFile;
|
||||
|
||||
export interface ConversationCreateParams {
|
||||
/**
|
||||
@@ -361,8 +222,12 @@ export interface ConversationCreateParams {
|
||||
items?: Array<ResponsesAPI.ResponseInputItem> | null;
|
||||
|
||||
/**
|
||||
* Set of 16 key-value pairs that can be attached to an object. Useful for storing
|
||||
* additional information about the object in a structured format.
|
||||
* Set of 16 key-value pairs that can be attached to an object. This can be useful
|
||||
* for storing additional information about the object in a structured format, and
|
||||
* querying for objects via API or the dashboard.
|
||||
*
|
||||
* Keys are strings with a maximum length of 64 characters. Values are strings with
|
||||
* a maximum length of 512 characters.
|
||||
*/
|
||||
metadata?: Shared.Metadata | null;
|
||||
}
|
||||
@@ -371,11 +236,12 @@ export interface ConversationUpdateParams {
|
||||
/**
|
||||
* Set of 16 key-value pairs that can be attached to an object. This can be useful
|
||||
* for storing additional information about the object in a structured format, and
|
||||
* querying for objects via API or the dashboard. Keys are strings with a maximum
|
||||
* length of 64 characters. Values are strings with a maximum length of 512
|
||||
* characters.
|
||||
* querying for objects via API or the dashboard.
|
||||
*
|
||||
* Keys are strings with a maximum length of 64 characters. Values are strings with
|
||||
* a maximum length of 512 characters.
|
||||
*/
|
||||
metadata: { [key: string]: string };
|
||||
metadata: Shared.Metadata | null;
|
||||
}
|
||||
|
||||
Conversations.Items = Items;
|
||||
@@ -383,22 +249,17 @@ Conversations.Items = Items;
|
||||
export declare namespace Conversations {
|
||||
export {
|
||||
type ComputerScreenshotContent as ComputerScreenshotContent,
|
||||
type ContainerFileCitationBody as ContainerFileCitationBody,
|
||||
type Conversation as Conversation,
|
||||
type ConversationDeleted as ConversationDeleted,
|
||||
type ConversationDeletedResource as ConversationDeletedResource,
|
||||
type FileCitationBody as FileCitationBody,
|
||||
type InputFileContent as InputFileContent,
|
||||
type InputImageContent as InputImageContent,
|
||||
type InputTextContent as InputTextContent,
|
||||
type LobProb as LobProb,
|
||||
type Message as Message,
|
||||
type OutputTextContent as OutputTextContent,
|
||||
type RefusalContent as RefusalContent,
|
||||
type SummaryTextContent as SummaryTextContent,
|
||||
type TextContent as TextContent,
|
||||
type TopLogProb as TopLogProb,
|
||||
type URLCitationBody as URLCitationBody,
|
||||
type InputTextContent as InputTextContent,
|
||||
type OutputTextContent as OutputTextContent,
|
||||
type RefusalContent as RefusalContent,
|
||||
type InputImageContent as InputImageContent,
|
||||
type InputFileContent as InputFileContent,
|
||||
type ConversationCreateParams as ConversationCreateParams,
|
||||
type ConversationUpdateParams as ConversationUpdateParams,
|
||||
};
|
||||
|
||||
17
node_modules/openai/src/resources/conversations/items.ts
generated
vendored
17
node_modules/openai/src/resources/conversations/items.ts
generated
vendored
@@ -89,6 +89,10 @@ export type ConversationItem =
|
||||
| ResponsesAPI.ResponseCodeInterpreterToolCall
|
||||
| ConversationItem.LocalShellCall
|
||||
| ConversationItem.LocalShellCallOutput
|
||||
| ResponsesAPI.ResponseFunctionShellToolCall
|
||||
| ResponsesAPI.ResponseFunctionShellToolCallOutput
|
||||
| ResponsesAPI.ResponseApplyPatchToolCall
|
||||
| ResponsesAPI.ResponseApplyPatchToolCallOutput
|
||||
| ConversationItem.McpListTools
|
||||
| ConversationItem.McpApprovalRequest
|
||||
| ConversationItem.McpApprovalResponse
|
||||
@@ -360,6 +364,13 @@ export namespace ConversationItem {
|
||||
*/
|
||||
type: 'mcp_call';
|
||||
|
||||
/**
|
||||
* Unique identifier for the MCP tool call approval request. Include this value in
|
||||
* a subsequent `mcp_approval_response` input to approve or reject the
|
||||
* corresponding tool call.
|
||||
*/
|
||||
approval_request_id?: string | null;
|
||||
|
||||
/**
|
||||
* The error from the tool call, if any.
|
||||
*/
|
||||
@@ -369,6 +380,12 @@ export namespace ConversationItem {
|
||||
* The output from the tool call.
|
||||
*/
|
||||
output?: string | null;
|
||||
|
||||
/**
|
||||
* The status of the tool call. One of `in_progress`, `completed`, `incomplete`,
|
||||
* `calling`, or `failed`.
|
||||
*/
|
||||
status?: 'in_progress' | 'completed' | 'incomplete' | 'calling' | 'failed';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
1
node_modules/openai/src/resources/evals/evals.ts
generated
vendored
1
node_modules/openai/src/resources/evals/evals.ts
generated
vendored
@@ -776,6 +776,7 @@ export namespace EvalCreateParams {
|
||||
| ResponsesAPI.ResponseInputText
|
||||
| EvalItem.OutputText
|
||||
| EvalItem.InputImage
|
||||
| ResponsesAPI.ResponseInputAudio
|
||||
| Array<unknown>;
|
||||
|
||||
/**
|
||||
|
||||
72
node_modules/openai/src/resources/evals/runs/output-items.ts
generated
vendored
72
node_modules/openai/src/resources/evals/runs/output-items.ts
generated
vendored
@@ -74,9 +74,9 @@ export interface OutputItemRetrieveResponse {
|
||||
object: 'eval.run.output_item';
|
||||
|
||||
/**
|
||||
* A list of results from the evaluation run.
|
||||
* A list of grader results for this output item.
|
||||
*/
|
||||
results: Array<{ [key: string]: unknown }>;
|
||||
results: Array<OutputItemRetrieveResponse.Result>;
|
||||
|
||||
/**
|
||||
* The identifier of the evaluation run associated with this output item.
|
||||
@@ -95,6 +95,38 @@ export interface OutputItemRetrieveResponse {
|
||||
}
|
||||
|
||||
export namespace OutputItemRetrieveResponse {
|
||||
/**
|
||||
* A single grader result for an evaluation run output item.
|
||||
*/
|
||||
export interface Result {
|
||||
/**
|
||||
* The name of the grader.
|
||||
*/
|
||||
name: string;
|
||||
|
||||
/**
|
||||
* Whether the grader considered the output a pass.
|
||||
*/
|
||||
passed: boolean;
|
||||
|
||||
/**
|
||||
* The numeric score produced by the grader.
|
||||
*/
|
||||
score: number;
|
||||
|
||||
/**
|
||||
* Optional sample or intermediate data produced by the grader.
|
||||
*/
|
||||
sample?: { [key: string]: unknown } | null;
|
||||
|
||||
/**
|
||||
* The grader type (for example, "string-check-grader").
|
||||
*/
|
||||
type?: string;
|
||||
|
||||
[k: string]: unknown;
|
||||
}
|
||||
|
||||
/**
|
||||
* A sample containing the input and output of the evaluation run.
|
||||
*/
|
||||
@@ -240,9 +272,9 @@ export interface OutputItemListResponse {
|
||||
object: 'eval.run.output_item';
|
||||
|
||||
/**
|
||||
* A list of results from the evaluation run.
|
||||
* A list of grader results for this output item.
|
||||
*/
|
||||
results: Array<{ [key: string]: unknown }>;
|
||||
results: Array<OutputItemListResponse.Result>;
|
||||
|
||||
/**
|
||||
* The identifier of the evaluation run associated with this output item.
|
||||
@@ -261,6 +293,38 @@ export interface OutputItemListResponse {
|
||||
}
|
||||
|
||||
export namespace OutputItemListResponse {
|
||||
/**
|
||||
* A single grader result for an evaluation run output item.
|
||||
*/
|
||||
export interface Result {
|
||||
/**
|
||||
* The name of the grader.
|
||||
*/
|
||||
name: string;
|
||||
|
||||
/**
|
||||
* Whether the grader considered the output a pass.
|
||||
*/
|
||||
passed: boolean;
|
||||
|
||||
/**
|
||||
* The numeric score produced by the grader.
|
||||
*/
|
||||
score: number;
|
||||
|
||||
/**
|
||||
* Optional sample or intermediate data produced by the grader.
|
||||
*/
|
||||
sample?: { [key: string]: unknown } | null;
|
||||
|
||||
/**
|
||||
* The grader type (for example, "string-check-grader").
|
||||
*/
|
||||
type?: string;
|
||||
|
||||
[k: string]: unknown;
|
||||
}
|
||||
|
||||
/**
|
||||
* A sample containing the input and output of the evaluation run.
|
||||
*/
|
||||
|
||||
172
node_modules/openai/src/resources/evals/runs/runs.ts
generated
vendored
172
node_modules/openai/src/resources/evals/runs/runs.ts
generated
vendored
@@ -213,6 +213,7 @@ export namespace CreateEvalCompletionsRunDataSource {
|
||||
| ResponsesAPI.ResponseInputText
|
||||
| EvalItem.OutputText
|
||||
| EvalItem.InputImage
|
||||
| ResponsesAPI.ResponseInputAudio
|
||||
| Array<unknown>;
|
||||
|
||||
/**
|
||||
@@ -284,6 +285,22 @@ export namespace CreateEvalCompletionsRunDataSource {
|
||||
*/
|
||||
max_completion_tokens?: number;
|
||||
|
||||
/**
|
||||
* Constrains effort on reasoning for
|
||||
* [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently
|
||||
* supported values are `none`, `minimal`, `low`, `medium`, and `high`. Reducing
|
||||
* reasoning effort can result in faster responses and fewer tokens used on
|
||||
* reasoning in a response.
|
||||
*
|
||||
* - `gpt-5.1` defaults to `none`, which does not perform reasoning. The supported
|
||||
* reasoning values for `gpt-5.1` are `none`, `low`, `medium`, and `high`. Tool
|
||||
* calls are supported for all reasoning values in gpt-5.1.
|
||||
* - All models before `gpt-5.1` default to `medium` reasoning effort, and do not
|
||||
* support `none`.
|
||||
* - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort.
|
||||
*/
|
||||
reasoning_effort?: Shared.ReasoningEffort | null;
|
||||
|
||||
/**
|
||||
* An object specifying the format that the model must output.
|
||||
*
|
||||
@@ -577,8 +594,18 @@ export namespace RunCreateResponse {
|
||||
model?: string | null;
|
||||
|
||||
/**
|
||||
* Optional reasoning effort parameter. This is a query parameter used to select
|
||||
* responses.
|
||||
* Constrains effort on reasoning for
|
||||
* [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently
|
||||
* supported values are `none`, `minimal`, `low`, `medium`, and `high`. Reducing
|
||||
* reasoning effort can result in faster responses and fewer tokens used on
|
||||
* reasoning in a response.
|
||||
*
|
||||
* - `gpt-5.1` defaults to `none`, which does not perform reasoning. The supported
|
||||
* reasoning values for `gpt-5.1` are `none`, `low`, `medium`, and `high`. Tool
|
||||
* calls are supported for all reasoning values in gpt-5.1.
|
||||
* - All models before `gpt-5.1` default to `medium` reasoning effort, and do not
|
||||
* support `none`.
|
||||
* - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort.
|
||||
*/
|
||||
reasoning_effort?: Shared.ReasoningEffort | null;
|
||||
|
||||
@@ -645,6 +672,7 @@ export namespace RunCreateResponse {
|
||||
| ResponsesAPI.ResponseInputText
|
||||
| EvalItem.OutputText
|
||||
| EvalItem.InputImage
|
||||
| ResponsesAPI.ResponseInputAudio
|
||||
| Array<unknown>;
|
||||
|
||||
/**
|
||||
@@ -716,6 +744,22 @@ export namespace RunCreateResponse {
|
||||
*/
|
||||
max_completion_tokens?: number;
|
||||
|
||||
/**
|
||||
* Constrains effort on reasoning for
|
||||
* [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently
|
||||
* supported values are `none`, `minimal`, `low`, `medium`, and `high`. Reducing
|
||||
* reasoning effort can result in faster responses and fewer tokens used on
|
||||
* reasoning in a response.
|
||||
*
|
||||
* - `gpt-5.1` defaults to `none`, which does not perform reasoning. The supported
|
||||
* reasoning values for `gpt-5.1` are `none`, `low`, `medium`, and `high`. Tool
|
||||
* calls are supported for all reasoning values in gpt-5.1.
|
||||
* - All models before `gpt-5.1` default to `medium` reasoning effort, and do not
|
||||
* support `none`.
|
||||
* - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort.
|
||||
*/
|
||||
reasoning_effort?: Shared.ReasoningEffort | null;
|
||||
|
||||
/**
|
||||
* A seed value to initialize the randomness, during sampling.
|
||||
*/
|
||||
@@ -1050,8 +1094,18 @@ export namespace RunRetrieveResponse {
|
||||
model?: string | null;
|
||||
|
||||
/**
|
||||
* Optional reasoning effort parameter. This is a query parameter used to select
|
||||
* responses.
|
||||
* Constrains effort on reasoning for
|
||||
* [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently
|
||||
* supported values are `none`, `minimal`, `low`, `medium`, and `high`. Reducing
|
||||
* reasoning effort can result in faster responses and fewer tokens used on
|
||||
* reasoning in a response.
|
||||
*
|
||||
* - `gpt-5.1` defaults to `none`, which does not perform reasoning. The supported
|
||||
* reasoning values for `gpt-5.1` are `none`, `low`, `medium`, and `high`. Tool
|
||||
* calls are supported for all reasoning values in gpt-5.1.
|
||||
* - All models before `gpt-5.1` default to `medium` reasoning effort, and do not
|
||||
* support `none`.
|
||||
* - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort.
|
||||
*/
|
||||
reasoning_effort?: Shared.ReasoningEffort | null;
|
||||
|
||||
@@ -1118,6 +1172,7 @@ export namespace RunRetrieveResponse {
|
||||
| ResponsesAPI.ResponseInputText
|
||||
| EvalItem.OutputText
|
||||
| EvalItem.InputImage
|
||||
| ResponsesAPI.ResponseInputAudio
|
||||
| Array<unknown>;
|
||||
|
||||
/**
|
||||
@@ -1189,6 +1244,22 @@ export namespace RunRetrieveResponse {
|
||||
*/
|
||||
max_completion_tokens?: number;
|
||||
|
||||
/**
|
||||
* Constrains effort on reasoning for
|
||||
* [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently
|
||||
* supported values are `none`, `minimal`, `low`, `medium`, and `high`. Reducing
|
||||
* reasoning effort can result in faster responses and fewer tokens used on
|
||||
* reasoning in a response.
|
||||
*
|
||||
* - `gpt-5.1` defaults to `none`, which does not perform reasoning. The supported
|
||||
* reasoning values for `gpt-5.1` are `none`, `low`, `medium`, and `high`. Tool
|
||||
* calls are supported for all reasoning values in gpt-5.1.
|
||||
* - All models before `gpt-5.1` default to `medium` reasoning effort, and do not
|
||||
* support `none`.
|
||||
* - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort.
|
||||
*/
|
||||
reasoning_effort?: Shared.ReasoningEffort | null;
|
||||
|
||||
/**
|
||||
* A seed value to initialize the randomness, during sampling.
|
||||
*/
|
||||
@@ -1520,8 +1591,18 @@ export namespace RunListResponse {
|
||||
model?: string | null;
|
||||
|
||||
/**
|
||||
* Optional reasoning effort parameter. This is a query parameter used to select
|
||||
* responses.
|
||||
* Constrains effort on reasoning for
|
||||
* [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently
|
||||
* supported values are `none`, `minimal`, `low`, `medium`, and `high`. Reducing
|
||||
* reasoning effort can result in faster responses and fewer tokens used on
|
||||
* reasoning in a response.
|
||||
*
|
||||
* - `gpt-5.1` defaults to `none`, which does not perform reasoning. The supported
|
||||
* reasoning values for `gpt-5.1` are `none`, `low`, `medium`, and `high`. Tool
|
||||
* calls are supported for all reasoning values in gpt-5.1.
|
||||
* - All models before `gpt-5.1` default to `medium` reasoning effort, and do not
|
||||
* support `none`.
|
||||
* - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort.
|
||||
*/
|
||||
reasoning_effort?: Shared.ReasoningEffort | null;
|
||||
|
||||
@@ -1588,6 +1669,7 @@ export namespace RunListResponse {
|
||||
| ResponsesAPI.ResponseInputText
|
||||
| EvalItem.OutputText
|
||||
| EvalItem.InputImage
|
||||
| ResponsesAPI.ResponseInputAudio
|
||||
| Array<unknown>;
|
||||
|
||||
/**
|
||||
@@ -1659,6 +1741,22 @@ export namespace RunListResponse {
|
||||
*/
|
||||
max_completion_tokens?: number;
|
||||
|
||||
/**
|
||||
* Constrains effort on reasoning for
|
||||
* [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently
|
||||
* supported values are `none`, `minimal`, `low`, `medium`, and `high`. Reducing
|
||||
* reasoning effort can result in faster responses and fewer tokens used on
|
||||
* reasoning in a response.
|
||||
*
|
||||
* - `gpt-5.1` defaults to `none`, which does not perform reasoning. The supported
|
||||
* reasoning values for `gpt-5.1` are `none`, `low`, `medium`, and `high`. Tool
|
||||
* calls are supported for all reasoning values in gpt-5.1.
|
||||
* - All models before `gpt-5.1` default to `medium` reasoning effort, and do not
|
||||
* support `none`.
|
||||
* - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort.
|
||||
*/
|
||||
reasoning_effort?: Shared.ReasoningEffort | null;
|
||||
|
||||
/**
|
||||
* A seed value to initialize the randomness, during sampling.
|
||||
*/
|
||||
@@ -2001,8 +2099,18 @@ export namespace RunCancelResponse {
|
||||
model?: string | null;
|
||||
|
||||
/**
|
||||
* Optional reasoning effort parameter. This is a query parameter used to select
|
||||
* responses.
|
||||
* Constrains effort on reasoning for
|
||||
* [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently
|
||||
* supported values are `none`, `minimal`, `low`, `medium`, and `high`. Reducing
|
||||
* reasoning effort can result in faster responses and fewer tokens used on
|
||||
* reasoning in a response.
|
||||
*
|
||||
* - `gpt-5.1` defaults to `none`, which does not perform reasoning. The supported
|
||||
* reasoning values for `gpt-5.1` are `none`, `low`, `medium`, and `high`. Tool
|
||||
* calls are supported for all reasoning values in gpt-5.1.
|
||||
* - All models before `gpt-5.1` default to `medium` reasoning effort, and do not
|
||||
* support `none`.
|
||||
* - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort.
|
||||
*/
|
||||
reasoning_effort?: Shared.ReasoningEffort | null;
|
||||
|
||||
@@ -2069,6 +2177,7 @@ export namespace RunCancelResponse {
|
||||
| ResponsesAPI.ResponseInputText
|
||||
| EvalItem.OutputText
|
||||
| EvalItem.InputImage
|
||||
| ResponsesAPI.ResponseInputAudio
|
||||
| Array<unknown>;
|
||||
|
||||
/**
|
||||
@@ -2140,6 +2249,22 @@ export namespace RunCancelResponse {
|
||||
*/
|
||||
max_completion_tokens?: number;
|
||||
|
||||
/**
|
||||
* Constrains effort on reasoning for
|
||||
* [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently
|
||||
* supported values are `none`, `minimal`, `low`, `medium`, and `high`. Reducing
|
||||
* reasoning effort can result in faster responses and fewer tokens used on
|
||||
* reasoning in a response.
|
||||
*
|
||||
* - `gpt-5.1` defaults to `none`, which does not perform reasoning. The supported
|
||||
* reasoning values for `gpt-5.1` are `none`, `low`, `medium`, and `high`. Tool
|
||||
* calls are supported for all reasoning values in gpt-5.1.
|
||||
* - All models before `gpt-5.1` default to `medium` reasoning effort, and do not
|
||||
* support `none`.
|
||||
* - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort.
|
||||
*/
|
||||
reasoning_effort?: Shared.ReasoningEffort | null;
|
||||
|
||||
/**
|
||||
* A seed value to initialize the randomness, during sampling.
|
||||
*/
|
||||
@@ -2421,8 +2546,18 @@ export namespace RunCreateParams {
|
||||
model?: string | null;
|
||||
|
||||
/**
|
||||
* Optional reasoning effort parameter. This is a query parameter used to select
|
||||
* responses.
|
||||
* Constrains effort on reasoning for
|
||||
* [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently
|
||||
* supported values are `none`, `minimal`, `low`, `medium`, and `high`. Reducing
|
||||
* reasoning effort can result in faster responses and fewer tokens used on
|
||||
* reasoning in a response.
|
||||
*
|
||||
* - `gpt-5.1` defaults to `none`, which does not perform reasoning. The supported
|
||||
* reasoning values for `gpt-5.1` are `none`, `low`, `medium`, and `high`. Tool
|
||||
* calls are supported for all reasoning values in gpt-5.1.
|
||||
* - All models before `gpt-5.1` default to `medium` reasoning effort, and do not
|
||||
* support `none`.
|
||||
* - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort.
|
||||
*/
|
||||
reasoning_effort?: Shared.ReasoningEffort | null;
|
||||
|
||||
@@ -2489,6 +2624,7 @@ export namespace RunCreateParams {
|
||||
| ResponsesAPI.ResponseInputText
|
||||
| EvalItem.OutputText
|
||||
| EvalItem.InputImage
|
||||
| ResponsesAPI.ResponseInputAudio
|
||||
| Array<unknown>;
|
||||
|
||||
/**
|
||||
@@ -2560,6 +2696,22 @@ export namespace RunCreateParams {
|
||||
*/
|
||||
max_completion_tokens?: number;
|
||||
|
||||
/**
|
||||
* Constrains effort on reasoning for
|
||||
* [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently
|
||||
* supported values are `none`, `minimal`, `low`, `medium`, and `high`. Reducing
|
||||
* reasoning effort can result in faster responses and fewer tokens used on
|
||||
* reasoning in a response.
|
||||
*
|
||||
* - `gpt-5.1` defaults to `none`, which does not perform reasoning. The supported
|
||||
* reasoning values for `gpt-5.1` are `none`, `low`, `medium`, and `high`. Tool
|
||||
* calls are supported for all reasoning values in gpt-5.1.
|
||||
* - All models before `gpt-5.1` default to `medium` reasoning effort, and do not
|
||||
* support `none`.
|
||||
* - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort.
|
||||
*/
|
||||
reasoning_effort?: Shared.ReasoningEffort | null;
|
||||
|
||||
/**
|
||||
* A seed value to initialize the randomness, during sampling.
|
||||
*/
|
||||
|
||||
29
node_modules/openai/src/resources/files.ts
generated
vendored
29
node_modules/openai/src/resources/files.ts
generated
vendored
@@ -17,20 +17,19 @@ export class Files extends APIResource {
|
||||
* up to 512 MB, and the size of all files uploaded by one organization can be up
|
||||
* to 1 TB.
|
||||
*
|
||||
* The Assistants API supports files up to 2 million tokens and of specific file
|
||||
* types. See the
|
||||
* [Assistants Tools guide](https://platform.openai.com/docs/assistants/tools) for
|
||||
* details.
|
||||
*
|
||||
* The Fine-tuning API only supports `.jsonl` files. The input also has certain
|
||||
* required formats for fine-tuning
|
||||
* [chat](https://platform.openai.com/docs/api-reference/fine-tuning/chat-input) or
|
||||
* [completions](https://platform.openai.com/docs/api-reference/fine-tuning/completions-input)
|
||||
* models.
|
||||
*
|
||||
* The Batch API only supports `.jsonl` files up to 200 MB in size. The input also
|
||||
* has a specific required
|
||||
* [format](https://platform.openai.com/docs/api-reference/batch/request-input).
|
||||
* - The Assistants API supports files up to 2 million tokens and of specific file
|
||||
* types. See the
|
||||
* [Assistants Tools guide](https://platform.openai.com/docs/assistants/tools)
|
||||
* for details.
|
||||
* - The Fine-tuning API only supports `.jsonl` files. The input also has certain
|
||||
* required formats for fine-tuning
|
||||
* [chat](https://platform.openai.com/docs/api-reference/fine-tuning/chat-input)
|
||||
* or
|
||||
* [completions](https://platform.openai.com/docs/api-reference/fine-tuning/completions-input)
|
||||
* models.
|
||||
* - The Batch API only supports `.jsonl` files up to 200 MB in size. The input
|
||||
* also has a specific required
|
||||
* [format](https://platform.openai.com/docs/api-reference/batch/request-input).
|
||||
*
|
||||
* Please [contact us](https://help.openai.com/) if you need to increase these
|
||||
* storage limits.
|
||||
@@ -57,7 +56,7 @@ export class Files extends APIResource {
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a file.
|
||||
* Delete a file and remove it from all vector stores.
|
||||
*/
|
||||
delete(fileID: string, options?: RequestOptions): APIPromise<FileDeleted> {
|
||||
return this._client.delete(path`/files/${fileID}`, options);
|
||||
|
||||
60
node_modules/openai/src/resources/graders/grader-models.ts
generated
vendored
60
node_modules/openai/src/resources/graders/grader-models.ts
generated
vendored
@@ -1,6 +1,7 @@
|
||||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
import { APIResource } from '../../core/resource';
|
||||
import * as Shared from '../shared';
|
||||
import * as ResponsesAPI from '../responses/responses';
|
||||
|
||||
export class GraderModels extends APIResource {}
|
||||
@@ -50,7 +51,13 @@ export namespace LabelModelGrader {
|
||||
/**
|
||||
* Inputs to the model - can contain template strings.
|
||||
*/
|
||||
content: string | ResponsesAPI.ResponseInputText | Input.OutputText | Input.InputImage | Array<unknown>;
|
||||
content:
|
||||
| string
|
||||
| ResponsesAPI.ResponseInputText
|
||||
| Input.OutputText
|
||||
| Input.InputImage
|
||||
| ResponsesAPI.ResponseInputAudio
|
||||
| Array<unknown>;
|
||||
|
||||
/**
|
||||
* The role of the message input. One of `user`, `assistant`, `system`, or
|
||||
@@ -187,7 +194,7 @@ export interface ScoreModelGrader {
|
||||
/**
|
||||
* The sampling parameters for the model.
|
||||
*/
|
||||
sampling_params?: unknown;
|
||||
sampling_params?: ScoreModelGrader.SamplingParams;
|
||||
}
|
||||
|
||||
export namespace ScoreModelGrader {
|
||||
@@ -202,7 +209,13 @@ export namespace ScoreModelGrader {
|
||||
/**
|
||||
* Inputs to the model - can contain template strings.
|
||||
*/
|
||||
content: string | ResponsesAPI.ResponseInputText | Input.OutputText | Input.InputImage | Array<unknown>;
|
||||
content:
|
||||
| string
|
||||
| ResponsesAPI.ResponseInputText
|
||||
| Input.OutputText
|
||||
| Input.InputImage
|
||||
| ResponsesAPI.ResponseInputAudio
|
||||
| Array<unknown>;
|
||||
|
||||
/**
|
||||
* The role of the message input. One of `user`, `assistant`, `system`, or
|
||||
@@ -253,6 +266,47 @@ export namespace ScoreModelGrader {
|
||||
detail?: string;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The sampling parameters for the model.
|
||||
*/
|
||||
export interface SamplingParams {
|
||||
/**
|
||||
* The maximum number of tokens the grader model may generate in its response.
|
||||
*/
|
||||
max_completions_tokens?: number | null;
|
||||
|
||||
/**
|
||||
* Constrains effort on reasoning for
|
||||
* [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently
|
||||
* supported values are `none`, `minimal`, `low`, `medium`, and `high`. Reducing
|
||||
* reasoning effort can result in faster responses and fewer tokens used on
|
||||
* reasoning in a response.
|
||||
*
|
||||
* - `gpt-5.1` defaults to `none`, which does not perform reasoning. The supported
|
||||
* reasoning values for `gpt-5.1` are `none`, `low`, `medium`, and `high`. Tool
|
||||
* calls are supported for all reasoning values in gpt-5.1.
|
||||
* - All models before `gpt-5.1` default to `medium` reasoning effort, and do not
|
||||
* support `none`.
|
||||
* - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort.
|
||||
*/
|
||||
reasoning_effort?: Shared.ReasoningEffort | null;
|
||||
|
||||
/**
|
||||
* A seed value to initialize the randomness, during sampling.
|
||||
*/
|
||||
seed?: number | null;
|
||||
|
||||
/**
|
||||
* A higher temperature increases randomness in the outputs.
|
||||
*/
|
||||
temperature?: number | null;
|
||||
|
||||
/**
|
||||
* An alternative to temperature for nucleus sampling; 1.0 includes all tokens.
|
||||
*/
|
||||
top_p?: number | null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
5
node_modules/openai/src/resources/images.ts
generated
vendored
5
node_modules/openai/src/resources/images.ts
generated
vendored
@@ -386,7 +386,7 @@ export interface ImageGenPartialImageEvent {
|
||||
*/
|
||||
export type ImageGenStreamEvent = ImageGenPartialImageEvent | ImageGenCompletedEvent;
|
||||
|
||||
export type ImageModel = 'dall-e-2' | 'dall-e-3' | 'gpt-image-1';
|
||||
export type ImageModel = 'dall-e-2' | 'dall-e-3' | 'gpt-image-1' | 'gpt-image-1-mini';
|
||||
|
||||
/**
|
||||
* The response from the image generation endpoint.
|
||||
@@ -547,7 +547,8 @@ export interface ImageEditParamsBase {
|
||||
/**
|
||||
* Control how much effort the model will exert to match the style and features,
|
||||
* especially facial features, of input images. This parameter is only supported
|
||||
* for `gpt-image-1`. Supports `high` and `low`. Defaults to `low`.
|
||||
* for `gpt-image-1`. Unsupported for `gpt-image-1-mini`. Supports `high` and
|
||||
* `low`. Defaults to `low`.
|
||||
*/
|
||||
input_fidelity?: 'high' | 'low' | null;
|
||||
|
||||
|
||||
16
node_modules/openai/src/resources/index.ts
generated
vendored
16
node_modules/openai/src/resources/index.ts
generated
vendored
@@ -8,6 +8,7 @@ export {
|
||||
type Batch,
|
||||
type BatchError,
|
||||
type BatchRequestCounts,
|
||||
type BatchUsage,
|
||||
type BatchCreateParams,
|
||||
type BatchListParams,
|
||||
type BatchesPage,
|
||||
@@ -95,6 +96,7 @@ export {
|
||||
type ModerationCreateResponse,
|
||||
type ModerationCreateParams,
|
||||
} from './moderations';
|
||||
export { Realtime } from './realtime/realtime';
|
||||
export { Responses } from './responses/responses';
|
||||
export { Uploads, type Upload, type UploadCreateParams, type UploadCompleteParams } from './uploads/uploads';
|
||||
export {
|
||||
@@ -116,4 +118,18 @@ export {
|
||||
type VectorStoresPage,
|
||||
type VectorStoreSearchResponsesPage,
|
||||
} from './vector-stores/vector-stores';
|
||||
export {
|
||||
Videos,
|
||||
type Video,
|
||||
type VideoCreateError,
|
||||
type VideoModel,
|
||||
type VideoSeconds,
|
||||
type VideoSize,
|
||||
type VideoDeleteResponse,
|
||||
type VideoCreateParams,
|
||||
type VideoListParams,
|
||||
type VideoDownloadContentParams,
|
||||
type VideoRemixParams,
|
||||
type VideosPage,
|
||||
} from './videos';
|
||||
export { Webhooks } from './webhooks';
|
||||
|
||||
3
node_modules/openai/src/resources/realtime.ts
generated
vendored
Normal file
3
node_modules/openai/src/resources/realtime.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
export * from './realtime/index';
|
||||
219
node_modules/openai/src/resources/realtime/calls.ts
generated
vendored
Normal file
219
node_modules/openai/src/resources/realtime/calls.ts
generated
vendored
Normal file
@@ -0,0 +1,219 @@
|
||||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
import { APIResource } from '../../core/resource';
|
||||
import * as RealtimeAPI from './realtime';
|
||||
import * as ResponsesAPI from '../responses/responses';
|
||||
import { APIPromise } from '../../core/api-promise';
|
||||
import { buildHeaders } from '../../internal/headers';
|
||||
import { RequestOptions } from '../../internal/request-options';
|
||||
import { path } from '../../internal/utils/path';
|
||||
|
||||
export class Calls extends APIResource {
|
||||
/**
|
||||
* Accept an incoming SIP call and configure the realtime session that will handle
|
||||
* it.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* await client.realtime.calls.accept('call_id', {
|
||||
* type: 'realtime',
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
accept(callID: string, body: CallAcceptParams, options?: RequestOptions): APIPromise<void> {
|
||||
return this._client.post(path`/realtime/calls/${callID}/accept`, {
|
||||
body,
|
||||
...options,
|
||||
headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* End an active Realtime API call, whether it was initiated over SIP or WebRTC.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* await client.realtime.calls.hangup('call_id');
|
||||
* ```
|
||||
*/
|
||||
hangup(callID: string, options?: RequestOptions): APIPromise<void> {
|
||||
return this._client.post(path`/realtime/calls/${callID}/hangup`, {
|
||||
...options,
|
||||
headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Transfer an active SIP call to a new destination using the SIP REFER verb.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* await client.realtime.calls.refer('call_id', {
|
||||
* target_uri: 'tel:+14155550123',
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
refer(callID: string, body: CallReferParams, options?: RequestOptions): APIPromise<void> {
|
||||
return this._client.post(path`/realtime/calls/${callID}/refer`, {
|
||||
body,
|
||||
...options,
|
||||
headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Decline an incoming SIP call by returning a SIP status code to the caller.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* await client.realtime.calls.reject('call_id');
|
||||
* ```
|
||||
*/
|
||||
reject(
|
||||
callID: string,
|
||||
body: CallRejectParams | null | undefined = {},
|
||||
options?: RequestOptions,
|
||||
): APIPromise<void> {
|
||||
return this._client.post(path`/realtime/calls/${callID}/reject`, {
|
||||
body,
|
||||
...options,
|
||||
headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export interface CallAcceptParams {
|
||||
/**
|
||||
* The type of session to create. Always `realtime` for the Realtime API.
|
||||
*/
|
||||
type: 'realtime';
|
||||
|
||||
/**
|
||||
* Configuration for input and output audio.
|
||||
*/
|
||||
audio?: RealtimeAPI.RealtimeAudioConfig;
|
||||
|
||||
/**
|
||||
* Additional fields to include in server outputs.
|
||||
*
|
||||
* `item.input_audio_transcription.logprobs`: Include logprobs for input audio
|
||||
* transcription.
|
||||
*/
|
||||
include?: Array<'item.input_audio_transcription.logprobs'>;
|
||||
|
||||
/**
|
||||
* The default system instructions (i.e. system message) prepended to model calls.
|
||||
* This field allows the client to guide the model on desired responses. The model
|
||||
* can be instructed on response content and format, (e.g. "be extremely succinct",
|
||||
* "act friendly", "here are examples of good responses") and on audio behavior
|
||||
* (e.g. "talk quickly", "inject emotion into your voice", "laugh frequently"). The
|
||||
* instructions are not guaranteed to be followed by the model, but they provide
|
||||
* guidance to the model on the desired behavior.
|
||||
*
|
||||
* Note that the server sets default instructions which will be used if this field
|
||||
* is not set and are visible in the `session.created` event at the start of the
|
||||
* session.
|
||||
*/
|
||||
instructions?: string;
|
||||
|
||||
/**
|
||||
* Maximum number of output tokens for a single assistant response, inclusive of
|
||||
* tool calls. Provide an integer between 1 and 4096 to limit output tokens, or
|
||||
* `inf` for the maximum available tokens for a given model. Defaults to `inf`.
|
||||
*/
|
||||
max_output_tokens?: number | 'inf';
|
||||
|
||||
/**
|
||||
* The Realtime model used for this session.
|
||||
*/
|
||||
model?:
|
||||
| (string & {})
|
||||
| 'gpt-realtime'
|
||||
| 'gpt-realtime-2025-08-28'
|
||||
| 'gpt-4o-realtime-preview'
|
||||
| 'gpt-4o-realtime-preview-2024-10-01'
|
||||
| 'gpt-4o-realtime-preview-2024-12-17'
|
||||
| 'gpt-4o-realtime-preview-2025-06-03'
|
||||
| 'gpt-4o-mini-realtime-preview'
|
||||
| 'gpt-4o-mini-realtime-preview-2024-12-17'
|
||||
| 'gpt-realtime-mini'
|
||||
| 'gpt-realtime-mini-2025-10-06'
|
||||
| 'gpt-audio-mini'
|
||||
| 'gpt-audio-mini-2025-10-06';
|
||||
|
||||
/**
|
||||
* The set of modalities the model can respond with. It defaults to `["audio"]`,
|
||||
* indicating that the model will respond with audio plus a transcript. `["text"]`
|
||||
* can be used to make the model respond with text only. It is not possible to
|
||||
* request both `text` and `audio` at the same time.
|
||||
*/
|
||||
output_modalities?: Array<'text' | 'audio'>;
|
||||
|
||||
/**
|
||||
* Reference to a prompt template and its variables.
|
||||
* [Learn more](https://platform.openai.com/docs/guides/text?api-mode=responses#reusable-prompts).
|
||||
*/
|
||||
prompt?: ResponsesAPI.ResponsePrompt | null;
|
||||
|
||||
/**
|
||||
* How the model chooses tools. Provide one of the string modes or force a specific
|
||||
* function/MCP tool.
|
||||
*/
|
||||
tool_choice?: RealtimeAPI.RealtimeToolChoiceConfig;
|
||||
|
||||
/**
|
||||
* Tools available to the model.
|
||||
*/
|
||||
tools?: RealtimeAPI.RealtimeToolsConfig;
|
||||
|
||||
/**
|
||||
* Realtime API can write session traces to the
|
||||
* [Traces Dashboard](/logs?api=traces). Set to null to disable tracing. Once
|
||||
* tracing is enabled for a session, the configuration cannot be modified.
|
||||
*
|
||||
* `auto` will create a trace for the session with default values for the workflow
|
||||
* name, group id, and metadata.
|
||||
*/
|
||||
tracing?: RealtimeAPI.RealtimeTracingConfig | null;
|
||||
|
||||
/**
|
||||
* When the number of tokens in a conversation exceeds the model's input token
|
||||
* limit, the conversation be truncated, meaning messages (starting from the
|
||||
* oldest) will not be included in the model's context. A 32k context model with
|
||||
* 4,096 max output tokens can only include 28,224 tokens in the context before
|
||||
* truncation occurs. Clients can configure truncation behavior to truncate with a
|
||||
* lower max token limit, which is an effective way to control token usage and
|
||||
* cost. Truncation will reduce the number of cached tokens on the next turn
|
||||
* (busting the cache), since messages are dropped from the beginning of the
|
||||
* context. However, clients can also configure truncation to retain messages up to
|
||||
* a fraction of the maximum context size, which will reduce the need for future
|
||||
* truncations and thus improve the cache rate. Truncation can be disabled
|
||||
* entirely, which means the server will never truncate but would instead return an
|
||||
* error if the conversation exceeds the model's input token limit.
|
||||
*/
|
||||
truncation?: RealtimeAPI.RealtimeTruncation;
|
||||
}
|
||||
|
||||
export interface CallReferParams {
|
||||
/**
|
||||
* URI that should appear in the SIP Refer-To header. Supports values like
|
||||
* `tel:+14155550123` or `sip:agent@example.com`.
|
||||
*/
|
||||
target_uri: string;
|
||||
}
|
||||
|
||||
export interface CallRejectParams {
|
||||
/**
|
||||
* SIP response code to send back to the caller. Defaults to `603` (Decline) when
|
||||
* omitted.
|
||||
*/
|
||||
status_code?: number;
|
||||
}
|
||||
|
||||
export declare namespace Calls {
|
||||
export {
|
||||
type CallAcceptParams as CallAcceptParams,
|
||||
type CallReferParams as CallReferParams,
|
||||
type CallRejectParams as CallRejectParams,
|
||||
};
|
||||
}
|
||||
732
node_modules/openai/src/resources/realtime/client-secrets.ts
generated
vendored
Normal file
732
node_modules/openai/src/resources/realtime/client-secrets.ts
generated
vendored
Normal file
@@ -0,0 +1,732 @@
|
||||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
import { APIResource } from '../../core/resource';
|
||||
import * as ClientSecretsAPI from './client-secrets';
|
||||
import * as RealtimeAPI from './realtime';
|
||||
import * as ResponsesAPI from '../responses/responses';
|
||||
import { APIPromise } from '../../core/api-promise';
|
||||
import { RequestOptions } from '../../internal/request-options';
|
||||
|
||||
export class ClientSecrets extends APIResource {
|
||||
/**
|
||||
* Create a Realtime client secret with an associated session configuration.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* const clientSecret =
|
||||
* await client.realtime.clientSecrets.create();
|
||||
* ```
|
||||
*/
|
||||
create(body: ClientSecretCreateParams, options?: RequestOptions): APIPromise<ClientSecretCreateResponse> {
|
||||
return this._client.post('/realtime/client_secrets', { body, ...options });
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ephemeral key returned by the API.
|
||||
*/
|
||||
export interface RealtimeSessionClientSecret {
|
||||
/**
|
||||
* Timestamp for when the token expires. Currently, all tokens expire after one
|
||||
* minute.
|
||||
*/
|
||||
expires_at: number;
|
||||
|
||||
/**
|
||||
* Ephemeral key usable in client environments to authenticate connections to the
|
||||
* Realtime API. Use this in client-side environments rather than a standard API
|
||||
* token, which should only be used server-side.
|
||||
*/
|
||||
value: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* A new Realtime session configuration, with an ephemeral key. Default TTL for
|
||||
* keys is one minute.
|
||||
*/
|
||||
export interface RealtimeSessionCreateResponse {
|
||||
/**
|
||||
* Ephemeral key returned by the API.
|
||||
*/
|
||||
client_secret: RealtimeSessionClientSecret;
|
||||
|
||||
/**
|
||||
* The type of session to create. Always `realtime` for the Realtime API.
|
||||
*/
|
||||
type: 'realtime';
|
||||
|
||||
/**
|
||||
* Configuration for input and output audio.
|
||||
*/
|
||||
audio?: RealtimeSessionCreateResponse.Audio;
|
||||
|
||||
/**
|
||||
* Additional fields to include in server outputs.
|
||||
*
|
||||
* `item.input_audio_transcription.logprobs`: Include logprobs for input audio
|
||||
* transcription.
|
||||
*/
|
||||
include?: Array<'item.input_audio_transcription.logprobs'>;
|
||||
|
||||
/**
|
||||
* The default system instructions (i.e. system message) prepended to model calls.
|
||||
* This field allows the client to guide the model on desired responses. The model
|
||||
* can be instructed on response content and format, (e.g. "be extremely succinct",
|
||||
* "act friendly", "here are examples of good responses") and on audio behavior
|
||||
* (e.g. "talk quickly", "inject emotion into your voice", "laugh frequently"). The
|
||||
* instructions are not guaranteed to be followed by the model, but they provide
|
||||
* guidance to the model on the desired behavior.
|
||||
*
|
||||
* Note that the server sets default instructions which will be used if this field
|
||||
* is not set and are visible in the `session.created` event at the start of the
|
||||
* session.
|
||||
*/
|
||||
instructions?: string;
|
||||
|
||||
/**
|
||||
* Maximum number of output tokens for a single assistant response, inclusive of
|
||||
* tool calls. Provide an integer between 1 and 4096 to limit output tokens, or
|
||||
* `inf` for the maximum available tokens for a given model. Defaults to `inf`.
|
||||
*/
|
||||
max_output_tokens?: number | 'inf';
|
||||
|
||||
/**
|
||||
* The Realtime model used for this session.
|
||||
*/
|
||||
model?:
|
||||
| (string & {})
|
||||
| 'gpt-realtime'
|
||||
| 'gpt-realtime-2025-08-28'
|
||||
| 'gpt-4o-realtime-preview'
|
||||
| 'gpt-4o-realtime-preview-2024-10-01'
|
||||
| 'gpt-4o-realtime-preview-2024-12-17'
|
||||
| 'gpt-4o-realtime-preview-2025-06-03'
|
||||
| 'gpt-4o-mini-realtime-preview'
|
||||
| 'gpt-4o-mini-realtime-preview-2024-12-17'
|
||||
| 'gpt-realtime-mini'
|
||||
| 'gpt-realtime-mini-2025-10-06'
|
||||
| 'gpt-audio-mini'
|
||||
| 'gpt-audio-mini-2025-10-06';
|
||||
|
||||
/**
|
||||
* The set of modalities the model can respond with. It defaults to `["audio"]`,
|
||||
* indicating that the model will respond with audio plus a transcript. `["text"]`
|
||||
* can be used to make the model respond with text only. It is not possible to
|
||||
* request both `text` and `audio` at the same time.
|
||||
*/
|
||||
output_modalities?: Array<'text' | 'audio'>;
|
||||
|
||||
/**
|
||||
* Reference to a prompt template and its variables.
|
||||
* [Learn more](https://platform.openai.com/docs/guides/text?api-mode=responses#reusable-prompts).
|
||||
*/
|
||||
prompt?: ResponsesAPI.ResponsePrompt | null;
|
||||
|
||||
/**
|
||||
* How the model chooses tools. Provide one of the string modes or force a specific
|
||||
* function/MCP tool.
|
||||
*/
|
||||
tool_choice?: ResponsesAPI.ToolChoiceOptions | ResponsesAPI.ToolChoiceFunction | ResponsesAPI.ToolChoiceMcp;
|
||||
|
||||
/**
|
||||
* Tools available to the model.
|
||||
*/
|
||||
tools?: Array<RealtimeAPI.RealtimeFunctionTool | RealtimeSessionCreateResponse.McpTool>;
|
||||
|
||||
/**
|
||||
* Realtime API can write session traces to the
|
||||
* [Traces Dashboard](/logs?api=traces). Set to null to disable tracing. Once
|
||||
* tracing is enabled for a session, the configuration cannot be modified.
|
||||
*
|
||||
* `auto` will create a trace for the session with default values for the workflow
|
||||
* name, group id, and metadata.
|
||||
*/
|
||||
tracing?: 'auto' | RealtimeSessionCreateResponse.TracingConfiguration | null;
|
||||
|
||||
/**
|
||||
* When the number of tokens in a conversation exceeds the model's input token
|
||||
* limit, the conversation be truncated, meaning messages (starting from the
|
||||
* oldest) will not be included in the model's context. A 32k context model with
|
||||
* 4,096 max output tokens can only include 28,224 tokens in the context before
|
||||
* truncation occurs. Clients can configure truncation behavior to truncate with a
|
||||
* lower max token limit, which is an effective way to control token usage and
|
||||
* cost. Truncation will reduce the number of cached tokens on the next turn
|
||||
* (busting the cache), since messages are dropped from the beginning of the
|
||||
* context. However, clients can also configure truncation to retain messages up to
|
||||
* a fraction of the maximum context size, which will reduce the need for future
|
||||
* truncations and thus improve the cache rate. Truncation can be disabled
|
||||
* entirely, which means the server will never truncate but would instead return an
|
||||
* error if the conversation exceeds the model's input token limit.
|
||||
*/
|
||||
truncation?: RealtimeAPI.RealtimeTruncation;
|
||||
}
|
||||
|
||||
export namespace RealtimeSessionCreateResponse {
|
||||
/**
|
||||
* Configuration for input and output audio.
|
||||
*/
|
||||
export interface Audio {
|
||||
input?: Audio.Input;
|
||||
|
||||
output?: Audio.Output;
|
||||
}
|
||||
|
||||
export namespace Audio {
|
||||
export interface Input {
|
||||
/**
|
||||
* The format of the input audio.
|
||||
*/
|
||||
format?: RealtimeAPI.RealtimeAudioFormats;
|
||||
|
||||
/**
|
||||
* 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
|
||||
* sent to VAD and the model. Filtering the audio can improve VAD and turn
|
||||
* detection accuracy (reducing false positives) and model performance by improving
|
||||
* perception of the input audio.
|
||||
*/
|
||||
noise_reduction?: Input.NoiseReduction;
|
||||
|
||||
/**
|
||||
* Configuration for input audio transcription, defaults to off and can be set to
|
||||
* `null` to turn off once on. Input audio transcription is not native to the
|
||||
* model, since the model consumes audio directly. Transcription runs
|
||||
* asynchronously through
|
||||
* [the /audio/transcriptions endpoint](https://platform.openai.com/docs/api-reference/audio/createTranscription)
|
||||
* and should be treated as guidance of input audio content rather than precisely
|
||||
* what the model heard. The client can optionally set the language and prompt for
|
||||
* transcription, these offer additional guidance to the transcription service.
|
||||
*/
|
||||
transcription?: RealtimeAPI.AudioTranscription;
|
||||
|
||||
/**
|
||||
* Configuration for turn detection, ether Server VAD or Semantic VAD. This can be
|
||||
* set to `null` to turn off, in which case the client must manually trigger model
|
||||
* response.
|
||||
*
|
||||
* Server VAD means that the model will detect the start and end of speech based on
|
||||
* audio volume and respond at the end of user speech.
|
||||
*
|
||||
* Semantic VAD is more advanced and uses a turn detection model (in conjunction
|
||||
* with VAD) to semantically estimate whether the user has finished speaking, then
|
||||
* dynamically sets a timeout based on this probability. For example, if user audio
|
||||
* trails off with "uhhm", the model will score a low probability of turn end and
|
||||
* wait longer for the user to continue speaking. This can be useful for more
|
||||
* natural conversations, but may have a higher latency.
|
||||
*/
|
||||
turn_detection?: Input.ServerVad | Input.SemanticVad | null;
|
||||
}
|
||||
|
||||
export namespace Input {
|
||||
/**
|
||||
* 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
|
||||
* sent to VAD and the model. Filtering the audio can improve VAD and turn
|
||||
* detection accuracy (reducing false positives) and model performance by improving
|
||||
* perception of the input audio.
|
||||
*/
|
||||
export interface NoiseReduction {
|
||||
/**
|
||||
* Type of noise reduction. `near_field` is for close-talking microphones such as
|
||||
* headphones, `far_field` is for far-field microphones such as laptop or
|
||||
* conference room microphones.
|
||||
*/
|
||||
type?: RealtimeAPI.NoiseReductionType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Server-side voice activity detection (VAD) which flips on when user speech is
|
||||
* detected and off after a period of silence.
|
||||
*/
|
||||
export interface ServerVad {
|
||||
/**
|
||||
* Type of turn detection, `server_vad` to turn on simple Server VAD.
|
||||
*/
|
||||
type: 'server_vad';
|
||||
|
||||
/**
|
||||
* Whether or not to automatically generate a response when a VAD stop event
|
||||
* occurs.
|
||||
*/
|
||||
create_response?: boolean;
|
||||
|
||||
/**
|
||||
* Optional timeout after which a model response will be triggered automatically.
|
||||
* This is useful for situations in which a long pause from the user is unexpected,
|
||||
* such as a phone call. The model will effectively prompt the user to continue the
|
||||
* conversation based on the current context.
|
||||
*
|
||||
* The timeout value will be applied after the last model response's audio has
|
||||
* finished playing, i.e. it's set to the `response.done` time plus audio playback
|
||||
* duration.
|
||||
*
|
||||
* An `input_audio_buffer.timeout_triggered` event (plus events associated with the
|
||||
* Response) will be emitted when the timeout is reached. Idle timeout is currently
|
||||
* only supported for `server_vad` mode.
|
||||
*/
|
||||
idle_timeout_ms?: number | null;
|
||||
|
||||
/**
|
||||
* Whether or not to automatically interrupt any ongoing response with output to
|
||||
* the default conversation (i.e. `conversation` of `auto`) when a VAD start event
|
||||
* occurs.
|
||||
*/
|
||||
interrupt_response?: boolean;
|
||||
|
||||
/**
|
||||
* Used only for `server_vad` mode. Amount of audio to include before the VAD
|
||||
* detected speech (in milliseconds). Defaults to 300ms.
|
||||
*/
|
||||
prefix_padding_ms?: number;
|
||||
|
||||
/**
|
||||
* Used only for `server_vad` mode. Duration of silence to detect speech stop (in
|
||||
* milliseconds). Defaults to 500ms. With shorter values the model will respond
|
||||
* more quickly, but may jump in on short pauses from the user.
|
||||
*/
|
||||
silence_duration_ms?: number;
|
||||
|
||||
/**
|
||||
* Used only for `server_vad` mode. Activation threshold for VAD (0.0 to 1.0), this
|
||||
* defaults to 0.5. A higher threshold will require louder audio to activate the
|
||||
* model, and thus might perform better in noisy environments.
|
||||
*/
|
||||
threshold?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Server-side semantic turn detection which uses a model to determine when the
|
||||
* user has finished speaking.
|
||||
*/
|
||||
export interface SemanticVad {
|
||||
/**
|
||||
* Type of turn detection, `semantic_vad` to turn on Semantic VAD.
|
||||
*/
|
||||
type: 'semantic_vad';
|
||||
|
||||
/**
|
||||
* Whether or not to automatically generate a response when a VAD stop event
|
||||
* occurs.
|
||||
*/
|
||||
create_response?: boolean;
|
||||
|
||||
/**
|
||||
* Used only for `semantic_vad` mode. The eagerness of the model to respond. `low`
|
||||
* will wait longer for the user to continue speaking, `high` will respond more
|
||||
* quickly. `auto` is the default and is equivalent to `medium`. `low`, `medium`,
|
||||
* and `high` have max timeouts of 8s, 4s, and 2s respectively.
|
||||
*/
|
||||
eagerness?: 'low' | 'medium' | 'high' | 'auto';
|
||||
|
||||
/**
|
||||
* Whether or not to automatically interrupt any ongoing response with output to
|
||||
* the default conversation (i.e. `conversation` of `auto`) when a VAD start event
|
||||
* occurs.
|
||||
*/
|
||||
interrupt_response?: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
export interface Output {
|
||||
/**
|
||||
* The format of the output audio.
|
||||
*/
|
||||
format?: RealtimeAPI.RealtimeAudioFormats;
|
||||
|
||||
/**
|
||||
* The speed of the model's spoken response as a multiple of the original speed.
|
||||
* 1.0 is the default speed. 0.25 is the minimum speed. 1.5 is the maximum speed.
|
||||
* This value can only be changed in between model turns, not while a response is
|
||||
* in progress.
|
||||
*
|
||||
* This parameter is a post-processing adjustment to the audio after it is
|
||||
* generated, it's also possible to prompt the model to speak faster or slower.
|
||||
*/
|
||||
speed?: number;
|
||||
|
||||
/**
|
||||
* The voice the model uses to respond. Voice cannot be changed during the session
|
||||
* once the model has responded with audio at least once. Current voice options are
|
||||
* `alloy`, `ash`, `ballad`, `coral`, `echo`, `sage`, `shimmer`, `verse`, `marin`,
|
||||
* and `cedar`. We recommend `marin` and `cedar` for best quality.
|
||||
*/
|
||||
voice?:
|
||||
| (string & {})
|
||||
| 'alloy'
|
||||
| 'ash'
|
||||
| 'ballad'
|
||||
| 'coral'
|
||||
| 'echo'
|
||||
| 'sage'
|
||||
| 'shimmer'
|
||||
| 'verse'
|
||||
| 'marin'
|
||||
| 'cedar';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Give the model access to additional tools via remote Model Context Protocol
|
||||
* (MCP) servers.
|
||||
* [Learn more about MCP](https://platform.openai.com/docs/guides/tools-remote-mcp).
|
||||
*/
|
||||
export interface McpTool {
|
||||
/**
|
||||
* A label for this MCP server, used to identify it in tool calls.
|
||||
*/
|
||||
server_label: string;
|
||||
|
||||
/**
|
||||
* The type of the MCP tool. Always `mcp`.
|
||||
*/
|
||||
type: 'mcp';
|
||||
|
||||
/**
|
||||
* List of allowed tool names or a filter object.
|
||||
*/
|
||||
allowed_tools?: Array<string> | McpTool.McpToolFilter | null;
|
||||
|
||||
/**
|
||||
* An OAuth access token that can be used with a remote MCP server, either with a
|
||||
* custom MCP server URL or a service connector. Your application must handle the
|
||||
* OAuth authorization flow and provide the token here.
|
||||
*/
|
||||
authorization?: string;
|
||||
|
||||
/**
|
||||
* Identifier for service connectors, like those available in ChatGPT. One of
|
||||
* `server_url` or `connector_id` must be provided. Learn more about service
|
||||
* connectors
|
||||
* [here](https://platform.openai.com/docs/guides/tools-remote-mcp#connectors).
|
||||
*
|
||||
* Currently supported `connector_id` values are:
|
||||
*
|
||||
* - Dropbox: `connector_dropbox`
|
||||
* - Gmail: `connector_gmail`
|
||||
* - Google Calendar: `connector_googlecalendar`
|
||||
* - Google Drive: `connector_googledrive`
|
||||
* - Microsoft Teams: `connector_microsoftteams`
|
||||
* - Outlook Calendar: `connector_outlookcalendar`
|
||||
* - Outlook Email: `connector_outlookemail`
|
||||
* - SharePoint: `connector_sharepoint`
|
||||
*/
|
||||
connector_id?:
|
||||
| 'connector_dropbox'
|
||||
| 'connector_gmail'
|
||||
| 'connector_googlecalendar'
|
||||
| 'connector_googledrive'
|
||||
| 'connector_microsoftteams'
|
||||
| 'connector_outlookcalendar'
|
||||
| 'connector_outlookemail'
|
||||
| 'connector_sharepoint';
|
||||
|
||||
/**
|
||||
* Optional HTTP headers to send to the MCP server. Use for authentication or other
|
||||
* purposes.
|
||||
*/
|
||||
headers?: { [key: string]: string } | null;
|
||||
|
||||
/**
|
||||
* Specify which of the MCP server's tools require approval.
|
||||
*/
|
||||
require_approval?: McpTool.McpToolApprovalFilter | 'always' | 'never' | null;
|
||||
|
||||
/**
|
||||
* Optional description of the MCP server, used to provide more context.
|
||||
*/
|
||||
server_description?: string;
|
||||
|
||||
/**
|
||||
* The URL for the MCP server. One of `server_url` or `connector_id` must be
|
||||
* provided.
|
||||
*/
|
||||
server_url?: string;
|
||||
}
|
||||
|
||||
export namespace McpTool {
|
||||
/**
|
||||
* A filter object to specify which tools are allowed.
|
||||
*/
|
||||
export interface McpToolFilter {
|
||||
/**
|
||||
* Indicates whether or not a tool modifies data or is read-only. If an MCP server
|
||||
* is
|
||||
* [annotated with `readOnlyHint`](https://modelcontextprotocol.io/specification/2025-06-18/schema#toolannotations-readonlyhint),
|
||||
* it will match this filter.
|
||||
*/
|
||||
read_only?: boolean;
|
||||
|
||||
/**
|
||||
* List of allowed tool names.
|
||||
*/
|
||||
tool_names?: Array<string>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify which of the MCP server's tools require approval. Can be `always`,
|
||||
* `never`, or a filter object associated with tools that require approval.
|
||||
*/
|
||||
export interface McpToolApprovalFilter {
|
||||
/**
|
||||
* A filter object to specify which tools are allowed.
|
||||
*/
|
||||
always?: McpToolApprovalFilter.Always;
|
||||
|
||||
/**
|
||||
* A filter object to specify which tools are allowed.
|
||||
*/
|
||||
never?: McpToolApprovalFilter.Never;
|
||||
}
|
||||
|
||||
export namespace McpToolApprovalFilter {
|
||||
/**
|
||||
* A filter object to specify which tools are allowed.
|
||||
*/
|
||||
export interface Always {
|
||||
/**
|
||||
* Indicates whether or not a tool modifies data or is read-only. If an MCP server
|
||||
* is
|
||||
* [annotated with `readOnlyHint`](https://modelcontextprotocol.io/specification/2025-06-18/schema#toolannotations-readonlyhint),
|
||||
* it will match this filter.
|
||||
*/
|
||||
read_only?: boolean;
|
||||
|
||||
/**
|
||||
* List of allowed tool names.
|
||||
*/
|
||||
tool_names?: Array<string>;
|
||||
}
|
||||
|
||||
/**
|
||||
* A filter object to specify which tools are allowed.
|
||||
*/
|
||||
export interface Never {
|
||||
/**
|
||||
* Indicates whether or not a tool modifies data or is read-only. If an MCP server
|
||||
* is
|
||||
* [annotated with `readOnlyHint`](https://modelcontextprotocol.io/specification/2025-06-18/schema#toolannotations-readonlyhint),
|
||||
* it will match this filter.
|
||||
*/
|
||||
read_only?: boolean;
|
||||
|
||||
/**
|
||||
* List of allowed tool names.
|
||||
*/
|
||||
tool_names?: Array<string>;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Granular configuration for tracing.
|
||||
*/
|
||||
export interface TracingConfiguration {
|
||||
/**
|
||||
* The group id to attach to this trace to enable filtering and grouping in the
|
||||
* Traces Dashboard.
|
||||
*/
|
||||
group_id?: string;
|
||||
|
||||
/**
|
||||
* The arbitrary metadata to attach to this trace to enable filtering in the Traces
|
||||
* Dashboard.
|
||||
*/
|
||||
metadata?: unknown;
|
||||
|
||||
/**
|
||||
* The name of the workflow to attach to this trace. This is used to name the trace
|
||||
* in the Traces Dashboard.
|
||||
*/
|
||||
workflow_name?: string;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A Realtime transcription session configuration object.
|
||||
*/
|
||||
export interface RealtimeTranscriptionSessionCreateResponse {
|
||||
/**
|
||||
* Unique identifier for the session that looks like `sess_1234567890abcdef`.
|
||||
*/
|
||||
id: string;
|
||||
|
||||
/**
|
||||
* The object type. Always `realtime.transcription_session`.
|
||||
*/
|
||||
object: string;
|
||||
|
||||
/**
|
||||
* The type of session. Always `transcription` for transcription sessions.
|
||||
*/
|
||||
type: 'transcription';
|
||||
|
||||
/**
|
||||
* Configuration for input audio for the session.
|
||||
*/
|
||||
audio?: RealtimeTranscriptionSessionCreateResponse.Audio;
|
||||
|
||||
/**
|
||||
* Expiration timestamp for the session, in seconds since epoch.
|
||||
*/
|
||||
expires_at?: number;
|
||||
|
||||
/**
|
||||
* Additional fields to include in server outputs.
|
||||
*
|
||||
* - `item.input_audio_transcription.logprobs`: Include logprobs for input audio
|
||||
* transcription.
|
||||
*/
|
||||
include?: Array<'item.input_audio_transcription.logprobs'>;
|
||||
}
|
||||
|
||||
export namespace RealtimeTranscriptionSessionCreateResponse {
|
||||
/**
|
||||
* Configuration for input audio for the session.
|
||||
*/
|
||||
export interface Audio {
|
||||
input?: Audio.Input;
|
||||
}
|
||||
|
||||
export namespace Audio {
|
||||
export interface Input {
|
||||
/**
|
||||
* The PCM audio format. Only a 24kHz sample rate is supported.
|
||||
*/
|
||||
format?: RealtimeAPI.RealtimeAudioFormats;
|
||||
|
||||
/**
|
||||
* Configuration for input audio noise reduction.
|
||||
*/
|
||||
noise_reduction?: Input.NoiseReduction;
|
||||
|
||||
/**
|
||||
* Configuration of the transcription model.
|
||||
*/
|
||||
transcription?: RealtimeAPI.AudioTranscription;
|
||||
|
||||
/**
|
||||
* Configuration for turn detection. Can be set to `null` to turn off. Server VAD
|
||||
* means that the model will detect the start and end of speech based on audio
|
||||
* volume and respond at the end of user speech.
|
||||
*/
|
||||
turn_detection?: ClientSecretsAPI.RealtimeTranscriptionSessionTurnDetection;
|
||||
}
|
||||
|
||||
export namespace Input {
|
||||
/**
|
||||
* Configuration for input audio noise reduction.
|
||||
*/
|
||||
export interface NoiseReduction {
|
||||
/**
|
||||
* Type of noise reduction. `near_field` is for close-talking microphones such as
|
||||
* headphones, `far_field` is for far-field microphones such as laptop or
|
||||
* conference room microphones.
|
||||
*/
|
||||
type?: RealtimeAPI.NoiseReductionType;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Configuration for turn detection. Can be set to `null` to turn off. Server VAD
|
||||
* means that the model will detect the start and end of speech based on audio
|
||||
* volume and respond at the end of user speech.
|
||||
*/
|
||||
export interface RealtimeTranscriptionSessionTurnDetection {
|
||||
/**
|
||||
* Amount of audio to include before the VAD detected speech (in milliseconds).
|
||||
* Defaults to 300ms.
|
||||
*/
|
||||
prefix_padding_ms?: number;
|
||||
|
||||
/**
|
||||
* Duration of silence to detect speech stop (in milliseconds). Defaults to 500ms.
|
||||
* With shorter values the model will respond more quickly, but may jump in on
|
||||
* short pauses from the user.
|
||||
*/
|
||||
silence_duration_ms?: number;
|
||||
|
||||
/**
|
||||
* Activation threshold for VAD (0.0 to 1.0), this defaults to 0.5. A higher
|
||||
* threshold will require louder audio to activate the model, and thus might
|
||||
* perform better in noisy environments.
|
||||
*/
|
||||
threshold?: number;
|
||||
|
||||
/**
|
||||
* Type of turn detection, only `server_vad` is currently supported.
|
||||
*/
|
||||
type?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Response from creating a session and client secret for the Realtime API.
|
||||
*/
|
||||
export interface ClientSecretCreateResponse {
|
||||
/**
|
||||
* Expiration timestamp for the client secret, in seconds since epoch.
|
||||
*/
|
||||
expires_at: number;
|
||||
|
||||
/**
|
||||
* The session configuration for either a realtime or transcription session.
|
||||
*/
|
||||
session: RealtimeSessionCreateResponse | RealtimeTranscriptionSessionCreateResponse;
|
||||
|
||||
/**
|
||||
* The generated client secret value.
|
||||
*/
|
||||
value: string;
|
||||
}
|
||||
|
||||
export interface ClientSecretCreateParams {
|
||||
/**
|
||||
* Configuration for the client secret expiration. Expiration refers to the time
|
||||
* after which a client secret will no longer be valid for creating sessions. The
|
||||
* session itself may continue after that time once started. A secret can be used
|
||||
* to create multiple sessions until it expires.
|
||||
*/
|
||||
expires_after?: ClientSecretCreateParams.ExpiresAfter;
|
||||
|
||||
/**
|
||||
* Session configuration to use for the client secret. Choose either a realtime
|
||||
* session or a transcription session.
|
||||
*/
|
||||
session?: RealtimeAPI.RealtimeSessionCreateRequest | RealtimeAPI.RealtimeTranscriptionSessionCreateRequest;
|
||||
}
|
||||
|
||||
export namespace ClientSecretCreateParams {
|
||||
/**
|
||||
* Configuration for the client secret expiration. Expiration refers to the time
|
||||
* after which a client secret will no longer be valid for creating sessions. The
|
||||
* session itself may continue after that time once started. A secret can be used
|
||||
* to create multiple sessions until it expires.
|
||||
*/
|
||||
export interface ExpiresAfter {
|
||||
/**
|
||||
* The anchor point for the client secret expiration, meaning that `seconds` will
|
||||
* be added to the `created_at` time of the client secret to produce an expiration
|
||||
* timestamp. 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` (2 hours). This default to 600 seconds (10 minutes) if
|
||||
* not specified.
|
||||
*/
|
||||
seconds?: number;
|
||||
}
|
||||
}
|
||||
|
||||
export declare namespace ClientSecrets {
|
||||
export {
|
||||
type RealtimeSessionClientSecret as RealtimeSessionClientSecret,
|
||||
type RealtimeSessionCreateResponse as RealtimeSessionCreateResponse,
|
||||
type RealtimeTranscriptionSessionCreateResponse as RealtimeTranscriptionSessionCreateResponse,
|
||||
type RealtimeTranscriptionSessionTurnDetection as RealtimeTranscriptionSessionTurnDetection,
|
||||
type ClientSecretCreateResponse as ClientSecretCreateResponse,
|
||||
type ClientSecretCreateParams as ClientSecretCreateParams,
|
||||
};
|
||||
}
|
||||
13
node_modules/openai/src/resources/realtime/index.ts
generated
vendored
Normal file
13
node_modules/openai/src/resources/realtime/index.ts
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
export { Calls, type CallAcceptParams, type CallReferParams, type CallRejectParams } from './calls';
|
||||
export {
|
||||
ClientSecrets,
|
||||
type RealtimeSessionClientSecret,
|
||||
type RealtimeSessionCreateResponse,
|
||||
type RealtimeTranscriptionSessionCreateResponse,
|
||||
type RealtimeTranscriptionSessionTurnDetection,
|
||||
type ClientSecretCreateResponse,
|
||||
type ClientSecretCreateParams,
|
||||
} from './client-secrets';
|
||||
export { Realtime } from './realtime';
|
||||
4764
node_modules/openai/src/resources/realtime/realtime.ts
generated
vendored
Normal file
4764
node_modules/openai/src/resources/realtime/realtime.ts
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
node_modules/openai/src/resources/responses/index.ts
generated
vendored
1
node_modules/openai/src/resources/responses/index.ts
generated
vendored
@@ -1,4 +1,5 @@
|
||||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
export { InputItems, type ResponseItemList, type InputItemListParams } from './input-items';
|
||||
export { InputTokens, type InputTokenCountResponse, type InputTokenCountParams } from './input-tokens';
|
||||
export { Responses } from './responses';
|
||||
|
||||
163
node_modules/openai/src/resources/responses/input-tokens.ts
generated
vendored
Normal file
163
node_modules/openai/src/resources/responses/input-tokens.ts
generated
vendored
Normal file
@@ -0,0 +1,163 @@
|
||||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
import { APIResource } from '../../core/resource';
|
||||
import * as Shared from '../shared';
|
||||
import * as ResponsesAPI from './responses';
|
||||
import { APIPromise } from '../../core/api-promise';
|
||||
import { RequestOptions } from '../../internal/request-options';
|
||||
|
||||
export class InputTokens extends APIResource {
|
||||
/**
|
||||
* Get input token counts
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* const response = await client.responses.inputTokens.count();
|
||||
* ```
|
||||
*/
|
||||
count(
|
||||
body: InputTokenCountParams | null | undefined = {},
|
||||
options?: RequestOptions,
|
||||
): APIPromise<InputTokenCountResponse> {
|
||||
return this._client.post('/responses/input_tokens', { body, ...options });
|
||||
}
|
||||
}
|
||||
|
||||
export interface InputTokenCountResponse {
|
||||
input_tokens: number;
|
||||
|
||||
object: 'response.input_tokens';
|
||||
}
|
||||
|
||||
export interface InputTokenCountParams {
|
||||
/**
|
||||
* The conversation that this response belongs to. Items from this conversation are
|
||||
* prepended to `input_items` for this response request. Input items and output
|
||||
* items from this response are automatically added to this conversation after this
|
||||
* response completes.
|
||||
*/
|
||||
conversation?: string | ResponsesAPI.ResponseConversationParam | null;
|
||||
|
||||
/**
|
||||
* Text, image, or file inputs to the model, used to generate a response
|
||||
*/
|
||||
input?: string | Array<ResponsesAPI.ResponseInputItem> | null;
|
||||
|
||||
/**
|
||||
* A system (or developer) message inserted into the model's context. When used
|
||||
* along with `previous_response_id`, the instructions from a previous response
|
||||
* will not be carried over to the next response. This makes it simple to swap out
|
||||
* system (or developer) messages in new responses.
|
||||
*/
|
||||
instructions?: string | null;
|
||||
|
||||
/**
|
||||
* Model ID used to generate the response, like `gpt-4o` or `o3`. 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 | null;
|
||||
|
||||
/**
|
||||
* Whether to allow the model to run tool calls in parallel.
|
||||
*/
|
||||
parallel_tool_calls?: boolean | null;
|
||||
|
||||
/**
|
||||
* The unique ID of the previous response to the model. Use this to create
|
||||
* multi-turn conversations. Learn more about
|
||||
* [conversation state](https://platform.openai.com/docs/guides/conversation-state).
|
||||
* Cannot be used in conjunction with `conversation`.
|
||||
*/
|
||||
previous_response_id?: string | null;
|
||||
|
||||
/**
|
||||
* **gpt-5 and o-series models only** Configuration options for
|
||||
* [reasoning models](https://platform.openai.com/docs/guides/reasoning).
|
||||
*/
|
||||
reasoning?: Shared.Reasoning | null;
|
||||
|
||||
/**
|
||||
* Configuration options for a text response from the model. Can be plain text or
|
||||
* structured JSON data. Learn more:
|
||||
*
|
||||
* - [Text inputs and outputs](https://platform.openai.com/docs/guides/text)
|
||||
* - [Structured Outputs](https://platform.openai.com/docs/guides/structured-outputs)
|
||||
*/
|
||||
text?: InputTokenCountParams.Text | null;
|
||||
|
||||
/**
|
||||
* How the model should select which tool (or tools) to use when generating a
|
||||
* response. See the `tools` parameter to see how to specify which tools the model
|
||||
* can call.
|
||||
*/
|
||||
tool_choice?:
|
||||
| ResponsesAPI.ToolChoiceOptions
|
||||
| ResponsesAPI.ToolChoiceAllowed
|
||||
| ResponsesAPI.ToolChoiceTypes
|
||||
| ResponsesAPI.ToolChoiceFunction
|
||||
| ResponsesAPI.ToolChoiceMcp
|
||||
| ResponsesAPI.ToolChoiceCustom
|
||||
| ResponsesAPI.ToolChoiceApplyPatch
|
||||
| ResponsesAPI.ToolChoiceShell
|
||||
| null;
|
||||
|
||||
/**
|
||||
* An array of tools the model may call while generating a response. You can
|
||||
* specify which tool to use by setting the `tool_choice` parameter.
|
||||
*/
|
||||
tools?: Array<ResponsesAPI.Tool> | null;
|
||||
|
||||
/**
|
||||
* The truncation strategy to use for the model response. - `auto`: If the input to
|
||||
* this Response exceeds the model's context window size, the model will truncate
|
||||
* the response to fit the context window by dropping items from the beginning of
|
||||
* the conversation. - `disabled` (default): If the input size will exceed the
|
||||
* context window size for a model, the request will fail with a 400 error.
|
||||
*/
|
||||
truncation?: 'auto' | 'disabled';
|
||||
}
|
||||
|
||||
export namespace InputTokenCountParams {
|
||||
/**
|
||||
* Configuration options for a text response from the model. Can be plain text or
|
||||
* structured JSON data. Learn more:
|
||||
*
|
||||
* - [Text inputs and outputs](https://platform.openai.com/docs/guides/text)
|
||||
* - [Structured Outputs](https://platform.openai.com/docs/guides/structured-outputs)
|
||||
*/
|
||||
export interface Text {
|
||||
/**
|
||||
* An object specifying the format that the model must output.
|
||||
*
|
||||
* Configuring `{ "type": "json_schema" }` enables Structured Outputs, which
|
||||
* ensures the model will match your supplied JSON schema. Learn more in the
|
||||
* [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).
|
||||
*
|
||||
* The default format is `{ "type": "text" }` with no additional options.
|
||||
*
|
||||
* **Not recommended for gpt-4o and newer models:**
|
||||
*
|
||||
* Setting to `{ "type": "json_object" }` enables the older JSON mode, which
|
||||
* ensures the message the model generates is valid JSON. Using `json_schema` is
|
||||
* preferred for models that support it.
|
||||
*/
|
||||
format?: ResponsesAPI.ResponseFormatTextConfig;
|
||||
|
||||
/**
|
||||
* Constrains the verbosity of the model's response. Lower values will result in
|
||||
* more concise responses, while higher values will result in more verbose
|
||||
* responses. Currently supported values are `low`, `medium`, and `high`.
|
||||
*/
|
||||
verbosity?: 'low' | 'medium' | 'high' | null;
|
||||
}
|
||||
}
|
||||
|
||||
export declare namespace InputTokens {
|
||||
export {
|
||||
type InputTokenCountResponse as InputTokenCountResponse,
|
||||
type InputTokenCountParams as InputTokenCountParams,
|
||||
};
|
||||
}
|
||||
1105
node_modules/openai/src/resources/responses/responses.ts
generated
vendored
1105
node_modules/openai/src/resources/responses/responses.ts
generated
vendored
File diff suppressed because it is too large
Load Diff
52
node_modules/openai/src/resources/shared.ts
generated
vendored
52
node_modules/openai/src/resources/shared.ts
generated
vendored
@@ -12,9 +12,17 @@ export type AllModels =
|
||||
| 'o4-mini-deep-research'
|
||||
| 'o4-mini-deep-research-2025-06-26'
|
||||
| 'computer-use-preview'
|
||||
| 'computer-use-preview-2025-03-11';
|
||||
| 'computer-use-preview-2025-03-11'
|
||||
| 'gpt-5-codex'
|
||||
| 'gpt-5-pro'
|
||||
| 'gpt-5-pro-2025-10-06';
|
||||
|
||||
export type ChatModel =
|
||||
| 'gpt-5.1'
|
||||
| 'gpt-5.1-2025-11-13'
|
||||
| 'gpt-5.1-codex'
|
||||
| 'gpt-5.1-mini'
|
||||
| 'gpt-5.1-chat-latest'
|
||||
| 'gpt-5'
|
||||
| 'gpt-5-mini'
|
||||
| 'gpt-5-nano'
|
||||
@@ -89,7 +97,8 @@ export interface ComparisonFilter {
|
||||
key: string;
|
||||
|
||||
/**
|
||||
* Specifies the comparison operator: `eq`, `ne`, `gt`, `gte`, `lt`, `lte`.
|
||||
* Specifies the comparison operator: `eq`, `ne`, `gt`, `gte`, `lt`, `lte`, `in`,
|
||||
* `nin`.
|
||||
*
|
||||
* - `eq`: equals
|
||||
* - `ne`: not equal
|
||||
@@ -97,6 +106,8 @@ export interface ComparisonFilter {
|
||||
* - `gte`: greater than or equal
|
||||
* - `lt`: less than
|
||||
* - `lte`: less than or equal
|
||||
* - `in`: in
|
||||
* - `nin`: not in
|
||||
*/
|
||||
type: 'eq' | 'ne' | 'gt' | 'gte' | 'lt' | 'lte';
|
||||
|
||||
@@ -104,7 +115,7 @@ export interface ComparisonFilter {
|
||||
* The value to compare against the attribute key; supports string, number, or
|
||||
* boolean types.
|
||||
*/
|
||||
value: string | number | boolean;
|
||||
value: string | number | boolean | Array<string | number>;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -235,9 +246,16 @@ export interface Reasoning {
|
||||
/**
|
||||
* Constrains effort on reasoning for
|
||||
* [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently
|
||||
* supported values are `minimal`, `low`, `medium`, and `high`. Reducing reasoning
|
||||
* effort can result in faster responses and fewer tokens used on reasoning in a
|
||||
* response.
|
||||
* supported values are `none`, `minimal`, `low`, `medium`, and `high`. Reducing
|
||||
* reasoning effort can result in faster responses and fewer tokens used on
|
||||
* reasoning in a response.
|
||||
*
|
||||
* - `gpt-5.1` defaults to `none`, which does not perform reasoning. The supported
|
||||
* reasoning values for `gpt-5.1` are `none`, `low`, `medium`, and `high`. Tool
|
||||
* calls are supported for all reasoning values in gpt-5.1.
|
||||
* - All models before `gpt-5.1` default to `medium` reasoning effort, and do not
|
||||
* support `none`.
|
||||
* - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort.
|
||||
*/
|
||||
effort?: ReasoningEffort | null;
|
||||
|
||||
@@ -254,6 +272,8 @@ export interface Reasoning {
|
||||
* A summary of the reasoning performed by the model. This can be useful for
|
||||
* debugging and understanding the model's reasoning process. One of `auto`,
|
||||
* `concise`, or `detailed`.
|
||||
*
|
||||
* `concise` is only supported for `computer-use-preview` models.
|
||||
*/
|
||||
summary?: 'auto' | 'concise' | 'detailed' | null;
|
||||
}
|
||||
@@ -261,11 +281,18 @@ export interface Reasoning {
|
||||
/**
|
||||
* Constrains effort on reasoning for
|
||||
* [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently
|
||||
* supported values are `minimal`, `low`, `medium`, and `high`. Reducing reasoning
|
||||
* effort can result in faster responses and fewer tokens used on reasoning in a
|
||||
* response.
|
||||
* supported values are `none`, `minimal`, `low`, `medium`, and `high`. Reducing
|
||||
* reasoning effort can result in faster responses and fewer tokens used on
|
||||
* reasoning in a response.
|
||||
*
|
||||
* - `gpt-5.1` defaults to `none`, which does not perform reasoning. The supported
|
||||
* reasoning values for `gpt-5.1` are `none`, `low`, `medium`, and `high`. Tool
|
||||
* calls are supported for all reasoning values in gpt-5.1.
|
||||
* - All models before `gpt-5.1` default to `medium` reasoning effort, and do not
|
||||
* support `none`.
|
||||
* - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort.
|
||||
*/
|
||||
export type ReasoningEffort = 'minimal' | 'low' | 'medium' | 'high' | null;
|
||||
export type ReasoningEffort = 'none' | 'minimal' | 'low' | 'medium' | 'high' | null;
|
||||
|
||||
/**
|
||||
* JSON object response format. An older method of generating JSON responses. Using
|
||||
@@ -380,4 +407,7 @@ export type ResponsesModel =
|
||||
| 'o4-mini-deep-research'
|
||||
| 'o4-mini-deep-research-2025-06-26'
|
||||
| 'computer-use-preview'
|
||||
| 'computer-use-preview-2025-03-11';
|
||||
| 'computer-use-preview-2025-03-11'
|
||||
| 'gpt-5-codex'
|
||||
| 'gpt-5-pro'
|
||||
| 'gpt-5-pro-2025-10-06';
|
||||
|
||||
49
node_modules/openai/src/resources/vector-stores/file-batches.ts
generated
vendored
49
node_modules/openai/src/resources/vector-stores/file-batches.ts
generated
vendored
@@ -255,13 +255,6 @@ export namespace VectorStoreFileBatch {
|
||||
}
|
||||
|
||||
export interface FileBatchCreateParams {
|
||||
/**
|
||||
* A list of [File](https://platform.openai.com/docs/api-reference/files) IDs that
|
||||
* the vector store should use. Useful for tools like `file_search` that can access
|
||||
* files.
|
||||
*/
|
||||
file_ids: Array<string>;
|
||||
|
||||
/**
|
||||
* Set of 16 key-value pairs that can be attached to an object. This can be useful
|
||||
* for storing additional information about the object in a structured format, and
|
||||
@@ -276,6 +269,48 @@ export interface FileBatchCreateParams {
|
||||
* strategy. Only applicable if `file_ids` is non-empty.
|
||||
*/
|
||||
chunking_strategy?: VectorStoresAPI.FileChunkingStrategyParam;
|
||||
|
||||
/**
|
||||
* A list of [File](https://platform.openai.com/docs/api-reference/files) IDs that
|
||||
* the vector store should use. Useful for tools like `file_search` that can access
|
||||
* files. If `attributes` or `chunking_strategy` are provided, they will be applied
|
||||
* to all files in the batch. Mutually exclusive with `files`.
|
||||
*/
|
||||
file_ids?: Array<string>;
|
||||
|
||||
/**
|
||||
* A list of objects that each include a `file_id` plus optional `attributes` or
|
||||
* `chunking_strategy`. Use this when you need to override metadata for specific
|
||||
* files. The global `attributes` or `chunking_strategy` will be ignored and must
|
||||
* be specified for each file. Mutually exclusive with `file_ids`.
|
||||
*/
|
||||
files?: Array<FileBatchCreateParams.File>;
|
||||
}
|
||||
|
||||
export namespace FileBatchCreateParams {
|
||||
export interface File {
|
||||
/**
|
||||
* A [File](https://platform.openai.com/docs/api-reference/files) ID that the
|
||||
* vector store should use. Useful for tools like `file_search` that can access
|
||||
* files.
|
||||
*/
|
||||
file_id: string;
|
||||
|
||||
/**
|
||||
* Set of 16 key-value pairs that can be attached to an object. This can be useful
|
||||
* for storing additional information about the object in a structured format, and
|
||||
* querying for objects via API or the dashboard. Keys are strings with a maximum
|
||||
* length of 64 characters. Values are strings with a maximum length of 512
|
||||
* characters, booleans, or numbers.
|
||||
*/
|
||||
attributes?: { [key: string]: string | number | boolean } | null;
|
||||
|
||||
/**
|
||||
* The chunking strategy used to chunk the file(s). If not set, will use the `auto`
|
||||
* strategy. Only applicable if `file_ids` is non-empty.
|
||||
*/
|
||||
chunking_strategy?: VectorStoresAPI.FileChunkingStrategyParam;
|
||||
}
|
||||
}
|
||||
|
||||
export interface FileBatchRetrieveParams {
|
||||
|
||||
2
node_modules/openai/src/resources/vector-stores/files.ts
generated
vendored
2
node_modules/openai/src/resources/vector-stores/files.ts
generated
vendored
@@ -264,7 +264,7 @@ export namespace VectorStoreFile {
|
||||
*/
|
||||
export interface LastError {
|
||||
/**
|
||||
* One of `server_error` or `rate_limit_exceeded`.
|
||||
* One of `server_error`, `unsupported_file`, or `invalid_file`.
|
||||
*/
|
||||
code: 'server_error' | 'unsupported_file' | 'invalid_file';
|
||||
|
||||
|
||||
6
node_modules/openai/src/resources/vector-stores/vector-stores.ts
generated
vendored
6
node_modules/openai/src/resources/vector-stores/vector-stores.ts
generated
vendored
@@ -363,6 +363,12 @@ export interface VectorStoreCreateParams {
|
||||
*/
|
||||
chunking_strategy?: FileChunkingStrategyParam;
|
||||
|
||||
/**
|
||||
* A description for the vector store. Can be used to describe the vector store's
|
||||
* purpose.
|
||||
*/
|
||||
description?: string;
|
||||
|
||||
/**
|
||||
* The expiration policy for a vector store.
|
||||
*/
|
||||
|
||||
238
node_modules/openai/src/resources/videos.ts
generated
vendored
Normal file
238
node_modules/openai/src/resources/videos.ts
generated
vendored
Normal file
@@ -0,0 +1,238 @@
|
||||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
import { APIResource } from '../core/resource';
|
||||
import { APIPromise } from '../core/api-promise';
|
||||
import { ConversationCursorPage, type ConversationCursorPageParams, PagePromise } from '../core/pagination';
|
||||
import { type Uploadable } from '../core/uploads';
|
||||
import { buildHeaders } from '../internal/headers';
|
||||
import { RequestOptions } from '../internal/request-options';
|
||||
import { maybeMultipartFormRequestOptions } from '../internal/uploads';
|
||||
import { path } from '../internal/utils/path';
|
||||
|
||||
export class Videos extends APIResource {
|
||||
/**
|
||||
* Create a video
|
||||
*/
|
||||
create(body: VideoCreateParams, options?: RequestOptions): APIPromise<Video> {
|
||||
return this._client.post('/videos', maybeMultipartFormRequestOptions({ body, ...options }, this._client));
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a video
|
||||
*/
|
||||
retrieve(videoID: string, options?: RequestOptions): APIPromise<Video> {
|
||||
return this._client.get(path`/videos/${videoID}`, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* List videos
|
||||
*/
|
||||
list(
|
||||
query: VideoListParams | null | undefined = {},
|
||||
options?: RequestOptions,
|
||||
): PagePromise<VideosPage, Video> {
|
||||
return this._client.getAPIList('/videos', ConversationCursorPage<Video>, { query, ...options });
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a video
|
||||
*/
|
||||
delete(videoID: string, options?: RequestOptions): APIPromise<VideoDeleteResponse> {
|
||||
return this._client.delete(path`/videos/${videoID}`, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Download video content
|
||||
*/
|
||||
downloadContent(
|
||||
videoID: string,
|
||||
query: VideoDownloadContentParams | null | undefined = {},
|
||||
options?: RequestOptions,
|
||||
): APIPromise<Response> {
|
||||
return this._client.get(path`/videos/${videoID}/content`, {
|
||||
query,
|
||||
...options,
|
||||
headers: buildHeaders([{ Accept: 'application/binary' }, options?.headers]),
|
||||
__binaryResponse: true,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a video remix
|
||||
*/
|
||||
remix(videoID: string, body: VideoRemixParams, options?: RequestOptions): APIPromise<Video> {
|
||||
return this._client.post(
|
||||
path`/videos/${videoID}/remix`,
|
||||
maybeMultipartFormRequestOptions({ body, ...options }, this._client),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export type VideosPage = ConversationCursorPage<Video>;
|
||||
|
||||
/**
|
||||
* Structured information describing a generated video job.
|
||||
*/
|
||||
export interface Video {
|
||||
/**
|
||||
* Unique identifier for the video job.
|
||||
*/
|
||||
id: string;
|
||||
|
||||
/**
|
||||
* Unix timestamp (seconds) for when the job completed, if finished.
|
||||
*/
|
||||
completed_at: number | null;
|
||||
|
||||
/**
|
||||
* Unix timestamp (seconds) for when the job was created.
|
||||
*/
|
||||
created_at: number;
|
||||
|
||||
/**
|
||||
* Error payload that explains why generation failed, if applicable.
|
||||
*/
|
||||
error: VideoCreateError | null;
|
||||
|
||||
/**
|
||||
* Unix timestamp (seconds) for when the downloadable assets expire, if set.
|
||||
*/
|
||||
expires_at: number | null;
|
||||
|
||||
/**
|
||||
* The video generation model that produced the job.
|
||||
*/
|
||||
model: VideoModel;
|
||||
|
||||
/**
|
||||
* The object type, which is always `video`.
|
||||
*/
|
||||
object: 'video';
|
||||
|
||||
/**
|
||||
* Approximate completion percentage for the generation task.
|
||||
*/
|
||||
progress: number;
|
||||
|
||||
/**
|
||||
* The prompt that was used to generate the video.
|
||||
*/
|
||||
prompt: string | null;
|
||||
|
||||
/**
|
||||
* Identifier of the source video if this video is a remix.
|
||||
*/
|
||||
remixed_from_video_id: string | null;
|
||||
|
||||
/**
|
||||
* Duration of the generated clip in seconds.
|
||||
*/
|
||||
seconds: VideoSeconds;
|
||||
|
||||
/**
|
||||
* The resolution of the generated video.
|
||||
*/
|
||||
size: VideoSize;
|
||||
|
||||
/**
|
||||
* Current lifecycle status of the video job.
|
||||
*/
|
||||
status: 'queued' | 'in_progress' | 'completed' | 'failed';
|
||||
}
|
||||
|
||||
export interface VideoCreateError {
|
||||
code: string;
|
||||
|
||||
message: string;
|
||||
}
|
||||
|
||||
export type VideoModel = 'sora-2' | 'sora-2-pro';
|
||||
|
||||
export type VideoSeconds = '4' | '8' | '12';
|
||||
|
||||
export type VideoSize = '720x1280' | '1280x720' | '1024x1792' | '1792x1024';
|
||||
|
||||
/**
|
||||
* Confirmation payload returned after deleting a video.
|
||||
*/
|
||||
export interface VideoDeleteResponse {
|
||||
/**
|
||||
* Identifier of the deleted video.
|
||||
*/
|
||||
id: string;
|
||||
|
||||
/**
|
||||
* Indicates that the video resource was deleted.
|
||||
*/
|
||||
deleted: boolean;
|
||||
|
||||
/**
|
||||
* The object type that signals the deletion response.
|
||||
*/
|
||||
object: 'video.deleted';
|
||||
}
|
||||
|
||||
export interface VideoCreateParams {
|
||||
/**
|
||||
* Text prompt that describes the video to generate.
|
||||
*/
|
||||
prompt: string;
|
||||
|
||||
/**
|
||||
* Optional image reference that guides generation.
|
||||
*/
|
||||
input_reference?: Uploadable;
|
||||
|
||||
/**
|
||||
* The video generation model to use. Defaults to `sora-2`.
|
||||
*/
|
||||
model?: VideoModel;
|
||||
|
||||
/**
|
||||
* Clip duration in seconds. Defaults to 4 seconds.
|
||||
*/
|
||||
seconds?: VideoSeconds;
|
||||
|
||||
/**
|
||||
* Output resolution formatted as width x height. Defaults to 720x1280.
|
||||
*/
|
||||
size?: VideoSize;
|
||||
}
|
||||
|
||||
export interface VideoListParams extends ConversationCursorPageParams {
|
||||
/**
|
||||
* Sort order of results by timestamp. Use `asc` for ascending order or `desc` for
|
||||
* descending order.
|
||||
*/
|
||||
order?: 'asc' | 'desc';
|
||||
}
|
||||
|
||||
export interface VideoDownloadContentParams {
|
||||
/**
|
||||
* Which downloadable asset to return. Defaults to the MP4 video.
|
||||
*/
|
||||
variant?: 'video' | 'thumbnail' | 'spritesheet';
|
||||
}
|
||||
|
||||
export interface VideoRemixParams {
|
||||
/**
|
||||
* Updated text prompt that directs the remix generation.
|
||||
*/
|
||||
prompt: string;
|
||||
}
|
||||
|
||||
export declare namespace Videos {
|
||||
export {
|
||||
type Video as Video,
|
||||
type VideoCreateError as VideoCreateError,
|
||||
type VideoModel as VideoModel,
|
||||
type VideoSeconds as VideoSeconds,
|
||||
type VideoSize as VideoSize,
|
||||
type VideoDeleteResponse as VideoDeleteResponse,
|
||||
type VideosPage as VideosPage,
|
||||
type VideoCreateParams as VideoCreateParams,
|
||||
type VideoListParams as VideoListParams,
|
||||
type VideoDownloadContentParams as VideoDownloadContentParams,
|
||||
type VideoRemixParams as VideoRemixParams,
|
||||
};
|
||||
}
|
||||
66
node_modules/openai/src/resources/webhooks.ts
generated
vendored
66
node_modules/openai/src/resources/webhooks.ts
generated
vendored
@@ -559,6 +559,70 @@ export namespace FineTuningJobSucceededWebhookEvent {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sent when Realtime API Receives a incoming SIP call.
|
||||
*/
|
||||
export interface RealtimeCallIncomingWebhookEvent {
|
||||
/**
|
||||
* The unique ID of the event.
|
||||
*/
|
||||
id: string;
|
||||
|
||||
/**
|
||||
* The Unix timestamp (in seconds) of when the model response was completed.
|
||||
*/
|
||||
created_at: number;
|
||||
|
||||
/**
|
||||
* Event data payload.
|
||||
*/
|
||||
data: RealtimeCallIncomingWebhookEvent.Data;
|
||||
|
||||
/**
|
||||
* The type of the event. Always `realtime.call.incoming`.
|
||||
*/
|
||||
type: 'realtime.call.incoming';
|
||||
|
||||
/**
|
||||
* The object of the event. Always `event`.
|
||||
*/
|
||||
object?: 'event';
|
||||
}
|
||||
|
||||
export namespace RealtimeCallIncomingWebhookEvent {
|
||||
/**
|
||||
* Event data payload.
|
||||
*/
|
||||
export interface Data {
|
||||
/**
|
||||
* The unique ID of this call.
|
||||
*/
|
||||
call_id: string;
|
||||
|
||||
/**
|
||||
* Headers from the SIP Invite.
|
||||
*/
|
||||
sip_headers: Array<Data.SipHeader>;
|
||||
}
|
||||
|
||||
export namespace Data {
|
||||
/**
|
||||
* A header from the SIP Invite.
|
||||
*/
|
||||
export interface SipHeader {
|
||||
/**
|
||||
* Name of the SIP Header.
|
||||
*/
|
||||
name: string;
|
||||
|
||||
/**
|
||||
* Value of the SIP Header.
|
||||
*/
|
||||
value: string;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sent when a background response has been cancelled.
|
||||
*/
|
||||
@@ -741,6 +805,7 @@ export type UnwrapWebhookEvent =
|
||||
| FineTuningJobCancelledWebhookEvent
|
||||
| FineTuningJobFailedWebhookEvent
|
||||
| FineTuningJobSucceededWebhookEvent
|
||||
| RealtimeCallIncomingWebhookEvent
|
||||
| ResponseCancelledWebhookEvent
|
||||
| ResponseCompletedWebhookEvent
|
||||
| ResponseFailedWebhookEvent
|
||||
@@ -758,6 +823,7 @@ export declare namespace Webhooks {
|
||||
type FineTuningJobCancelledWebhookEvent as FineTuningJobCancelledWebhookEvent,
|
||||
type FineTuningJobFailedWebhookEvent as FineTuningJobFailedWebhookEvent,
|
||||
type FineTuningJobSucceededWebhookEvent as FineTuningJobSucceededWebhookEvent,
|
||||
type RealtimeCallIncomingWebhookEvent as RealtimeCallIncomingWebhookEvent,
|
||||
type ResponseCancelledWebhookEvent as ResponseCancelledWebhookEvent,
|
||||
type ResponseCompletedWebhookEvent as ResponseCompletedWebhookEvent,
|
||||
type ResponseFailedWebhookEvent as ResponseFailedWebhookEvent,
|
||||
|
||||
2
node_modules/openai/src/version.ts
generated
vendored
2
node_modules/openai/src/version.ts
generated
vendored
@@ -1 +1 @@
|
||||
export const VERSION = '5.16.0'; // x-release-please-version
|
||||
export const VERSION = '6.9.1'; // x-release-please-version
|
||||
|
||||
Reference in New Issue
Block a user