🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

@ai-sdk/openai

Package Overview
Dependencies
Maintainers
3
Versions
579
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ai-sdk/openai - npm Package Compare versions

Comparing version
4.0.0-beta.44
to
4.0.0-beta.74
+181
src/openai-stream-error.ts
import { APICallError } from '@ai-sdk/provider';
import type { ParseResult } from '@ai-sdk/provider-utils';
type StreamError = {
message: string;
code?: string | number | null;
type?: string | null;
frame: unknown;
};
export async function throwIfOpenAIStreamErrorBeforeOutput<T>({
stream,
getError,
isOutputChunk,
url,
requestBodyValues,
responseHeaders,
}: {
stream: ReadableStream<ParseResult<T>>;
getError: (chunk: T) => unknown | undefined;
isOutputChunk: (chunk: T) => boolean;
url: string;
requestBodyValues: unknown;
responseHeaders?: Record<string, string>;
}): Promise<ReadableStream<ParseResult<T>>> {
const [streamForEarlyError, streamForConsumer] = stream.tee();
const reader = streamForEarlyError.getReader();
try {
while (true) {
const result = await reader.read();
if (result.done) {
return streamForConsumer;
}
const chunk = result.value;
if (!chunk.success) {
return streamForConsumer;
}
const errorFrame = getError(chunk.value);
if (errorFrame != null) {
streamForConsumer.cancel().catch(() => {});
throw createOpenAIStreamError({
frame: errorFrame,
url,
requestBodyValues,
responseHeaders,
});
}
if (isOutputChunk(chunk.value)) {
return streamForConsumer;
}
}
} finally {
reader.cancel().catch(() => {});
reader.releaseLock();
}
}
function createOpenAIStreamError({
frame,
url,
requestBodyValues,
responseHeaders,
}: {
frame: unknown;
url: string;
requestBodyValues: unknown;
responseHeaders?: Record<string, string>;
}): APICallError {
const streamError = parseStreamError(frame);
return new APICallError({
message:
streamError?.message ??
'OpenAI stream failed before any output was generated',
url,
requestBodyValues,
statusCode: streamError == null ? 500 : getStatusCode(streamError),
responseHeaders,
responseBody: JSON.stringify(frame),
data: frame,
});
}
function parseStreamError(frame: unknown): StreamError | undefined {
const value = asRecord(frame);
if (value == null) {
return undefined;
}
if (value.type === 'response.failed') {
const response = asRecord(value.response);
const responseError = asRecord(response?.error);
return typeof responseError?.message === 'string'
? {
message: responseError.message,
code: getStringOrNumber(responseError.code),
type: 'response.failed',
frame,
}
: undefined;
}
const error = asRecord(value.error) ?? value;
return typeof error.message === 'string' &&
(asRecord(value.error) != null ||
typeof error.type === 'string' ||
'code' in error ||
'param' in error)
? {
message: error.message,
code: getStringOrNumber(error.code),
type: typeof error.type === 'string' ? error.type : undefined,
frame,
}
: undefined;
}
function getStatusCode(error: StreamError): number {
if (typeof error.code === 'number' && isHttpErrorStatusCode(error.code)) {
return error.code;
}
if (typeof error.code === 'string' && /^\d{3}$/.test(error.code)) {
const numericCode = Number(error.code);
if (isHttpErrorStatusCode(numericCode)) {
return numericCode;
}
}
const discriminator = [error.code, error.type]
.filter(value => typeof value === 'string' || typeof value === 'number')
.join(' ')
.toLowerCase();
if (
['insufficient_quota', 'rate_limit'].some(term =>
discriminator.includes(term),
)
) {
return 429;
}
if (discriminator.includes('authentication')) return 401;
if (discriminator.includes('permission')) return 403;
if (discriminator.includes('not_found')) return 404;
if (
['invalid', 'bad_request', 'context_length'].some(term =>
discriminator.includes(term),
)
) {
return 400;
}
if (discriminator.includes('overload')) return 503;
if (discriminator.includes('timeout')) return 504;
return 500;
}
function asRecord(value: unknown): Record<string, unknown> | undefined {
return typeof value === 'object' && value != null
? (value as Record<string, unknown>)
: undefined;
}
function getStringOrNumber(value: unknown): string | number | undefined {
return typeof value === 'string' || typeof value === 'number'
? value
: undefined;
}
function isHttpErrorStatusCode(value: number): boolean {
return Number.isInteger(value) && value >= 400 && value <= 599;
}
export { OpenAIRealtimeModel as Experimental_OpenAIRealtimeModel } from './openai-realtime-model';
export type { OpenAIRealtimeModelConfig as Experimental_OpenAIRealtimeModelConfig } from './openai-realtime-model';
import type {
Experimental_RealtimeModelV4ClientEvent as RealtimeModelV4ClientEvent,
Experimental_RealtimeModelV4ServerEvent as RealtimeModelV4ServerEvent,
Experimental_RealtimeModelV4SessionConfig as RealtimeModelV4SessionConfig,
} from '@ai-sdk/provider';
type OpenAIRealtimeWireEvent = {
type: string;
session?: { id?: string };
item?: { id?: string } & Record<string, unknown>;
response?: { id?: string; status?: string };
error?: { message?: string; code?: string };
item_id: string;
previous_item_id?: string;
response_id: string;
transcript?: string;
delta: string;
text?: string;
call_id: string;
name: string;
arguments: string;
message?: string;
code?: string;
};
/**
* Parses a raw OpenAI Realtime API server event into a normalized event.
*/
export function parseOpenAIRealtimeServerEvent(
raw: unknown,
): RealtimeModelV4ServerEvent {
const event = raw as OpenAIRealtimeWireEvent;
const type = event.type;
switch (type) {
// ── Session lifecycle ──────────────────────────────────────────
case 'session.created':
return {
type: 'session-created',
sessionId: event.session?.id,
raw,
};
case 'session.updated':
return { type: 'session-updated', raw };
// ── Input audio buffer ─────────────────────────────────────────
case 'input_audio_buffer.speech_started':
return {
type: 'speech-started',
itemId: event.item_id,
raw,
};
case 'input_audio_buffer.speech_stopped':
return {
type: 'speech-stopped',
itemId: event.item_id,
raw,
};
case 'input_audio_buffer.committed':
return {
type: 'audio-committed',
itemId: event.item_id,
previousItemId: event.previous_item_id,
raw,
};
// ── Conversation items ─────────────────────────────────────────
case 'conversation.item.added':
return {
type: 'conversation-item-added',
itemId: event.item?.id ?? event.item_id,
item: event.item,
raw,
};
case 'conversation.item.input_audio_transcription.completed':
return {
type: 'input-transcription-completed',
itemId: event.item_id,
transcript: event.transcript ?? '',
raw,
};
// ── Response lifecycle ──────────────────────────────────────────
case 'response.created':
return {
type: 'response-created',
responseId: event.response?.id ?? event.response_id,
raw,
};
case 'response.done':
return {
type: 'response-done',
responseId: event.response?.id ?? event.response_id,
status: event.response?.status ?? 'completed',
raw,
};
// ── Output item lifecycle ───────────────────────────────────────
case 'response.output_item.added':
return {
type: 'output-item-added',
responseId: event.response_id,
itemId: event.item?.id ?? event.item_id,
raw,
};
case 'response.output_item.done':
return {
type: 'output-item-done',
responseId: event.response_id,
itemId: event.item?.id ?? event.item_id,
raw,
};
case 'response.content_part.added':
return {
type: 'content-part-added',
responseId: event.response_id,
itemId: event.item_id,
raw,
};
case 'response.content_part.done':
return {
type: 'content-part-done',
responseId: event.response_id,
itemId: event.item_id,
raw,
};
// ── Audio output ────────────────────────────────────────────────
case 'response.output_audio.delta':
return {
type: 'audio-delta',
responseId: event.response_id,
itemId: event.item_id,
delta: event.delta,
raw,
};
case 'response.output_audio.done':
return {
type: 'audio-done',
responseId: event.response_id,
itemId: event.item_id,
raw,
};
// ── Audio transcript output ─────────────────────────────────────
case 'response.output_audio_transcript.delta':
return {
type: 'audio-transcript-delta',
responseId: event.response_id,
itemId: event.item_id,
delta: event.delta,
raw,
};
case 'response.output_audio_transcript.done':
return {
type: 'audio-transcript-done',
responseId: event.response_id,
itemId: event.item_id,
transcript: event.transcript,
raw,
};
// ── Text output ─────────────────────────────────────────────────
case 'response.output_text.delta':
return {
type: 'text-delta',
responseId: event.response_id,
itemId: event.item_id,
delta: event.delta,
raw,
};
case 'response.output_text.done':
return {
type: 'text-done',
responseId: event.response_id,
itemId: event.item_id,
text: event.text,
raw,
};
// ── Function calling ────────────────────────────────────────────
case 'response.function_call_arguments.delta':
return {
type: 'function-call-arguments-delta',
responseId: event.response_id,
itemId: event.item_id,
callId: event.call_id,
delta: event.delta,
raw,
};
case 'response.function_call_arguments.done':
return {
type: 'function-call-arguments-done',
responseId: event.response_id,
itemId: event.item_id,
callId: event.call_id,
name: event.name,
arguments: event.arguments,
raw,
};
// ── Error ───────────────────────────────────────────────────────
case 'error':
return {
type: 'error',
message: event.error?.message ?? event.message ?? 'Unknown error',
code: event.error?.code ?? event.code,
raw,
};
// ── Pass-through ────────────────────────────────────────────────
default:
return { type: 'custom', rawType: type, raw };
}
}
/**
* Serializes a normalized client event into OpenAI's Realtime API format.
*/
export function serializeOpenAIRealtimeClientEvent(
event: RealtimeModelV4ClientEvent,
modelId: string,
): unknown {
switch (event.type) {
case 'session-update':
return {
type: 'session.update',
session: buildOpenAISessionConfig(event.config, modelId),
};
case 'input-audio-append':
return {
type: 'input_audio_buffer.append',
audio: event.audio,
};
case 'input-audio-commit':
return { type: 'input_audio_buffer.commit' };
case 'input-audio-clear':
return { type: 'input_audio_buffer.clear' };
case 'conversation-item-create': {
const item = event.item;
switch (item.type) {
case 'text-message':
return {
type: 'conversation.item.create',
item: {
type: 'message',
role: item.role,
content: [{ type: 'input_text', text: item.text }],
},
};
case 'audio-message':
return {
type: 'conversation.item.create',
item: {
type: 'message',
role: item.role,
content: [{ type: 'input_audio', audio: item.audio }],
},
};
case 'function-call-output':
return {
type: 'conversation.item.create',
item: {
type: 'function_call_output',
call_id: item.callId,
output: item.output,
},
};
}
break;
}
case 'conversation-item-truncate':
return {
type: 'conversation.item.truncate',
item_id: event.itemId,
content_index: event.contentIndex,
audio_end_ms: event.audioEndMs,
};
case 'response-create':
return {
type: 'response.create',
...(event.options != null
? {
response: {
...(event.options.modalities != null
? { output_modalities: event.options.modalities }
: {}),
...(event.options.instructions != null
? { instructions: event.options.instructions }
: {}),
...(event.options.metadata != null
? { metadata: event.options.metadata }
: {}),
},
}
: {}),
};
case 'response-cancel':
return { type: 'response.cancel' };
}
}
/**
* Builds an OpenAI-specific session configuration from a normalized config.
*/
export function buildOpenAISessionConfig(
config: RealtimeModelV4SessionConfig,
modelId: string,
): Record<string, unknown> {
const session: Record<string, unknown> = {
type: 'realtime',
model: modelId,
};
if (config.instructions != null) {
session.instructions = config.instructions;
}
if (config.outputModalities != null) {
session.output_modalities = config.outputModalities;
}
const audio: Record<string, unknown> = {};
if (
config.inputAudioFormat != null ||
config.inputAudioTranscription != null ||
config.turnDetection != null
) {
const input: Record<string, unknown> = {};
if (config.inputAudioFormat != null) {
input.format = {
type: config.inputAudioFormat.type,
...(config.inputAudioFormat.rate != null
? { rate: config.inputAudioFormat.rate }
: {}),
};
}
if (config.turnDetection != null) {
if (config.turnDetection.type === 'disabled') {
input.turn_detection = null;
} else {
const td: Record<string, unknown> = {
type:
config.turnDetection.type === 'server-vad'
? 'server_vad'
: 'semantic_vad',
};
if (config.turnDetection.threshold != null) {
td.threshold = config.turnDetection.threshold;
}
if (config.turnDetection.silenceDurationMs != null) {
td.silence_duration_ms = config.turnDetection.silenceDurationMs;
}
if (config.turnDetection.prefixPaddingMs != null) {
td.prefix_padding_ms = config.turnDetection.prefixPaddingMs;
}
input.turn_detection = td;
}
}
if (config.inputAudioTranscription != null) {
input.transcription = {
model: config.inputAudioTranscription.model ?? 'gpt-realtime-whisper',
...(config.inputAudioTranscription.language != null
? { language: config.inputAudioTranscription.language }
: {}),
...(config.inputAudioTranscription.prompt != null
? { prompt: config.inputAudioTranscription.prompt }
: {}),
};
}
audio.input = input;
}
if (config.outputAudioFormat != null || config.voice != null) {
const output: Record<string, unknown> = {};
if (config.outputAudioFormat != null) {
output.format = {
type: config.outputAudioFormat.type,
...(config.outputAudioFormat.rate != null
? { rate: config.outputAudioFormat.rate }
: {}),
};
}
if (config.voice != null) {
output.voice = config.voice;
}
audio.output = output;
}
if (Object.keys(audio).length > 0) {
session.audio = audio;
}
if (config.tools != null && config.tools.length > 0) {
session.tools = config.tools.map(tool => ({
type: tool.type,
name: tool.name,
description: tool.description,
parameters: tool.parameters,
}));
session.tool_choice = 'auto';
}
if (config.providerOptions != null) {
Object.assign(session, config.providerOptions);
}
return session;
}
export type OpenAIRealtimeModelId = string;
export type OpenAIRealtimeModelOptions = Record<string, never>;
import type {
Experimental_RealtimeModelV4 as RealtimeModelV4,
Experimental_RealtimeModelV4ClientEvent as RealtimeModelV4ClientEvent,
Experimental_RealtimeModelV4ClientSecretOptions as RealtimeModelV4ClientSecretOptions,
Experimental_RealtimeModelV4ClientSecretResult as RealtimeModelV4ClientSecretResult,
Experimental_RealtimeModelV4ServerEvent as RealtimeModelV4ServerEvent,
Experimental_RealtimeModelV4SessionConfig as RealtimeModelV4SessionConfig,
} from '@ai-sdk/provider';
import type { FetchFunction } from '@ai-sdk/provider-utils';
import {
buildOpenAISessionConfig,
parseOpenAIRealtimeServerEvent,
serializeOpenAIRealtimeClientEvent,
} from './openai-realtime-event-mapper';
export type OpenAIRealtimeModelConfig = {
provider: string;
baseURL: string;
headers: () => Record<string, string | undefined>;
fetch?: FetchFunction;
};
export class OpenAIRealtimeModel implements RealtimeModelV4 {
readonly specificationVersion = 'v4' as const;
readonly provider: string;
readonly modelId: string;
private readonly config: OpenAIRealtimeModelConfig;
constructor(modelId: string, config: OpenAIRealtimeModelConfig) {
this.modelId = modelId;
this.provider = config.provider;
this.config = config;
}
async doCreateClientSecret(
options: RealtimeModelV4ClientSecretOptions,
): Promise<RealtimeModelV4ClientSecretResult> {
const fetchFn = this.config.fetch ?? fetch;
const url = `${this.config.baseURL}/realtime/client_secrets`;
const session =
options.sessionConfig != null
? buildOpenAISessionConfig(options.sessionConfig, this.modelId)
: { type: 'realtime', model: this.modelId };
const response = await fetchFn(url, {
method: 'POST',
headers: {
...this.config.headers(),
'Content-Type': 'application/json',
},
body: JSON.stringify({
session,
...(options.expiresAfterSeconds != null
? {
// `anchor` is required by the client secrets endpoint; without it
// the request fails with "Missing required parameter:
// 'expires_after.anchor'".
expires_after: {
anchor: 'created_at',
seconds: options.expiresAfterSeconds,
},
}
: {}),
}),
});
if (!response.ok) {
const text = await response.text();
throw new Error(
`OpenAI realtime client secret request failed: ${response.status} ${text}`,
);
}
const data = (await response.json()) as {
value: string;
expires_at?: number;
};
return {
token: data.value,
url: `wss://${new URL(this.config.baseURL).host}/v1/realtime?model=${encodeURIComponent(this.modelId)}`,
expiresAt: data.expires_at,
};
}
getWebSocketConfig(options: { token: string; url: string }): {
url: string;
protocols?: string[];
} {
return {
url: options.url,
protocols: ['realtime', `openai-insecure-api-key.${options.token}`],
};
}
parseServerEvent(raw: unknown): RealtimeModelV4ServerEvent {
return parseOpenAIRealtimeServerEvent(raw);
}
serializeClientEvent(event: RealtimeModelV4ClientEvent): unknown {
return serializeOpenAIRealtimeClientEvent(event, this.modelId);
}
buildSessionConfig(
config: RealtimeModelV4SessionConfig,
): Record<string, unknown> {
return buildOpenAISessionConfig(config, this.modelId);
}
}
+63
-13
import * as _ai_sdk_provider from '@ai-sdk/provider';
import { JSONValue, ProviderV4, LanguageModelV4, EmbeddingModelV4, ImageModelV4, TranscriptionModelV4, SpeechModelV4, FilesV4, SkillsV4 } from '@ai-sdk/provider';
import { JSONValue, ProviderV4, LanguageModelV4, EmbeddingModelV4, ImageModelV4, TranscriptionModelV4, SpeechModelV4, Experimental_RealtimeFactoryV4, FilesV4, SkillsV4, Experimental_RealtimeModelV4, Experimental_RealtimeModelV4ClientSecretOptions, Experimental_RealtimeModelV4ClientSecretResult, Experimental_RealtimeModelV4ServerEvent, Experimental_RealtimeModelV4ClientEvent, Experimental_RealtimeModelV4SessionConfig } from '@ai-sdk/provider';
import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
import { InferSchema, FetchFunction } from '@ai-sdk/provider-utils';
type OpenAIChatModelId = 'o1' | 'o1-2024-12-17' | 'o3-mini' | 'o3-mini-2025-01-31' | 'o3' | 'o3-2025-04-16' | 'o4-mini' | 'o4-mini-2025-04-16' | 'gpt-4.1' | 'gpt-4.1-2025-04-14' | 'gpt-4.1-mini' | 'gpt-4.1-mini-2025-04-14' | 'gpt-4.1-nano' | 'gpt-4.1-nano-2025-04-14' | 'gpt-4o' | 'gpt-4o-2024-05-13' | 'gpt-4o-2024-08-06' | 'gpt-4o-2024-11-20' | 'gpt-4o-audio-preview' | 'gpt-4o-audio-preview-2024-12-17' | 'gpt-4o-audio-preview-2025-06-03' | 'gpt-4o-mini' | 'gpt-4o-mini-2024-07-18' | 'gpt-4o-mini-audio-preview' | 'gpt-4o-mini-audio-preview-2024-12-17' | 'gpt-4o-search-preview' | 'gpt-4o-search-preview-2025-03-11' | 'gpt-4o-mini-search-preview' | 'gpt-4o-mini-search-preview-2025-03-11' | 'gpt-3.5-turbo-0125' | 'gpt-3.5-turbo' | 'gpt-3.5-turbo-1106' | 'gpt-3.5-turbo-16k' | 'gpt-5' | 'gpt-5-2025-08-07' | 'gpt-5-mini' | 'gpt-5-mini-2025-08-07' | 'gpt-5-nano' | 'gpt-5-nano-2025-08-07' | 'gpt-5-chat-latest' | 'gpt-5.1' | 'gpt-5.1-2025-11-13' | 'gpt-5.1-chat-latest' | 'gpt-5.2' | 'gpt-5.2-2025-12-11' | 'gpt-5.2-chat-latest' | 'gpt-5.2-pro' | 'gpt-5.2-pro-2025-12-11' | 'gpt-5.3-chat-latest' | 'gpt-5.4' | 'gpt-5.4-2026-03-05' | 'gpt-5.4-mini' | 'gpt-5.4-mini-2026-03-17' | 'gpt-5.4-nano' | 'gpt-5.4-nano-2026-03-17' | 'gpt-5.4-pro' | 'gpt-5.4-pro-2026-03-05' | (string & {});
type OpenAIChatModelId = 'o1' | 'o1-2024-12-17' | 'o3-mini' | 'o3-mini-2025-01-31' | 'o3' | 'o3-2025-04-16' | 'o4-mini' | 'o4-mini-2025-04-16' | 'gpt-4.1' | 'gpt-4.1-2025-04-14' | 'gpt-4.1-mini' | 'gpt-4.1-mini-2025-04-14' | 'gpt-4.1-nano' | 'gpt-4.1-nano-2025-04-14' | 'gpt-4o' | 'gpt-4o-2024-05-13' | 'gpt-4o-2024-08-06' | 'gpt-4o-2024-11-20' | 'gpt-4o-audio-preview' | 'gpt-4o-audio-preview-2024-12-17' | 'gpt-4o-audio-preview-2025-06-03' | 'gpt-4o-mini' | 'gpt-4o-mini-2024-07-18' | 'gpt-4o-mini-audio-preview' | 'gpt-4o-mini-audio-preview-2024-12-17' | 'gpt-4o-search-preview' | 'gpt-4o-search-preview-2025-03-11' | 'gpt-4o-mini-search-preview' | 'gpt-4o-mini-search-preview-2025-03-11' | 'gpt-3.5-turbo-0125' | 'gpt-3.5-turbo' | 'gpt-3.5-turbo-1106' | 'gpt-3.5-turbo-16k' | 'gpt-5' | 'gpt-5-2025-08-07' | 'gpt-5-mini' | 'gpt-5-mini-2025-08-07' | 'gpt-5-nano' | 'gpt-5-nano-2025-08-07' | 'gpt-5-chat-latest' | 'gpt-5.1' | 'gpt-5.1-2025-11-13' | 'gpt-5.1-chat-latest' | 'gpt-5.2' | 'gpt-5.2-2025-12-11' | 'gpt-5.2-chat-latest' | 'gpt-5.2-pro' | 'gpt-5.2-pro-2025-12-11' | 'gpt-5.3-chat-latest' | 'gpt-5.4' | 'gpt-5.4-2026-03-05' | 'gpt-5.4-mini' | 'gpt-5.4-mini-2026-03-17' | 'gpt-5.4-nano' | 'gpt-5.4-nano-2026-03-17' | 'gpt-5.4-pro' | 'gpt-5.4-pro-2026-03-05' | 'gpt-5.5' | 'gpt-5.5-2026-04-23' | (string & {});
declare const openaiLanguageModelChatOptions: _ai_sdk_provider_utils.LazySchema<{

@@ -86,4 +86,10 @@ logitBias?: Record<number, number> | undefined;

* The search query.
*
* @deprecated Use `queries` instead.
*/
query?: string;
/**
* The search queries the model used.
*/
queries?: string[];
} | {

@@ -208,2 +214,17 @@ /**

} | {
type: "error";
sequence_number: number;
error: {
type: string;
code: string;
message: string;
param?: string | null | undefined;
};
} | {
type: "error";
sequence_number: number;
message: string;
code?: string | null | undefined;
param?: string | null | undefined;
} | {
type: "response.output_text.delta";

@@ -240,2 +261,3 @@ item_id: string;

type: "response.failed";
sequence_number: number;
response: {

@@ -439,2 +461,3 @@ error?: {

query?: string | null | undefined;
queries?: string[] | null | undefined;
sources?: ({

@@ -653,11 +676,2 @@ type: "url";

diff: string;
} | {
type: "error";
sequence_number: number;
error: {
type: string;
code: string;
message: string;
param?: string | null | undefined;
};
}>;

@@ -969,2 +983,3 @@ type OpenAIResponsesChunk = InferSchema<typeof openaiResponsesChunkSchema>;

query?: string;
queries?: string[];
} | {

@@ -1049,3 +1064,3 @@ type: "openPage";

type OpenAIResponsesModelId = 'gpt-3.5-turbo-0125' | 'gpt-3.5-turbo-1106' | 'gpt-3.5-turbo' | 'gpt-4.1-2025-04-14' | 'gpt-4.1-mini-2025-04-14' | 'gpt-4.1-mini' | 'gpt-4.1-nano-2025-04-14' | 'gpt-4.1-nano' | 'gpt-4.1' | 'gpt-4o-2024-05-13' | 'gpt-4o-2024-08-06' | 'gpt-4o-2024-11-20' | 'gpt-4o-mini-2024-07-18' | 'gpt-4o-mini' | 'gpt-4o' | 'gpt-5.1' | 'gpt-5.1-2025-11-13' | 'gpt-5.1-chat-latest' | 'gpt-5.1-codex-mini' | 'gpt-5.1-codex' | 'gpt-5.1-codex-max' | 'gpt-5.2' | 'gpt-5.2-2025-12-11' | 'gpt-5.2-chat-latest' | 'gpt-5.2-pro' | 'gpt-5.2-pro-2025-12-11' | 'gpt-5.2-codex' | 'gpt-5.3-chat-latest' | 'gpt-5.3-codex' | 'gpt-5.4' | 'gpt-5.4-2026-03-05' | 'gpt-5.4-mini' | 'gpt-5.4-mini-2026-03-17' | 'gpt-5.4-nano' | 'gpt-5.4-nano-2026-03-17' | 'gpt-5.4-pro' | 'gpt-5.4-pro-2026-03-05' | 'gpt-5-2025-08-07' | 'gpt-5-chat-latest' | 'gpt-5-codex' | 'gpt-5-mini-2025-08-07' | 'gpt-5-mini' | 'gpt-5-nano-2025-08-07' | 'gpt-5-nano' | 'gpt-5-pro-2025-10-06' | 'gpt-5-pro' | 'gpt-5' | 'o1-2024-12-17' | 'o1' | 'o3-2025-04-16' | 'o3-mini-2025-01-31' | 'o3-mini' | 'o3' | 'o4-mini' | 'o4-mini-2025-04-16' | (string & {});
type OpenAIResponsesModelId = 'gpt-3.5-turbo-0125' | 'gpt-3.5-turbo-1106' | 'gpt-3.5-turbo' | 'gpt-4.1-2025-04-14' | 'gpt-4.1-mini-2025-04-14' | 'gpt-4.1-mini' | 'gpt-4.1-nano-2025-04-14' | 'gpt-4.1-nano' | 'gpt-4.1' | 'gpt-4o-2024-05-13' | 'gpt-4o-2024-08-06' | 'gpt-4o-2024-11-20' | 'gpt-4o-mini-2024-07-18' | 'gpt-4o-mini' | 'gpt-4o' | 'gpt-5.1' | 'gpt-5.1-2025-11-13' | 'gpt-5.1-chat-latest' | 'gpt-5.1-codex-mini' | 'gpt-5.1-codex' | 'gpt-5.1-codex-max' | 'gpt-5.2' | 'gpt-5.2-2025-12-11' | 'gpt-5.2-chat-latest' | 'gpt-5.2-pro' | 'gpt-5.2-pro-2025-12-11' | 'gpt-5.2-codex' | 'gpt-5.3-chat-latest' | 'gpt-5.3-codex' | 'gpt-5.4' | 'gpt-5.4-2026-03-05' | 'gpt-5.4-mini' | 'gpt-5.4-mini-2026-03-17' | 'gpt-5.4-nano' | 'gpt-5.4-nano-2026-03-17' | 'gpt-5.4-pro' | 'gpt-5.4-pro-2026-03-05' | 'gpt-5.5' | 'gpt-5.5-2026-04-23' | 'gpt-5-2025-08-07' | 'gpt-5-chat-latest' | 'gpt-5-codex' | 'gpt-5-mini-2025-08-07' | 'gpt-5-mini' | 'gpt-5-nano-2025-08-07' | 'gpt-5-nano' | 'gpt-5-pro-2025-10-06' | 'gpt-5-pro' | 'gpt-5' | 'o1-2024-12-17' | 'o1' | 'o3-2025-04-16' | 'o3-mini-2025-01-31' | 'o3-mini' | 'o3' | 'o4-mini' | 'o4-mini-2025-04-16' | (string & {});
declare const openaiLanguageModelResponsesOptionsSchema: _ai_sdk_provider_utils.LazySchema<{

@@ -1067,2 +1082,3 @@ conversation?: string | null | undefined;

store?: boolean | null | undefined;
passThroughUnsupportedFiles?: boolean | undefined;
strictJsonSchema?: boolean | null | undefined;

@@ -1078,2 +1094,6 @@ textVerbosity?: "low" | "medium" | "high" | null | undefined;

}[] | null | undefined;
allowedTools?: {
toolNames: string[];
mode?: "auto" | "required" | undefined;
} | undefined;
}>;

@@ -1150,2 +1170,7 @@ type OpenAILanguageModelResponsesOptions = InferSchema<typeof openaiLanguageModelResponsesOptionsSchema>;

/**
* Creates an experimental realtime model for bidirectional audio/text
* communication over WebSocket.
*/
experimental_realtime: Experimental_RealtimeFactoryV4;
/**
* Returns a FilesV4 interface for uploading files to OpenAI.

@@ -1203,2 +1228,27 @@ */

type OpenAIRealtimeModelConfig = {
provider: string;
baseURL: string;
headers: () => Record<string, string | undefined>;
fetch?: FetchFunction;
};
declare class OpenAIRealtimeModel implements Experimental_RealtimeModelV4 {
readonly specificationVersion: "v4";
readonly provider: string;
readonly modelId: string;
private readonly config;
constructor(modelId: string, config: OpenAIRealtimeModelConfig);
doCreateClientSecret(options: Experimental_RealtimeModelV4ClientSecretOptions): Promise<Experimental_RealtimeModelV4ClientSecretResult>;
getWebSocketConfig(options: {
token: string;
url: string;
}): {
url: string;
protocols?: string[];
};
parseServerEvent(raw: unknown): Experimental_RealtimeModelV4ServerEvent;
serializeClientEvent(event: Experimental_RealtimeModelV4ClientEvent): unknown;
buildSessionConfig(config: Experimental_RealtimeModelV4SessionConfig): Record<string, unknown>;
}
declare const openaiFilesOptionsSchema: _ai_sdk_provider_utils.LazySchema<{

@@ -1264,2 +1314,2 @@ purpose?: string | undefined;

export { type OpenAILanguageModelChatOptions as OpenAIChatLanguageModelOptions, type OpenAIEmbeddingModelOptions, type OpenAIFilesOptions, type OpenAIImageModelEditOptions, type OpenAIImageModelGenerationOptions, type OpenAIImageModelOptions, type OpenAILanguageModelChatOptions, type OpenAILanguageModelCompletionOptions, type OpenAILanguageModelResponsesOptions, type OpenAIProvider, type OpenAIProviderSettings, type OpenAILanguageModelResponsesOptions as OpenAIResponsesProviderOptions, type OpenAISpeechModelOptions, type OpenAITranscriptionModelOptions, type OpenaiResponsesCompactionProviderMetadata, type OpenaiResponsesProviderMetadata, type OpenaiResponsesReasoningProviderMetadata, type OpenaiResponsesSourceDocumentProviderMetadata, type OpenaiResponsesTextProviderMetadata, VERSION, createOpenAI, openai };
export { OpenAIRealtimeModel as Experimental_OpenAIRealtimeModel, type OpenAIRealtimeModelConfig as Experimental_OpenAIRealtimeModelConfig, type OpenAILanguageModelChatOptions as OpenAIChatLanguageModelOptions, type OpenAIEmbeddingModelOptions, type OpenAIFilesOptions, type OpenAIImageModelEditOptions, type OpenAIImageModelGenerationOptions, type OpenAIImageModelOptions, type OpenAILanguageModelChatOptions, type OpenAILanguageModelCompletionOptions, type OpenAILanguageModelResponsesOptions, type OpenAIProvider, type OpenAIProviderSettings, type OpenAILanguageModelResponsesOptions as OpenAIResponsesProviderOptions, type OpenAISpeechModelOptions, type OpenAITranscriptionModelOptions, type OpenaiResponsesCompactionProviderMetadata, type OpenaiResponsesProviderMetadata, type OpenaiResponsesReasoningProviderMetadata, type OpenaiResponsesSourceDocumentProviderMetadata, type OpenaiResponsesTextProviderMetadata, VERSION, createOpenAI, openai };

@@ -6,3 +6,3 @@ import * as _ai_sdk_provider from '@ai-sdk/provider';

type OpenAIChatModelId = 'o1' | 'o1-2024-12-17' | 'o3-mini' | 'o3-mini-2025-01-31' | 'o3' | 'o3-2025-04-16' | 'o4-mini' | 'o4-mini-2025-04-16' | 'gpt-4.1' | 'gpt-4.1-2025-04-14' | 'gpt-4.1-mini' | 'gpt-4.1-mini-2025-04-14' | 'gpt-4.1-nano' | 'gpt-4.1-nano-2025-04-14' | 'gpt-4o' | 'gpt-4o-2024-05-13' | 'gpt-4o-2024-08-06' | 'gpt-4o-2024-11-20' | 'gpt-4o-audio-preview' | 'gpt-4o-audio-preview-2024-12-17' | 'gpt-4o-audio-preview-2025-06-03' | 'gpt-4o-mini' | 'gpt-4o-mini-2024-07-18' | 'gpt-4o-mini-audio-preview' | 'gpt-4o-mini-audio-preview-2024-12-17' | 'gpt-4o-search-preview' | 'gpt-4o-search-preview-2025-03-11' | 'gpt-4o-mini-search-preview' | 'gpt-4o-mini-search-preview-2025-03-11' | 'gpt-3.5-turbo-0125' | 'gpt-3.5-turbo' | 'gpt-3.5-turbo-1106' | 'gpt-3.5-turbo-16k' | 'gpt-5' | 'gpt-5-2025-08-07' | 'gpt-5-mini' | 'gpt-5-mini-2025-08-07' | 'gpt-5-nano' | 'gpt-5-nano-2025-08-07' | 'gpt-5-chat-latest' | 'gpt-5.1' | 'gpt-5.1-2025-11-13' | 'gpt-5.1-chat-latest' | 'gpt-5.2' | 'gpt-5.2-2025-12-11' | 'gpt-5.2-chat-latest' | 'gpt-5.2-pro' | 'gpt-5.2-pro-2025-12-11' | 'gpt-5.3-chat-latest' | 'gpt-5.4' | 'gpt-5.4-2026-03-05' | 'gpt-5.4-mini' | 'gpt-5.4-mini-2026-03-17' | 'gpt-5.4-nano' | 'gpt-5.4-nano-2026-03-17' | 'gpt-5.4-pro' | 'gpt-5.4-pro-2026-03-05' | (string & {});
type OpenAIChatModelId = 'o1' | 'o1-2024-12-17' | 'o3-mini' | 'o3-mini-2025-01-31' | 'o3' | 'o3-2025-04-16' | 'o4-mini' | 'o4-mini-2025-04-16' | 'gpt-4.1' | 'gpt-4.1-2025-04-14' | 'gpt-4.1-mini' | 'gpt-4.1-mini-2025-04-14' | 'gpt-4.1-nano' | 'gpt-4.1-nano-2025-04-14' | 'gpt-4o' | 'gpt-4o-2024-05-13' | 'gpt-4o-2024-08-06' | 'gpt-4o-2024-11-20' | 'gpt-4o-audio-preview' | 'gpt-4o-audio-preview-2024-12-17' | 'gpt-4o-audio-preview-2025-06-03' | 'gpt-4o-mini' | 'gpt-4o-mini-2024-07-18' | 'gpt-4o-mini-audio-preview' | 'gpt-4o-mini-audio-preview-2024-12-17' | 'gpt-4o-search-preview' | 'gpt-4o-search-preview-2025-03-11' | 'gpt-4o-mini-search-preview' | 'gpt-4o-mini-search-preview-2025-03-11' | 'gpt-3.5-turbo-0125' | 'gpt-3.5-turbo' | 'gpt-3.5-turbo-1106' | 'gpt-3.5-turbo-16k' | 'gpt-5' | 'gpt-5-2025-08-07' | 'gpt-5-mini' | 'gpt-5-mini-2025-08-07' | 'gpt-5-nano' | 'gpt-5-nano-2025-08-07' | 'gpt-5-chat-latest' | 'gpt-5.1' | 'gpt-5.1-2025-11-13' | 'gpt-5.1-chat-latest' | 'gpt-5.2' | 'gpt-5.2-2025-12-11' | 'gpt-5.2-chat-latest' | 'gpt-5.2-pro' | 'gpt-5.2-pro-2025-12-11' | 'gpt-5.3-chat-latest' | 'gpt-5.4' | 'gpt-5.4-2026-03-05' | 'gpt-5.4-mini' | 'gpt-5.4-mini-2026-03-17' | 'gpt-5.4-nano' | 'gpt-5.4-nano-2026-03-17' | 'gpt-5.4-pro' | 'gpt-5.4-pro-2026-03-05' | 'gpt-5.5' | 'gpt-5.5-2026-04-23' | (string & {});
declare const openaiLanguageModelChatOptions: _ai_sdk_provider_utils.LazySchema<{

@@ -268,3 +268,3 @@ logitBias?: Record<number, number> | undefined;

type OpenAIResponsesModelId = 'gpt-3.5-turbo-0125' | 'gpt-3.5-turbo-1106' | 'gpt-3.5-turbo' | 'gpt-4.1-2025-04-14' | 'gpt-4.1-mini-2025-04-14' | 'gpt-4.1-mini' | 'gpt-4.1-nano-2025-04-14' | 'gpt-4.1-nano' | 'gpt-4.1' | 'gpt-4o-2024-05-13' | 'gpt-4o-2024-08-06' | 'gpt-4o-2024-11-20' | 'gpt-4o-mini-2024-07-18' | 'gpt-4o-mini' | 'gpt-4o' | 'gpt-5.1' | 'gpt-5.1-2025-11-13' | 'gpt-5.1-chat-latest' | 'gpt-5.1-codex-mini' | 'gpt-5.1-codex' | 'gpt-5.1-codex-max' | 'gpt-5.2' | 'gpt-5.2-2025-12-11' | 'gpt-5.2-chat-latest' | 'gpt-5.2-pro' | 'gpt-5.2-pro-2025-12-11' | 'gpt-5.2-codex' | 'gpt-5.3-chat-latest' | 'gpt-5.3-codex' | 'gpt-5.4' | 'gpt-5.4-2026-03-05' | 'gpt-5.4-mini' | 'gpt-5.4-mini-2026-03-17' | 'gpt-5.4-nano' | 'gpt-5.4-nano-2026-03-17' | 'gpt-5.4-pro' | 'gpt-5.4-pro-2026-03-05' | 'gpt-5-2025-08-07' | 'gpt-5-chat-latest' | 'gpt-5-codex' | 'gpt-5-mini-2025-08-07' | 'gpt-5-mini' | 'gpt-5-nano-2025-08-07' | 'gpt-5-nano' | 'gpt-5-pro-2025-10-06' | 'gpt-5-pro' | 'gpt-5' | 'o1-2024-12-17' | 'o1' | 'o3-2025-04-16' | 'o3-mini-2025-01-31' | 'o3-mini' | 'o3' | 'o4-mini' | 'o4-mini-2025-04-16' | (string & {});
type OpenAIResponsesModelId = 'gpt-3.5-turbo-0125' | 'gpt-3.5-turbo-1106' | 'gpt-3.5-turbo' | 'gpt-4.1-2025-04-14' | 'gpt-4.1-mini-2025-04-14' | 'gpt-4.1-mini' | 'gpt-4.1-nano-2025-04-14' | 'gpt-4.1-nano' | 'gpt-4.1' | 'gpt-4o-2024-05-13' | 'gpt-4o-2024-08-06' | 'gpt-4o-2024-11-20' | 'gpt-4o-mini-2024-07-18' | 'gpt-4o-mini' | 'gpt-4o' | 'gpt-5.1' | 'gpt-5.1-2025-11-13' | 'gpt-5.1-chat-latest' | 'gpt-5.1-codex-mini' | 'gpt-5.1-codex' | 'gpt-5.1-codex-max' | 'gpt-5.2' | 'gpt-5.2-2025-12-11' | 'gpt-5.2-chat-latest' | 'gpt-5.2-pro' | 'gpt-5.2-pro-2025-12-11' | 'gpt-5.2-codex' | 'gpt-5.3-chat-latest' | 'gpt-5.3-codex' | 'gpt-5.4' | 'gpt-5.4-2026-03-05' | 'gpt-5.4-mini' | 'gpt-5.4-mini-2026-03-17' | 'gpt-5.4-nano' | 'gpt-5.4-nano-2026-03-17' | 'gpt-5.4-pro' | 'gpt-5.4-pro-2026-03-05' | 'gpt-5.5' | 'gpt-5.5-2026-04-23' | 'gpt-5-2025-08-07' | 'gpt-5-chat-latest' | 'gpt-5-codex' | 'gpt-5-mini-2025-08-07' | 'gpt-5-mini' | 'gpt-5-nano-2025-08-07' | 'gpt-5-nano' | 'gpt-5-pro-2025-10-06' | 'gpt-5-pro' | 'gpt-5' | 'o1-2024-12-17' | 'o1' | 'o3-2025-04-16' | 'o3-mini-2025-01-31' | 'o3-mini' | 'o3' | 'o4-mini' | 'o4-mini-2025-04-16' | (string & {});

@@ -325,2 +325,17 @@ declare class OpenAIResponsesLanguageModel implements LanguageModelV4 {

} | {
type: "error";
sequence_number: number;
error: {
type: string;
code: string;
message: string;
param?: string | null | undefined;
};
} | {
type: "error";
sequence_number: number;
message: string;
code?: string | null | undefined;
param?: string | null | undefined;
} | {
type: "response.output_text.delta";

@@ -357,2 +372,3 @@ item_id: string;

type: "response.failed";
sequence_number: number;
response: {

@@ -556,2 +572,3 @@ error?: {

query?: string | null | undefined;
queries?: string[] | null | undefined;
sources?: ({

@@ -770,11 +787,2 @@ type: "url";

diff: string;
} | {
type: "error";
sequence_number: number;
error: {
type: string;
code: string;
message: string;
param?: string | null | undefined;
};
}>;

@@ -1212,2 +1220,196 @@ type OpenAIResponsesChunk = InferSchema<typeof openaiResponsesChunkSchema>;

declare const webSearchArgsSchema: _ai_sdk_provider_utils.LazySchema<{
externalWebAccess?: boolean | undefined;
filters?: {
allowedDomains?: string[] | undefined;
} | undefined;
searchContextSize?: "low" | "medium" | "high" | undefined;
userLocation?: {
type: "approximate";
country?: string | undefined;
city?: string | undefined;
region?: string | undefined;
timezone?: string | undefined;
} | undefined;
}>;
declare const webSearchOutputSchema: _ai_sdk_provider_utils.LazySchema<{
action?: {
type: "search";
query?: string | undefined;
queries?: string[] | undefined;
} | {
type: "openPage";
url?: string | null | undefined;
} | {
type: "findInPage";
url?: string | null | undefined;
pattern?: string | null | undefined;
} | undefined;
sources?: ({
type: "url";
url: string;
} | {
type: "api";
name: string;
})[] | undefined;
}>;
declare const webSearchToolFactory: _ai_sdk_provider_utils.ProviderExecutedToolFactory<{}, {
/**
* An object describing the specific action taken in this web search call.
* Includes details on how the model used the web (search, open_page, find_in_page).
*/
action?: {
/**
* Action type "search" - Performs a web search query.
*/
type: "search";
/**
* The search query.
*
* @deprecated Use `queries` instead.
*/
query?: string;
/**
* The search queries the model used.
*/
queries?: string[];
} | {
/**
* Action type "openPage" - Opens a specific URL from search results.
*/
type: "openPage";
/**
* The URL opened by the model.
*/
url?: string | null;
} | {
/**
* Action type "findInPage": Searches for a pattern within a loaded page.
*/
type: "findInPage";
/**
* The URL of the page searched for the pattern.
*/
url?: string | null;
/**
* The pattern or text to search for within the page.
*/
pattern?: string | null;
};
/**
* Optional sources cited by the model for the web search call.
*/
sources?: Array<{
type: "url";
url: string;
} | {
type: "api";
name: string;
}>;
}, {
/**
* Whether to use external web access for fetching live content.
* - true: Fetch live web content (default)
* - false: Use cached/indexed results
*/
externalWebAccess?: boolean;
/**
* Filters for the search.
*/
filters?: {
/**
* Allowed domains for the search.
* If not provided, all domains are allowed.
* Subdomains of the provided domains are allowed as well.
*/
allowedDomains?: string[];
};
/**
* Search context size to use for the web search.
* - high: Most comprehensive context, highest cost, slower response
* - medium: Balanced context, cost, and latency (default)
* - low: Least context, lowest cost, fastest response
*/
searchContextSize?: "low" | "medium" | "high";
/**
* User location information to provide geographically relevant search results.
*/
userLocation?: {
/**
* Type of location (always 'approximate')
*/
type: "approximate";
/**
* Two-letter ISO country code (e.g., 'US', 'GB')
*/
country?: string;
/**
* City name (free text, e.g., 'Minneapolis')
*/
city?: string;
/**
* Region name (free text, e.g., 'Minnesota')
*/
region?: string;
/**
* IANA timezone (e.g., 'America/Chicago')
*/
timezone?: string;
};
}, {}>;
declare const webSearch: (args?: Parameters<typeof webSearchToolFactory>[0]) => _ai_sdk_provider_utils.ProviderExecutedTool<{}, {
/**
* An object describing the specific action taken in this web search call.
* Includes details on how the model used the web (search, open_page, find_in_page).
*/
action?: {
/**
* Action type "search" - Performs a web search query.
*/
type: "search";
/**
* The search query.
*
* @deprecated Use `queries` instead.
*/
query?: string;
/**
* The search queries the model used.
*/
queries?: string[];
} | {
/**
* Action type "openPage" - Opens a specific URL from search results.
*/
type: "openPage";
/**
* The URL opened by the model.
*/
url?: string | null;
} | {
/**
* Action type "findInPage": Searches for a pattern within a loaded page.
*/
type: "findInPage";
/**
* The URL of the page searched for the pattern.
*/
url?: string | null;
/**
* The pattern or text to search for within the page.
*/
pattern?: string | null;
};
/**
* Optional sources cited by the model for the web search call.
*/
sources?: Array<{
type: "url";
url: string;
} | {
type: "api";
name: string;
}>;
}, {}>;
declare const webSearchPreviewArgsSchema: _ai_sdk_provider_utils.LazySchema<{

@@ -1296,2 +1498,2 @@ searchContextSize?: "low" | "medium" | "high" | undefined;

export { type ApplyPatchOperation, OpenAIChatLanguageModel, type OpenAIChatModelId, OpenAICompletionLanguageModel, type OpenAICompletionModelId, OpenAIEmbeddingModel, type OpenAIEmbeddingModelId, type OpenAIEmbeddingModelOptions, OpenAIImageModel, type OpenAIImageModelEditOptions, type OpenAIImageModelGenerationOptions, type OpenAIImageModelId, type OpenAIImageModelOptions, type OpenAILanguageModelChatOptions, type OpenAILanguageModelCompletionOptions, OpenAIResponsesLanguageModel, OpenAISpeechModel, type OpenAISpeechModelId, type OpenAISpeechModelOptions, type OpenAITranscriptionCallOptions, OpenAITranscriptionModel, type OpenAITranscriptionModelId, type OpenAITranscriptionModelOptions, type OpenaiResponsesCompactionProviderMetadata, type OpenaiResponsesProviderMetadata, type OpenaiResponsesReasoningProviderMetadata, type OpenaiResponsesSourceDocumentProviderMetadata, type OpenaiResponsesTextProviderMetadata, type ResponsesCompactionProviderMetadata, type ResponsesProviderMetadata, type ResponsesReasoningProviderMetadata, type ResponsesSourceDocumentProviderMetadata, type ResponsesTextProviderMetadata, applyPatch, applyPatchArgsSchema, applyPatchInputSchema, applyPatchOutputSchema, applyPatchToolFactory, codeInterpreter, codeInterpreterArgsSchema, codeInterpreterInputSchema, codeInterpreterOutputSchema, codeInterpreterToolFactory, fileSearch, fileSearchArgsSchema, fileSearchOutputSchema, hasDefaultResponseFormat, imageGeneration, imageGenerationArgsSchema, imageGenerationOutputSchema, modelMaxImagesPerCall, openAITranscriptionModelOptions, openaiEmbeddingModelOptions, openaiImageModelEditOptions, openaiImageModelGenerationOptions, openaiImageModelOptions, openaiLanguageModelChatOptions, openaiLanguageModelCompletionOptions, openaiSpeechModelOptionsSchema, webSearchPreview, webSearchPreviewArgsSchema, webSearchPreviewInputSchema };
export { type ApplyPatchOperation, OpenAIChatLanguageModel, type OpenAIChatModelId, OpenAICompletionLanguageModel, type OpenAICompletionModelId, OpenAIEmbeddingModel, type OpenAIEmbeddingModelId, type OpenAIEmbeddingModelOptions, OpenAIImageModel, type OpenAIImageModelEditOptions, type OpenAIImageModelGenerationOptions, type OpenAIImageModelId, type OpenAIImageModelOptions, type OpenAILanguageModelChatOptions, type OpenAILanguageModelCompletionOptions, OpenAIResponsesLanguageModel, OpenAISpeechModel, type OpenAISpeechModelId, type OpenAISpeechModelOptions, type OpenAITranscriptionCallOptions, OpenAITranscriptionModel, type OpenAITranscriptionModelId, type OpenAITranscriptionModelOptions, type OpenaiResponsesCompactionProviderMetadata, type OpenaiResponsesProviderMetadata, type OpenaiResponsesReasoningProviderMetadata, type OpenaiResponsesSourceDocumentProviderMetadata, type OpenaiResponsesTextProviderMetadata, type ResponsesCompactionProviderMetadata, type ResponsesProviderMetadata, type ResponsesReasoningProviderMetadata, type ResponsesSourceDocumentProviderMetadata, type ResponsesTextProviderMetadata, applyPatch, applyPatchArgsSchema, applyPatchInputSchema, applyPatchOutputSchema, applyPatchToolFactory, codeInterpreter, codeInterpreterArgsSchema, codeInterpreterInputSchema, codeInterpreterOutputSchema, codeInterpreterToolFactory, fileSearch, fileSearchArgsSchema, fileSearchOutputSchema, hasDefaultResponseFormat, imageGeneration, imageGenerationArgsSchema, imageGenerationOutputSchema, modelMaxImagesPerCall, openAITranscriptionModelOptions, openaiEmbeddingModelOptions, openaiImageModelEditOptions, openaiImageModelGenerationOptions, openaiImageModelOptions, openaiLanguageModelChatOptions, openaiLanguageModelCompletionOptions, openaiSpeechModelOptionsSchema, webSearch, webSearchArgsSchema, webSearchOutputSchema, webSearchPreview, webSearchPreviewArgsSchema, webSearchPreviewInputSchema, webSearchToolFactory };
+7
-7
{
"name": "@ai-sdk/openai",
"version": "4.0.0-beta.44",
"version": "4.0.0-beta.74",
"type": "module",

@@ -38,11 +38,11 @@ "license": "Apache-2.0",

"dependencies": {
"@ai-sdk/provider": "4.0.0-beta.14",
"@ai-sdk/provider-utils": "5.0.0-beta.30"
"@ai-sdk/provider": "4.0.0-beta.19",
"@ai-sdk/provider-utils": "5.0.0-beta.49"
},
"devDependencies": {
"@types/node": "20.17.24",
"tsup": "^8",
"@types/node": "22.19.19",
"tsup": "^8.5.1",
"typescript": "5.8.3",
"zod": "3.25.76",
"@ai-sdk/test-server": "2.0.0-beta.3",
"@ai-sdk/test-server": "2.0.0-beta.7",
"@vercel/ai-tsconfig": "0.0.0"

@@ -54,3 +54,3 @@ },

"engines": {
"node": ">=18"
"node": ">=22"
},

@@ -57,0 +57,0 @@ "publishConfig": {

@@ -206,3 +206,3 @@ import {

role: 'assistant',
content: text || null,
content: toolCalls.length > 0 ? text || null : text,
tool_calls: toolCalls.length > 0 ? toolCalls : undefined,

@@ -209,0 +209,0 @@ });

@@ -67,2 +67,4 @@ import {

| 'gpt-5.4-pro-2026-03-05'
| 'gpt-5.5'
| 'gpt-5.5-2026-04-23'
| (string & {});

@@ -69,0 +71,0 @@

@@ -29,2 +29,3 @@ import type {

import { getOpenAILanguageModelCapabilities } from '../openai-language-model-capabilities';
import { throwIfOpenAIStreamErrorBeforeOutput } from '../openai-stream-error';
import {

@@ -441,7 +442,9 @@ convertOpenAIChatUsage,

const url = this.config.url({
path: '/chat/completions',
modelId: this.modelId,
});
const { responseHeaders, value: response } = await postJsonToApi({
url: this.config.url({
path: '/chat/completions',
modelId: this.modelId,
}),
url,
headers: combineHeaders(this.config.headers?.(), options.headers),

@@ -457,2 +460,11 @@ body,

const checkedResponse = await throwIfOpenAIStreamErrorBeforeOutput({
stream: response,
getError: chunk => ('error' in chunk ? chunk.error : undefined),
isOutputChunk: isOpenAIChatOutputChunk,
url,
requestBodyValues: body,
responseHeaders,
});
let toolCallTracker: StreamingToolCallTracker;

@@ -470,4 +482,4 @@

return {
stream: response.pipeThrough(
const result = {
stream: checkedResponse.pipeThrough(
new TransformStream<

@@ -610,3 +622,21 @@ ParseResult<OpenAIChatChunk>,

};
return result;
}
}
function isOpenAIChatOutputChunk(chunk: OpenAIChatChunk): boolean {
if ('error' in chunk) {
return false;
}
return chunk.choices.some(choice => {
const delta = choice.delta;
return (
(delta?.content != null && delta.content.length > 0) ||
(delta?.tool_calls != null && delta.tool_calls.length > 0) ||
(delta?.annotations != null && delta.annotations.length > 0)
);
});
}

@@ -24,2 +24,3 @@ import type {

import { openaiFailedResponseHandler } from '../openai-error';
import { throwIfOpenAIStreamErrorBeforeOutput } from '../openai-stream-error';
import {

@@ -244,7 +245,9 @@ convertOpenAICompletionUsage,

const url = this.config.url({
path: '/completions',
modelId: this.modelId,
});
const { responseHeaders, value: response } = await postJsonToApi({
url: this.config.url({
path: '/completions',
modelId: this.modelId,
}),
url,
headers: combineHeaders(this.config.headers?.(), options.headers),

@@ -260,2 +263,11 @@ body,

const checkedResponse = await throwIfOpenAIStreamErrorBeforeOutput({
stream: response,
getError: chunk => ('error' in chunk ? chunk.error : undefined),
isOutputChunk: isOpenAICompletionOutputChunk,
url,
requestBodyValues: body,
responseHeaders,
});
let finishReason: LanguageModelV4FinishReason = {

@@ -269,4 +281,4 @@ unified: 'other',

return {
stream: response.pipeThrough(
const result = {
stream: checkedResponse.pipeThrough(
new TransformStream<

@@ -355,3 +367,11 @@ ParseResult<OpenAICompletionChunk>,

};
return result;
}
}
function isOpenAICompletionOutputChunk(chunk: OpenAICompletionChunk): boolean {
return (
!('error' in chunk) && chunk.choices.some(choice => choice.text.length > 0)
);
}
export { createOpenAI, openai } from './openai-provider';
export type { OpenAIProvider, OpenAIProviderSettings } from './openai-provider';
export { OpenAIRealtimeModel as Experimental_OpenAIRealtimeModel } from './realtime/openai-realtime-model';
export type { OpenAIRealtimeModelConfig as Experimental_OpenAIRealtimeModelConfig } from './realtime/openai-realtime-model';
export type {

@@ -4,0 +6,0 @@ OpenAILanguageModelResponsesOptions,

@@ -19,2 +19,3 @@ export * from '../chat/openai-chat-language-model';

export * from '../tool/image-generation';
export * from '../tool/web-search';
export * from '../tool/web-search-preview';

@@ -39,3 +39,3 @@ export type OpenAILanguageModelCapabilities = {

// https://platform.openai.com/docs/guides/latest-model#gpt-5-1-parameter-compatibility
// GPT-5.1, GPT-5.2, and GPT-5.4 support temperature, topP, logProbs when reasoningEffort is none
// GPT-5.1 and later model families support temperature, topP, logProbs when reasoningEffort is none.
const supportsNonReasoningParameters =

@@ -45,3 +45,4 @@ modelId.startsWith('gpt-5.1') ||

modelId.startsWith('gpt-5.3') ||
modelId.startsWith('gpt-5.4');
modelId.startsWith('gpt-5.4') ||
modelId.startsWith('gpt-5.5');

@@ -48,0 +49,0 @@ const systemMessageMode = isReasoningModel ? 'developer' : 'system';

@@ -7,2 +7,4 @@ import type {

ProviderV4,
Experimental_RealtimeFactoryV4 as RealtimeFactoryV4,
Experimental_RealtimeFactoryV4GetTokenOptions as RealtimeFactoryV4GetTokenOptions,
SpeechModelV4,

@@ -29,2 +31,3 @@ SkillsV4,

import { openaiTools } from './openai-tools';
import { OpenAIRealtimeModel } from './realtime/openai-realtime-model';
import { OpenAIResponsesLanguageModel } from './responses/openai-responses-language-model';

@@ -103,2 +106,8 @@ import type { OpenAIResponsesModelId } from './responses/openai-responses-language-model-options';

/**
* Creates an experimental realtime model for bidirectional audio/text
* communication over WebSocket.
*/
experimental_realtime: RealtimeFactoryV4;
/**
* Returns a FilesV4 interface for uploading files to OpenAI.

@@ -273,2 +282,29 @@ */

const createRealtimeModel = (modelId: string) =>
new OpenAIRealtimeModel(modelId, {
provider: `${providerName}.realtime`,
baseURL,
headers: getHeaders,
fetch: options.fetch,
});
const experimentalRealtimeFactory = Object.assign(
(modelId: string) => createRealtimeModel(modelId),
{
getToken: async (tokenOptions: RealtimeFactoryV4GetTokenOptions) => {
const model = createRealtimeModel(tokenOptions.model);
const secret = await model.doCreateClientSecret({
sessionConfig: tokenOptions.sessionConfig,
expiresAfterSeconds: tokenOptions.expiresAfterSeconds,
});
return {
token: secret.token,
url: secret.url,
expiresAt: secret.expiresAt,
};
},
},
) as RealtimeFactoryV4;
const provider = function (modelId: OpenAIResponsesModelId) {

@@ -299,2 +335,4 @@ return createLanguageModel(modelId);

provider.experimental_realtime = experimentalRealtimeFactory;
provider.tools = openaiTools;

@@ -301,0 +339,0 @@

@@ -61,4 +61,6 @@ import {

fileIdPrefixes,
passThroughUnsupportedFiles = false,
store,
hasConversation = false,
hasPreviousResponseId = false,
hasLocalShellTool = false,

@@ -75,4 +77,6 @@ hasShellTool = false,

fileIdPrefixes?: readonly string[];
passThroughUnsupportedFiles?: boolean;
store: boolean;
hasConversation?: boolean; // when true, skip assistant messages that already have item IDs
hasPreviousResponseId?: boolean; // when true, skip reasoning and function-call items that already exist in the previous response chain
hasLocalShellTool?: boolean;

@@ -183,3 +187,6 @@ hasShellTool?: boolean;

const fullMediaType = resolveFullMediaType({ part });
if (fullMediaType !== 'application/pdf') {
if (
fullMediaType !== 'application/pdf' &&
!passThroughUnsupportedFiles
) {
throw new UnsupportedFunctionalityError({

@@ -196,4 +203,8 @@ functionality: `file part media type ${fullMediaType}`,

: {
filename: part.filename ?? `part-${index}.pdf`,
file_data: `data:application/pdf;base64,${convertToBase64(part.data.data)}`,
filename:
part.filename ??
(fullMediaType === 'application/pdf'
? `part-${index}.pdf`
: `part-${index}`),
file_data: `data:${fullMediaType};base64,${convertToBase64(part.data.data)}`,
}),

@@ -218,5 +229,6 @@ };

case 'text': {
const providerOpts = part.providerOptions?.[providerOptionsName];
const id = providerOpts?.itemId as string | undefined;
const phase = providerOpts?.phase as
const providerOptions =
part.providerOptions?.[providerOptionsName];
const id = providerOptions?.itemId as string | undefined;
const phase = providerOptions?.phase as
| 'commentary'

@@ -259,2 +271,14 @@ | 'final_answer'

const namespace = (part.providerOptions?.[providerOptionsName]
?.namespace ??
(
part as {
providerMetadata?: {
[providerOptionsName]?: { namespace?: string };
};
}
).providerMetadata?.[providerOptionsName]?.namespace) as
| string
| undefined;
if (hasConversation && id != null) {

@@ -306,3 +330,25 @@ break;

if (store && id != null) {
// When chaining with a previous response id, items already part
// of that response chain must not be resent.
if (hasPreviousResponseId && store && id != null) {
break;
}
// Provider-defined tool calls (local_shell, shell, apply_patch,
// and custom tools) are stored by the API and can be sent as an
// `item_reference` to reduce payload size. Plain client-executed
// function calls must NOT be: the matching `function_call_output`
// can only reference the call by `call_id` (`call_...`), which
// the API cannot reconcile with an item id (`fc_...`) or an
// `item_reference`. Sending either breaks call/output pairing and
// makes follow-up requests fail with "No tool call found for
// function call output with call_id", most visibly with parallel
// tool calls across multiple steps.
const isProviderDefinedToolCall =
(hasLocalShellTool && resolvedToolName === 'local_shell') ||
(hasShellTool && resolvedToolName === 'shell') ||
(hasApplyPatchTool && resolvedToolName === 'apply_patch') ||
(customProviderToolNames?.has(resolvedToolName) ?? false);
if (store && id != null && isProviderDefinedToolCall) {
input.push({ type: 'item_reference', id });

@@ -389,3 +435,3 @@ break;

arguments: serializeToolCallArguments(part.input),
id,
...(namespace != null && { namespace }),
});

@@ -507,3 +553,6 @@ break;

if (hasConversation && reasoningId != null) {
if (
(hasConversation || hasPreviousResponseId) &&
reasoningId != null
) {
break;

@@ -602,5 +651,5 @@ }

if (part.kind === 'openai.compaction') {
const providerOpts =
const providerOptions =
part.providerOptions?.[providerOptionsName];
const id = providerOpts?.itemId as string | undefined;
const id = providerOptions?.itemId as string | undefined;

@@ -616,3 +665,3 @@ if (hasConversation && id != null) {

const encryptedContent = providerOpts?.encryptedContent as
const encryptedContent = providerOptions?.encryptedContent as
| string

@@ -781,25 +830,46 @@ | undefined;

return { type: 'input_text' as const, text: item.text };
case 'file-data':
if (item.mediaType.startsWith('image/')) {
case 'file': {
const topLevel = getTopLevelMediaType(item.mediaType);
const imageDetail =
item.providerOptions?.[providerOptionsName]
?.imageDetail;
if (item.data.type === 'data') {
const fullMediaType = resolveFullMediaType({
part: item,
});
if (topLevel === 'image') {
return {
type: 'input_image' as const,
image_url: `data:${fullMediaType};base64,${convertToBase64(item.data.data)}`,
detail: imageDetail,
};
}
return {
type: 'input_image' as const,
image_url: `data:${item.mediaType};base64,${item.data}`,
type: 'input_file' as const,
filename: item.filename ?? 'data',
file_data: `data:${fullMediaType};base64,${convertToBase64(item.data.data)}`,
};
}
return {
type: 'input_file' as const,
filename: item.filename ?? 'data',
file_data: `data:${item.mediaType};base64,${item.data}`,
};
case 'file-url':
if (item.mediaType.startsWith('image/')) {
if (item.data.type === 'url') {
if (topLevel === 'image') {
return {
type: 'input_image' as const,
image_url: item.data.url.toString(),
detail: imageDetail,
};
}
return {
type: 'input_image' as const,
image_url: item.url,
type: 'input_file' as const,
file_url: item.data.url.toString(),
};
}
return {
type: 'input_file' as const,
file_url: item.url,
};
warnings.push({
type: 'other',
message: `unsupported custom tool content part type: ${item.type} with data type: ${item.data.type}`,
});
return undefined;
}
default:

@@ -847,27 +917,45 @@ warnings.push({

case 'file-data': {
if (item.mediaType.startsWith('image/')) {
case 'file': {
const topLevel = getTopLevelMediaType(item.mediaType);
const imageDetail =
item.providerOptions?.[providerOptionsName]
?.imageDetail;
if (item.data.type === 'data') {
const fullMediaType = resolveFullMediaType({
part: item,
});
if (topLevel === 'image') {
return {
type: 'input_image' as const,
image_url: `data:${fullMediaType};base64,${convertToBase64(item.data.data)}`,
detail: imageDetail,
};
}
return {
type: 'input_image' as const,
image_url: `data:${item.mediaType};base64,${item.data}`,
type: 'input_file' as const,
filename: item.filename ?? 'data',
file_data: `data:${fullMediaType};base64,${convertToBase64(item.data.data)}`,
};
}
return {
type: 'input_file' as const,
filename: item.filename ?? 'data',
file_data: `data:${item.mediaType};base64,${item.data}`,
};
}
case 'file-url': {
if (item.mediaType.startsWith('image/')) {
if (item.data.type === 'url') {
if (topLevel === 'image') {
return {
type: 'input_image' as const,
image_url: item.data.url.toString(),
detail: imageDetail,
};
}
return {
type: 'input_image' as const,
image_url: item.url,
type: 'input_file' as const,
file_url: item.data.url.toString(),
};
}
return {
type: 'input_file' as const,
file_url: item.url,
};
warnings.push({
type: 'other',
message: `unsupported tool content part type: ${item.type} with data type: ${item.data.type}`,
});
return undefined;
}

@@ -874,0 +962,0 @@

@@ -103,2 +103,3 @@ import type { JSONObject, JSONSchema7, JSONValue } from '@ai-sdk/provider';

id?: string;
namespace?: string;
};

@@ -289,10 +290,18 @@

export type OpenAIResponsesFunctionTool = {
type: 'function';
name: string;
description: string | undefined;
parameters: JSONSchema7;
strict?: boolean;
defer_loading?: boolean;
};
export type OpenAIResponsesTool =
| OpenAIResponsesFunctionTool
| {
type: 'function';
type: 'namespace';
name: string;
description: string | undefined;
parameters: JSONSchema7;
strict?: boolean;
defer_loading?: boolean;
description: string;
tools: Array<OpenAIResponsesFunctionTool>;
}

@@ -474,2 +483,26 @@ | {

// Captured from the Responses API when OpenAI returned an early
// insufficient_quota stream error after HTTP 200. This shape differs from the
// currently documented ResponseErrorEvent below.
const openaiResponsesNestedErrorChunkSchema = z.object({
type: z.literal('error'),
sequence_number: z.number(),
error: z.object({
type: z.string(),
code: z.string(),
message: z.string(),
param: z.string().nullish(),
}),
});
// Current OpenAI OpenAPI docs define ResponseErrorEvent with top-level
// code/message/param fields.
const openaiResponsesErrorChunkSchema = z.object({
type: z.literal('error'),
sequence_number: z.number(),
code: z.string().nullish(),
message: z.string(),
param: z.string().nullish(),
});
export const openaiResponsesChunkSchema = lazySchema(() =>

@@ -516,2 +549,3 @@ zodSchema(

type: z.literal('response.failed'),
sequence_number: z.number(),
response: z.object({

@@ -757,2 +791,3 @@ error: z

query: z.string().nullish(),
queries: z.array(z.string()).nullish(),
sources: z

@@ -1034,12 +1069,4 @@ .array(

}),
z.object({
type: z.literal('error'),
sequence_number: z.number(),
error: z.object({
type: z.string(),
code: z.string(),
message: z.string(),
param: z.string().nullish(),
}),
}),
openaiResponsesNestedErrorChunkSchema,
openaiResponsesErrorChunkSchema,
z

@@ -1156,2 +1183,3 @@ .object({ type: z.string() })

query: z.string().nullish(),
queries: z.array(z.string()).nullish(),
sources: z

@@ -1158,0 +1186,0 @@ .array(

@@ -54,2 +54,4 @@ import {

'gpt-5.4-pro-2026-03-05',
'gpt-5.5',
'gpt-5.5-2026-04-23',
] as const;

@@ -121,2 +123,4 @@

| 'gpt-5.4-pro-2026-03-05'
| 'gpt-5.5'
| 'gpt-5.5-2026-04-23'
| 'gpt-5-2025-08-07'

@@ -271,2 +275,11 @@ | 'gpt-5-chat-latest'

/**
* Whether to pass through non-image file types as generic input files.
*
* By default, inline file inputs are restricted to images and PDFs.
* Enable this when the target OpenAI Responses model supports additional
* file media types, such as text/csv.
*/
passThroughUnsupportedFiles: z.boolean().optional(),
/**
* Whether to use strict JSON schema validation.

@@ -330,2 +343,19 @@ * Defaults to `true`.

.nullish(),
/**
* Restrict the callable tools to a subset while keeping the full tools
* list intact, so prompt caching is preserved across requests with
* different allowlists.
*
* When set, this overrides the request-level `toolChoice` and emits
* `tool_choice: { type: "allowed_tools", mode, tools }` on the wire.
*
* @see https://developers.openai.com/api/reference/resources/responses/methods/create#(resource)%20responses%20%3E%20(model)%20tool_choice_allowed%20%3E%20(schema)
*/
allowedTools: z
.object({
toolNames: z.array(z.string()).min(1),
mode: z.enum(['auto', 'required']).optional(),
})
.optional(),
}),

@@ -332,0 +362,0 @@ ),

import {
UnsupportedFunctionalityError,
type LanguageModelV4CallOptions,
type LanguageModelV4FunctionTool,
type SharedV4ProviderReference,

@@ -21,7 +22,19 @@ type SharedV4Warning,

import { webSearchPreviewArgsSchema } from '../tool/web-search-preview';
import type { OpenAIResponsesTool } from './openai-responses-api';
import type {
OpenAIResponsesFunctionTool,
OpenAIResponsesTool,
} from './openai-responses-api';
type OpenAIToolOptions = {
deferLoading?: boolean;
namespace?: {
name: string;
description: string;
};
};
export async function prepareResponsesTools({
tools,
toolChoice,
allowedTools,
toolNameMapping,

@@ -32,2 +45,6 @@ customProviderToolNames,

toolChoice: LanguageModelV4CallOptions['toolChoice'] | undefined;
allowedTools?: {
toolNames: string[];
mode?: 'auto' | 'required';
};
toolNameMapping?: ToolNameMapping;

@@ -49,3 +66,8 @@ customProviderToolNames?: Set<string>;

| { type: 'image_generation' }
| { type: 'apply_patch' };
| { type: 'apply_patch' }
| {
type: 'allowed_tools';
mode: 'auto' | 'required';
tools: Array<{ type: 'function'; name: string }>;
};
toolWarnings: SharedV4Warning[];

@@ -63,2 +85,6 @@ }> {

const openaiTools: Array<OpenAIResponsesTool> = [];
const namespaceTools = new Map<
string,
Extract<OpenAIResponsesTool, { type: 'namespace' }>
>();
const resolvedCustomProviderToolNames =

@@ -71,14 +97,32 @@ customProviderToolNames ?? new Set<string>();

const openaiOptions = tool.providerOptions?.openai as
| { deferLoading?: boolean }
| OpenAIToolOptions
| undefined;
const deferLoading = openaiOptions?.deferLoading;
const openaiFunctionTool = prepareFunctionTool({
tool,
options: openaiOptions,
});
const namespace = openaiOptions?.namespace;
openaiTools.push({
type: 'function',
name: tool.name,
description: tool.description,
parameters: tool.inputSchema,
...(tool.strict != null ? { strict: tool.strict } : {}),
...(deferLoading != null ? { defer_loading: deferLoading } : {}),
});
if (namespace == null) {
openaiTools.push(openaiFunctionTool);
} else {
let namespaceTool = namespaceTools.get(namespace.name);
if (namespaceTool == null) {
namespaceTool = {
type: 'namespace',
name: namespace.name,
description: namespace.description,
tools: [],
};
namespaceTools.set(namespace.name, namespaceTool);
openaiTools.push(namespaceTool);
} else if (namespaceTool.description !== namespace.description) {
throw new UnsupportedFunctionalityError({
functionality: `conflicting descriptions for OpenAI tool namespace "${namespace.name}"`,
});
}
namespaceTool.tools.push(openaiFunctionTool);
}
break;

@@ -298,2 +342,17 @@ }

if (allowedTools != null) {
return {
tools: openaiTools,
toolChoice: {
type: 'allowed_tools',
mode: allowedTools.mode ?? 'auto',
tools: allowedTools.toolNames.map(name => ({
type: 'function',
name: toolNameMapping?.toProviderToolName(name) ?? name,
})),
},
toolWarnings,
};
}
if (toolChoice == null) {

@@ -341,2 +400,21 @@ return { tools: openaiTools, toolChoice: undefined, toolWarnings };

function prepareFunctionTool({
tool,
options,
}: {
tool: LanguageModelV4FunctionTool;
options: OpenAIToolOptions | undefined;
}): OpenAIResponsesFunctionTool {
const deferLoading = options?.deferLoading;
return {
type: 'function',
name: tool.name,
description: tool.description,
parameters: tool.inputSchema,
...(tool.strict != null ? { strict: tool.strict } : {}),
...(deferLoading != null ? { defer_loading: deferLoading } : {}),
};
}
function mapShellEnvironment(environment: {

@@ -343,0 +421,0 @@ type?: string;

@@ -39,2 +39,3 @@ import {

query: z.string().optional(),
queries: z.array(z.string()).optional(),
}),

@@ -82,4 +83,11 @@ z.object({

* The search query.
*
* @deprecated Use `queries` instead.
*/
query?: string;
/**
* The search queries the model used.
*/
queries?: string[];
}

@@ -86,0 +94,0 @@ | {

@@ -156,4 +156,13 @@ import type {

if (this.modelId === 'whisper-1') {
formData.append('response_format', 'verbose_json');
}
// Add provider-specific options
if (openAIOptions) {
const isGpt4oTranscribeModel = [
'gpt-4o-transcribe',
'gpt-4o-mini-transcribe',
].includes(this.modelId);
const transcriptionModelOptions = {

@@ -165,8 +174,5 @@ include: openAIOptions.include,

// prefer verbose_json to get segments for models that support it
response_format: [
'gpt-4o-transcribe',
'gpt-4o-mini-transcribe',
].includes(this.modelId)
? 'json'
: 'verbose_json',
...(this.modelId !== 'whisper-1' && {
response_format: isGpt4oTranscribeModel ? 'json' : 'verbose_json',
}),
temperature: openAIOptions.temperature,

@@ -173,0 +179,0 @@ timestamp_granularities: openAIOptions.timestampGranularities,

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display