@ai-sdk/openai 4.0.47 → 4.0.49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -0
- package/dist/index.d.ts +29 -12
- package/dist/index.js +374 -274
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +45 -26
- package/dist/internal/index.js +270 -166
- package/dist/internal/index.js.map +1 -1
- package/docs/03-openai.mdx +31 -11
- package/package.json +2 -2
- package/src/chat/convert-to-openai-chat-messages.ts +5 -1
- package/src/chat/openai-chat-language-model.ts +9 -2
- package/src/completion/openai-completion-language-model.ts +9 -2
- package/src/embedding/openai-embedding-model.ts +2 -0
- package/src/openai-responses-batch.ts +90 -102
- package/src/openai-stream-error.ts +68 -15
- package/src/responses/openai-responses-api.ts +114 -40
- package/src/responses/openai-responses-language-model.ts +28 -18
package/dist/internal/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as _ai_sdk_provider from '@ai-sdk/provider';
|
|
2
2
|
import { LanguageModelV4, LanguageModelV4CallOptions, LanguageModelV4GenerateResult, LanguageModelV4StreamResult, EmbeddingModelV4, ImageModelV4, TranscriptionModelV4CallOptions, TranscriptionModelV4, Experimental_TranscriptionModelV4StreamOptions, SpeechModelV4, JSONSchema7, JSONObject, JSONValue, SharedV4Warning } from '@ai-sdk/provider';
|
|
3
3
|
import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
|
|
4
|
-
import { InferSchema, WORKFLOW_SERIALIZE, WORKFLOW_DESERIALIZE, FetchFunction, WebSocketConstructor } from '@ai-sdk/provider-utils';
|
|
4
|
+
import { InferSchema, WORKFLOW_SERIALIZE, WORKFLOW_DESERIALIZE, FetchFunction, WebSocketConstructor, EXPERIMENTAL_EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL } from '@ai-sdk/provider-utils';
|
|
5
5
|
import { z } from 'zod/v4';
|
|
6
6
|
|
|
7
7
|
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' | 'gpt-5.6' | 'gpt-5.6-luna' | 'gpt-5.6-sol' | 'gpt-5.6-terra' | (string & {});
|
|
@@ -133,6 +133,7 @@ declare class OpenAIEmbeddingModel implements EmbeddingModelV4 {
|
|
|
133
133
|
readonly specificationVersion = "v4";
|
|
134
134
|
readonly modelId: OpenAIEmbeddingModelId;
|
|
135
135
|
readonly maxEmbeddingsPerCall = 2048;
|
|
136
|
+
readonly [EXPERIMENTAL_EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL] = 300000;
|
|
136
137
|
readonly supportsParallelCalls = true;
|
|
137
138
|
private readonly config;
|
|
138
139
|
static [WORKFLOW_SERIALIZE](model: OpenAIEmbeddingModel): {
|
|
@@ -390,6 +391,19 @@ declare const openaiResponsesComputerCallSchema: z.ZodObject<{
|
|
|
390
391
|
message: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
391
392
|
}, z.core.$strip>>>>;
|
|
392
393
|
}, z.core.$strip>;
|
|
394
|
+
declare const openaiResponsesLocalShellCallSchema: z.ZodObject<{
|
|
395
|
+
type: z.ZodLiteral<"local_shell_call">;
|
|
396
|
+
id: z.ZodString;
|
|
397
|
+
call_id: z.ZodString;
|
|
398
|
+
action: z.ZodObject<{
|
|
399
|
+
type: z.ZodLiteral<"exec">;
|
|
400
|
+
command: z.ZodArray<z.ZodString>;
|
|
401
|
+
timeout_ms: z.ZodOptional<z.ZodNumber>;
|
|
402
|
+
user: z.ZodOptional<z.ZodString>;
|
|
403
|
+
working_directory: z.ZodOptional<z.ZodString>;
|
|
404
|
+
env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
405
|
+
}, z.core.$strip>;
|
|
406
|
+
}, z.core.$strip>;
|
|
393
407
|
type OpenAIResponsesInput = Array<OpenAIResponsesInputItem>;
|
|
394
408
|
type OpenAIResponsesInputItem = OpenAIResponsesSystemMessage | OpenAIResponsesUserMessage | OpenAIResponsesAssistantMessage | OpenAIResponsesFunctionCall | OpenAIResponsesFunctionCallOutput | OpenAIResponsesProgram | OpenAIResponsesProgramOutput | OpenAIResponsesCustomToolCall | OpenAIResponsesCustomToolCallOutput | OpenAIResponsesMcpApprovalResponse | OpenAIResponsesComputerCall | OpenAIResponsesComputerCallOutput | OpenAIResponsesLocalShellCall | OpenAIResponsesLocalShellCallOutput | OpenAIResponsesShellCall | OpenAIResponsesShellCallOutput | OpenAIResponsesApplyPatchCall | OpenAIResponsesApplyPatchCallOutput | OpenAIResponsesToolSearchCall | OpenAIResponsesToolSearchOutput | OpenAIResponsesReasoning | OpenAIResponsesItemReference | OpenAIResponsesCompactionItem | OpenAIResponsesCompactionTrigger;
|
|
395
409
|
type OpenAIResponsesIncludeValue = 'web_search_call.action.sources' | 'web_search_call.results' | 'code_interpreter_call.outputs' | 'computer_call_output.output.image_url' | 'file_search_call.results' | 'message.input_image.image_url' | 'message.output_text.logprobs' | 'reasoning.encrypted_content';
|
|
@@ -547,19 +561,7 @@ type OpenAIResponsesComputerCallOutput = {
|
|
|
547
561
|
message?: string;
|
|
548
562
|
}>;
|
|
549
563
|
};
|
|
550
|
-
type OpenAIResponsesLocalShellCall =
|
|
551
|
-
type: 'local_shell_call';
|
|
552
|
-
id: string;
|
|
553
|
-
call_id: string;
|
|
554
|
-
action: {
|
|
555
|
-
type: 'exec';
|
|
556
|
-
command: string[];
|
|
557
|
-
timeout_ms?: number;
|
|
558
|
-
user?: string;
|
|
559
|
-
working_directory?: string;
|
|
560
|
-
env?: Record<string, string>;
|
|
561
|
-
};
|
|
562
|
-
};
|
|
564
|
+
type OpenAIResponsesLocalShellCall = InferSchema<typeof openaiResponsesLocalShellCallSchema>;
|
|
563
565
|
type OpenAIResponsesLocalShellCallOutput = {
|
|
564
566
|
type: 'local_shell_call_output';
|
|
565
567
|
call_id: string;
|
|
@@ -1058,6 +1060,18 @@ declare const openaiResponsesChunkSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
1058
1060
|
code?: string | null | undefined;
|
|
1059
1061
|
message?: string | null | undefined;
|
|
1060
1062
|
}[] | null | undefined;
|
|
1063
|
+
} | {
|
|
1064
|
+
type: "local_shell_call";
|
|
1065
|
+
id: string;
|
|
1066
|
+
call_id: string;
|
|
1067
|
+
action: {
|
|
1068
|
+
type: "exec";
|
|
1069
|
+
command: string[];
|
|
1070
|
+
timeout_ms?: number | undefined;
|
|
1071
|
+
user?: string | undefined;
|
|
1072
|
+
working_directory?: string | undefined;
|
|
1073
|
+
env?: Record<string, string> | undefined;
|
|
1074
|
+
};
|
|
1061
1075
|
} | {
|
|
1062
1076
|
type: "message";
|
|
1063
1077
|
id: string;
|
|
@@ -1285,6 +1299,18 @@ declare const openaiResponsesChunkSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
1285
1299
|
code?: string | null | undefined;
|
|
1286
1300
|
message?: string | null | undefined;
|
|
1287
1301
|
}[] | null | undefined;
|
|
1302
|
+
} | {
|
|
1303
|
+
type: "local_shell_call";
|
|
1304
|
+
id: string;
|
|
1305
|
+
call_id: string;
|
|
1306
|
+
action: {
|
|
1307
|
+
type: "exec";
|
|
1308
|
+
command: string[];
|
|
1309
|
+
timeout_ms?: number | undefined;
|
|
1310
|
+
user?: string | undefined;
|
|
1311
|
+
working_directory?: string | undefined;
|
|
1312
|
+
env?: Record<string, string> | undefined;
|
|
1313
|
+
};
|
|
1288
1314
|
} | {
|
|
1289
1315
|
type: "program";
|
|
1290
1316
|
id: string;
|
|
@@ -1376,18 +1402,6 @@ declare const openaiResponsesChunkSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
1376
1402
|
score: number;
|
|
1377
1403
|
text: string;
|
|
1378
1404
|
}[] | null | undefined;
|
|
1379
|
-
} | {
|
|
1380
|
-
type: "local_shell_call";
|
|
1381
|
-
id: string;
|
|
1382
|
-
call_id: string;
|
|
1383
|
-
action: {
|
|
1384
|
-
type: "exec";
|
|
1385
|
-
command: string[];
|
|
1386
|
-
timeout_ms?: number | undefined;
|
|
1387
|
-
user?: string | undefined;
|
|
1388
|
-
working_directory?: string | undefined;
|
|
1389
|
-
env?: Record<string, string> | undefined;
|
|
1390
|
-
};
|
|
1391
1405
|
} | {
|
|
1392
1406
|
type: "mcp_call";
|
|
1393
1407
|
id: string;
|
|
@@ -1490,6 +1504,11 @@ declare const openaiResponsesChunkSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
1490
1504
|
item_id: string;
|
|
1491
1505
|
output_index: number;
|
|
1492
1506
|
delta: string;
|
|
1507
|
+
} | {
|
|
1508
|
+
type: "response.function_call_arguments.done";
|
|
1509
|
+
item_id: string;
|
|
1510
|
+
output_index: number;
|
|
1511
|
+
arguments: string;
|
|
1493
1512
|
} | {
|
|
1494
1513
|
type: "response.custom_tool_call_input.delta";
|
|
1495
1514
|
item_id: string;
|