@ai-sdk/openai 3.0.47 → 3.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 +37 -22
- package/dist/index.d.mts +24 -2
- package/dist/index.d.ts +24 -2
- package/dist/index.js +52 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +52 -7
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +24 -2
- package/dist/internal/index.d.ts +24 -2
- package/dist/internal/index.js +51 -6
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +51 -6
- package/dist/internal/index.mjs.map +1 -1
- package/docs/03-openai.mdx +2 -0
- package/package.json +3 -5
- package/src/chat/openai-chat-options.ts +4 -0
- package/src/openai-language-model-capabilities.ts +2 -2
- package/src/responses/convert-to-openai-responses-input.ts +12 -0
- package/src/responses/openai-responses-api.ts +26 -0
- package/src/responses/openai-responses-language-model.ts +19 -0
- package/src/responses/openai-responses-options.ts +8 -0
package/docs/03-openai.mdx
CHANGED
|
@@ -2182,6 +2182,8 @@ The following optional provider options are available for OpenAI completion mode
|
|
|
2182
2182
|
| --------------------- | ------------------- | ------------------- | ------------------- | ------------------- |
|
|
2183
2183
|
| `gpt-5.4-pro` | <Check size={18} /> | <Cross size={18} /> | <Check size={18} /> | <Check size={18} /> |
|
|
2184
2184
|
| `gpt-5.4` | <Check size={18} /> | <Cross size={18} /> | <Check size={18} /> | <Check size={18} /> |
|
|
2185
|
+
| `gpt-5.4-mini` | <Check size={18} /> | <Cross size={18} /> | <Check size={18} /> | <Check size={18} /> |
|
|
2186
|
+
| `gpt-5.4-nano` | <Check size={18} /> | <Cross size={18} /> | <Check size={18} /> | <Check size={18} /> |
|
|
2185
2187
|
| `gpt-5.3-chat-latest` | <Check size={18} /> | <Cross size={18} /> | <Check size={18} /> | <Check size={18} /> |
|
|
2186
2188
|
| `gpt-5.2-pro` | <Check size={18} /> | <Cross size={18} /> | <Check size={18} /> | <Check size={18} /> |
|
|
2187
2189
|
| `gpt-5.2-chat-latest` | <Check size={18} /> | <Cross size={18} /> | <Check size={18} /> | <Check size={18} /> |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/openai",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.49",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -44,8 +44,8 @@
|
|
|
44
44
|
"tsup": "^8",
|
|
45
45
|
"typescript": "5.8.3",
|
|
46
46
|
"zod": "3.25.76",
|
|
47
|
-
"@ai-
|
|
48
|
-
"@
|
|
47
|
+
"@vercel/ai-tsconfig": "0.0.0",
|
|
48
|
+
"@ai-sdk/test-server": "1.0.3"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
51
|
"zod": "^3.25.76 || ^4.1.8"
|
|
@@ -71,9 +71,7 @@
|
|
|
71
71
|
"build": "pnpm clean && tsup --tsconfig tsconfig.build.json",
|
|
72
72
|
"build:watch": "pnpm clean && tsup --watch",
|
|
73
73
|
"clean": "del-cli dist docs *.tsbuildinfo",
|
|
74
|
-
"lint": "eslint \"./**/*.ts*\"",
|
|
75
74
|
"type-check": "tsc --build",
|
|
76
|
-
"prettier-check": "prettier --check \"./**/*.ts*\"",
|
|
77
75
|
"test": "pnpm test:node && pnpm test:edge",
|
|
78
76
|
"test:update": "pnpm test:node -u",
|
|
79
77
|
"test:watch": "vitest --config vitest.node.config.js",
|
|
@@ -54,6 +54,10 @@ export type OpenAIChatModelId =
|
|
|
54
54
|
| 'gpt-5.3-chat-latest'
|
|
55
55
|
| 'gpt-5.4'
|
|
56
56
|
| 'gpt-5.4-2026-03-05'
|
|
57
|
+
| 'gpt-5.4-mini'
|
|
58
|
+
| 'gpt-5.4-mini-2026-03-17'
|
|
59
|
+
| 'gpt-5.4-nano'
|
|
60
|
+
| 'gpt-5.4-nano-2026-03-17'
|
|
57
61
|
| 'gpt-5.4-pro'
|
|
58
62
|
| 'gpt-5.4-pro-2026-03-05'
|
|
59
63
|
| (string & {});
|
|
@@ -20,10 +20,10 @@ export function getOpenAILanguageModelCapabilities(
|
|
|
20
20
|
|
|
21
21
|
const supportsPriorityProcessing =
|
|
22
22
|
modelId.startsWith('gpt-4') ||
|
|
23
|
-
modelId.startsWith('gpt-5-mini') ||
|
|
24
23
|
(modelId.startsWith('gpt-5') &&
|
|
25
24
|
!modelId.startsWith('gpt-5-nano') &&
|
|
26
|
-
!modelId.startsWith('gpt-5-chat')
|
|
25
|
+
!modelId.startsWith('gpt-5-chat') &&
|
|
26
|
+
!modelId.startsWith('gpt-5.4-nano')) ||
|
|
27
27
|
modelId.startsWith('o3') ||
|
|
28
28
|
modelId.startsWith('o4-mini');
|
|
29
29
|
|
|
@@ -709,6 +709,11 @@ export async function convertToOpenAIResponsesInput({
|
|
|
709
709
|
filename: item.filename ?? 'data',
|
|
710
710
|
file_data: `data:${item.mediaType};base64,${item.data}`,
|
|
711
711
|
};
|
|
712
|
+
case 'file-url':
|
|
713
|
+
return {
|
|
714
|
+
type: 'input_file' as const,
|
|
715
|
+
file_url: item.url,
|
|
716
|
+
};
|
|
712
717
|
default:
|
|
713
718
|
warnings.push({
|
|
714
719
|
type: 'other',
|
|
@@ -773,6 +778,13 @@ export async function convertToOpenAIResponsesInput({
|
|
|
773
778
|
};
|
|
774
779
|
}
|
|
775
780
|
|
|
781
|
+
case 'file-url': {
|
|
782
|
+
return {
|
|
783
|
+
type: 'input_file' as const,
|
|
784
|
+
file_url: item.url,
|
|
785
|
+
};
|
|
786
|
+
}
|
|
787
|
+
|
|
776
788
|
default: {
|
|
777
789
|
warnings.push({
|
|
778
790
|
type: 'other',
|
|
@@ -106,6 +106,7 @@ export type OpenAIResponsesFunctionCallOutput = {
|
|
|
106
106
|
| { type: 'input_text'; text: string }
|
|
107
107
|
| { type: 'input_image'; image_url: string }
|
|
108
108
|
| { type: 'input_file'; filename: string; file_data: string }
|
|
109
|
+
| { type: 'input_file'; file_url: string }
|
|
109
110
|
>;
|
|
110
111
|
};
|
|
111
112
|
|
|
@@ -496,6 +497,31 @@ export const openaiResponsesChunkSchema = lazySchema(() =>
|
|
|
496
497
|
service_tier: z.string().nullish(),
|
|
497
498
|
}),
|
|
498
499
|
}),
|
|
500
|
+
z.object({
|
|
501
|
+
type: z.literal('response.failed'),
|
|
502
|
+
response: z.object({
|
|
503
|
+
error: z
|
|
504
|
+
.object({
|
|
505
|
+
code: z.string().nullish(),
|
|
506
|
+
message: z.string(),
|
|
507
|
+
})
|
|
508
|
+
.nullish(),
|
|
509
|
+
incomplete_details: z.object({ reason: z.string() }).nullish(),
|
|
510
|
+
usage: z
|
|
511
|
+
.object({
|
|
512
|
+
input_tokens: z.number(),
|
|
513
|
+
input_tokens_details: z
|
|
514
|
+
.object({ cached_tokens: z.number().nullish() })
|
|
515
|
+
.nullish(),
|
|
516
|
+
output_tokens: z.number(),
|
|
517
|
+
output_tokens_details: z
|
|
518
|
+
.object({ reasoning_tokens: z.number().nullish() })
|
|
519
|
+
.nullish(),
|
|
520
|
+
})
|
|
521
|
+
.nullish(),
|
|
522
|
+
service_tier: z.string().nullish(),
|
|
523
|
+
}),
|
|
524
|
+
}),
|
|
499
525
|
z.object({
|
|
500
526
|
type: z.literal('response.created'),
|
|
501
527
|
response: z.object({
|
|
@@ -2006,6 +2006,19 @@ export class OpenAIResponsesLanguageModel implements LanguageModelV3 {
|
|
|
2006
2006
|
if (typeof value.response.service_tier === 'string') {
|
|
2007
2007
|
serviceTier = value.response.service_tier;
|
|
2008
2008
|
}
|
|
2009
|
+
} else if (isResponseFailedChunk(value)) {
|
|
2010
|
+
const incompleteReason =
|
|
2011
|
+
value.response.incomplete_details?.reason;
|
|
2012
|
+
finishReason = {
|
|
2013
|
+
unified: incompleteReason
|
|
2014
|
+
? mapOpenAIResponseFinishReason({
|
|
2015
|
+
finishReason: incompleteReason,
|
|
2016
|
+
hasFunctionCall,
|
|
2017
|
+
})
|
|
2018
|
+
: 'error',
|
|
2019
|
+
raw: incompleteReason ?? 'error',
|
|
2020
|
+
};
|
|
2021
|
+
usage = value.response.usage ?? undefined;
|
|
2009
2022
|
} else if (isResponseAnnotationAddedChunk(value)) {
|
|
2010
2023
|
ongoingAnnotations.push(value.annotation);
|
|
2011
2024
|
if (value.annotation.type === 'url_citation') {
|
|
@@ -2125,6 +2138,12 @@ function isResponseFinishedChunk(
|
|
|
2125
2138
|
);
|
|
2126
2139
|
}
|
|
2127
2140
|
|
|
2141
|
+
function isResponseFailedChunk(
|
|
2142
|
+
chunk: OpenAIResponsesChunk,
|
|
2143
|
+
): chunk is OpenAIResponsesChunk & { type: 'response.failed' } {
|
|
2144
|
+
return chunk.type === 'response.failed';
|
|
2145
|
+
}
|
|
2146
|
+
|
|
2128
2147
|
function isResponseCreatedChunk(
|
|
2129
2148
|
chunk: OpenAIResponsesChunk,
|
|
2130
2149
|
): chunk is OpenAIResponsesChunk & { type: 'response.created' } {
|
|
@@ -41,6 +41,10 @@ export const openaiResponsesReasoningModelIds = [
|
|
|
41
41
|
'gpt-5.3-codex',
|
|
42
42
|
'gpt-5.4',
|
|
43
43
|
'gpt-5.4-2026-03-05',
|
|
44
|
+
'gpt-5.4-mini',
|
|
45
|
+
'gpt-5.4-mini-2026-03-17',
|
|
46
|
+
'gpt-5.4-nano',
|
|
47
|
+
'gpt-5.4-nano-2026-03-17',
|
|
44
48
|
'gpt-5.4-pro',
|
|
45
49
|
'gpt-5.4-pro-2026-03-05',
|
|
46
50
|
] as const;
|
|
@@ -103,6 +107,10 @@ export type OpenAIResponsesModelId =
|
|
|
103
107
|
| 'gpt-5.3-codex'
|
|
104
108
|
| 'gpt-5.4'
|
|
105
109
|
| 'gpt-5.4-2026-03-05'
|
|
110
|
+
| 'gpt-5.4-mini'
|
|
111
|
+
| 'gpt-5.4-mini-2026-03-17'
|
|
112
|
+
| 'gpt-5.4-nano'
|
|
113
|
+
| 'gpt-5.4-nano-2026-03-17'
|
|
106
114
|
| 'gpt-5.4-pro'
|
|
107
115
|
| 'gpt-5.4-pro-2026-03-05'
|
|
108
116
|
| 'gpt-5-2025-08-07'
|