@ai-sdk/openai 4.0.0-canary.73 → 4.0.0
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 +193 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +32 -10
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +6 -0
- package/dist/internal/index.js +31 -9
- package/dist/internal/index.js.map +1 -1
- package/docs/03-openai.mdx +1 -1
- package/package.json +4 -4
- package/src/responses/convert-openai-responses-usage.ts +3 -0
- package/src/responses/openai-responses-api.ts +27 -6
- package/src/responses/openai-responses-language-model.ts +9 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,198 @@
|
|
|
1
1
|
# @ai-sdk/openai
|
|
2
2
|
|
|
3
|
+
## 4.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- 34bd95d: feat(ai): add support for uploading provider skills using the provider references abstraction
|
|
8
|
+
- ef992f8: Remove CommonJS exports from all packages. All packages are now ESM-only (`"type": "module"`). Consumers using `require()` must switch to ESM `import` syntax.
|
|
9
|
+
- c29a26f: feat(provider): add support for provider references and uploading files as supported per provider
|
|
10
|
+
- 3887c70: feat(provider): add new top-level reasoning parameter to spec and support it in `generateText` and `streamText`
|
|
11
|
+
- 61753c3: ### `@ai-sdk/openai`: remove redundant `name` argument from `openai.tools.customTool()`
|
|
12
|
+
|
|
13
|
+
`openai.tools.customTool()` no longer accepts a `name` field. the tool name is now derived from the sdk tool key (the object key in the `tools` object).
|
|
14
|
+
|
|
15
|
+
migration: remove the `name` property from `customTool()` calls. the object key is now used as the tool name sent to the openai api.
|
|
16
|
+
|
|
17
|
+
before:
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
tools: {
|
|
21
|
+
write_sql: openai.tools.customTool({
|
|
22
|
+
name: 'write_sql',
|
|
23
|
+
description: '...',
|
|
24
|
+
}),
|
|
25
|
+
}
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
after:
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
tools: {
|
|
32
|
+
write_sql: openai.tools.customTool({
|
|
33
|
+
description: '...',
|
|
34
|
+
}),
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### `@ai-sdk/provider-utils`: `createToolNameMapping()` no longer accepts the `resolveProviderToolName` parameter
|
|
39
|
+
|
|
40
|
+
before: tool name can be set dynamically
|
|
41
|
+
|
|
42
|
+
```ts
|
|
43
|
+
const toolNameMapping = createToolNameMapping({
|
|
44
|
+
tools,
|
|
45
|
+
providerToolNames: {
|
|
46
|
+
"openai.code_interpreter": "code_interpreter",
|
|
47
|
+
"openai.file_search": "file_search",
|
|
48
|
+
"openai.image_generation": "image_generation",
|
|
49
|
+
"openai.local_shell": "local_shell",
|
|
50
|
+
"openai.shell": "shell",
|
|
51
|
+
"openai.web_search": "web_search",
|
|
52
|
+
"openai.web_search_preview": "web_search_preview",
|
|
53
|
+
"openai.mcp": "mcp",
|
|
54
|
+
"openai.apply_patch": "apply_patch",
|
|
55
|
+
},
|
|
56
|
+
resolveProviderToolName: (tool) =>
|
|
57
|
+
tool.id === "openai.custom"
|
|
58
|
+
? (tool.args as { name?: string }).name
|
|
59
|
+
: undefined,
|
|
60
|
+
});
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
after: tool name is static based on `tools` keys
|
|
64
|
+
|
|
65
|
+
```
|
|
66
|
+
const toolNameMapping = createToolNameMapping({
|
|
67
|
+
tools,
|
|
68
|
+
providerToolNames: {
|
|
69
|
+
'openai.code_interpreter': 'code_interpreter',
|
|
70
|
+
'openai.file_search': 'file_search',
|
|
71
|
+
'openai.image_generation': 'image_generation',
|
|
72
|
+
'openai.local_shell': 'local_shell',
|
|
73
|
+
'openai.shell': 'shell',
|
|
74
|
+
'openai.web_search': 'web_search',
|
|
75
|
+
'openai.web_search_preview': 'web_search_preview',
|
|
76
|
+
'openai.mcp': 'mcp',
|
|
77
|
+
'openai.apply_patch': 'apply_patch',
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
- 8359612: Start v7 pre-release
|
|
83
|
+
- 04e9009: chore: make provider implementations code patterns more consistent, including renaming certain exported symbols
|
|
84
|
+
|
|
85
|
+
For all externally exported symbols that were renamed, the old names continue to work via deprecated aliases.
|
|
86
|
+
|
|
87
|
+
### Patch Changes
|
|
88
|
+
|
|
89
|
+
- 29e6ac6: feat: add allowedTools provider option for OpenAI Responses
|
|
90
|
+
- 38fc777: Add AI Gateway hint to provider READMEs
|
|
91
|
+
- a71d345: fix(provider/openai): drop reasoning parts without encrypted content when store: false
|
|
92
|
+
- 7afaece: feat(provider/openai): add GPT-5.4 model support
|
|
93
|
+
- 365da1a: Add `gpt-5.4-mini`, `gpt-5.4-mini-2026-03-17`, `gpt-5.4-nano`, and `gpt-5.4-nano-2026-03-17` models.
|
|
94
|
+
- 1772a63: Default OpenAI Responses reasoning summaries to detailed when reasoning effort is enabled.
|
|
95
|
+
- 83f9d04: feat(openai): upgrade v3 specs to v4
|
|
96
|
+
- 45b3d76: fix(security): prevent streaming tool calls from finalizing on parsable partial JSON
|
|
97
|
+
|
|
98
|
+
Streaming tool call arguments were finalized using `isParsableJson()` as a heuristic for completion. If partial accumulated JSON happened to be valid JSON before all chunks arrived, the tool call would be executed with incomplete arguments. Tool call finalization now only occurs in `flush()` after the stream is fully consumed.
|
|
99
|
+
|
|
100
|
+
- bf837fe: feat(provider/gateway): add speech and transcription model support
|
|
101
|
+
- d6c79e3: feat(openai): add GPT-5.5 chat model IDs
|
|
102
|
+
- e776fc7: feat(provider/azure):web search tool in the Azure OpenAI Responses API.
|
|
103
|
+
- 817a1a6: fix(openai): support file-url parts in tool output content
|
|
104
|
+
- 1f509d4: fix(ai): force template check on 'kind' param
|
|
105
|
+
- 0c4ac8a: fix(openai): default undefined tool-call input to empty object before serializing tool arguments
|
|
106
|
+
- 9f0e36c: trigger release for all packages after provenance setup
|
|
107
|
+
- 58a2ad7: fix: more precise default message for tool execution denial
|
|
108
|
+
- 6a5800e: feat(openai): add namespaces for tool definitions
|
|
109
|
+
- ae7f932: fix(openai): throw retryable errors for OpenAI stream failures before output starts
|
|
110
|
+
- 2c4767d: feat(openai): add orchestration token usage details to Responses API usage
|
|
111
|
+
- bada0f3: feat(openai): preserve `namespace` on function_call output items
|
|
112
|
+
- cd3de8b: feat(openai): forward `web_search_call.action.queries` from Responses API
|
|
113
|
+
- 94eba1b: fix(openai): round-trip `namespace` on function_call input items
|
|
114
|
+
|
|
115
|
+
When `tool_search` dispatches a deferred tool, the resulting `function_call` carries a `namespace` field identifying which deferred-tool group the model picked. `#14789` preserved this on the read side (`providerMetadata.openai.namespace`), but the write side still serialized `function_call` input items without `namespace`. Multi-step / multi-turn conversations then failed with `Missing namespace for function_call '<name>'. ... Round-trip the model's function_call item with its namespace field included.`
|
|
116
|
+
|
|
117
|
+
`convert-to-openai-responses-input.ts` now reads `namespace` from `providerOptions.openai.namespace` (or `providerMetadata.openai.namespace`) on `tool-call` parts and includes it on the serialized `function_call` item, mirroring how `itemId` is round-tripped.
|
|
118
|
+
|
|
119
|
+
- 7bbc194: feat(provider/openai): forward imageDetail providerOptions on tool-result image content
|
|
120
|
+
- 156cdf0: feat(openai): add new tool search tool
|
|
121
|
+
- f7295cb: revert incorrect fix https://github.com/vercel/ai/pull/13172
|
|
122
|
+
- 9ea40e0: chore(provider/openai): add type for image model options for type-safe processing
|
|
123
|
+
- 7fc6bd6: Raise minimum supported Node.js version to 22. Supported versions: 22, 24, and 26.
|
|
124
|
+
- f807e45: Extract shared `StreamingToolCallTracker` class into `@ai-sdk/provider-utils` to deduplicate streaming tool call handling across OpenAI-compatible providers. Also adds missing `generateId()` fallback for `toolCallId` in Alibaba's `doGenerate` path and ensures all providers finalize unfinished tool calls during stream flush.
|
|
125
|
+
- d9a1e9a: feat(openai): add server side compaction for openai
|
|
126
|
+
- 0c4c275: trigger initial canary release
|
|
127
|
+
- ac18f89: feat(provider/openai): add `gpt-5.3-chat-latest`
|
|
128
|
+
- 6fd51c0: fix(provider): preserve error type prefix in getErrorMessage
|
|
129
|
+
- cd9c311: fix(openai, openai-compatible): only send null content for assistant messages with tool calls
|
|
130
|
+
- e6376c2: fix(openai): preserve raw finish reason for failed responses stream events
|
|
131
|
+
|
|
132
|
+
Handle `response.failed` chunks in Responses API streaming so `finishReason.raw` is preserved from `incomplete_details.reason` (e.g. `max_output_tokens`), and map failed-without-reason cases to unified `error` instead of `other`.
|
|
133
|
+
|
|
134
|
+
- ce769dd: feat(provider): add experimental Realtime API support for voice conversations
|
|
135
|
+
|
|
136
|
+
Adds first-class support for realtime (speech-to-speech) APIs:
|
|
137
|
+
|
|
138
|
+
- `Experimental_RealtimeModelV4` spec in `@ai-sdk/provider` with normalized event types and factory
|
|
139
|
+
- OpenAI, Google, and xAI realtime provider implementations
|
|
140
|
+
- `openai.experimental_realtime()` / `google.experimental_realtime()` / `xai.experimental_realtime()` work in both server and browser
|
|
141
|
+
- `.getToken()` static method on each provider for server-side ephemeral token creation
|
|
142
|
+
- `experimental_getRealtimeToolDefinitions` helper for provider session tool definitions
|
|
143
|
+
- `experimental_useRealtime` hook in `@ai-sdk/react` returning `UIMessage[]` (aligned with `useChat`), with `onToolCall` and `addToolOutput` for client-driven tool execution
|
|
144
|
+
- `inputAudioTranscription` session config for showing transcribed user audio messages when supported by the provider
|
|
145
|
+
|
|
146
|
+
- e311194: feat(ai): allow passing provider instance to `uploadFile` and `uploadSkill` as shorthand
|
|
147
|
+
- 9bd6512: feat(provider): change file part data property to be tagged with a type and remove the image part type
|
|
148
|
+
- 258c093: chore: ensure consistent import handling and avoid import duplicates or cycles
|
|
149
|
+
- 685cec7: feat(openai): add opt-in pass-through for unsupported file media types
|
|
150
|
+
- 61bcdb5: fix(provider/openai): send client-executed tool calls as full function_call items in the Responses API so they pair with their function_call_output by call_id
|
|
151
|
+
- 5463d0d: feat(provider): align tool result output content file part types with top-level message file part types
|
|
152
|
+
- b8396f0: trigger initial beta release
|
|
153
|
+
- bfb756d: patch - send content: null instead of empty string for tool-only assistant messages
|
|
154
|
+
- 90e2d8a: chore: fix unused vars not being flagged by our lint tooling
|
|
155
|
+
- 17b5597: fix(openai): skip passing reasoning items when using previous response id
|
|
156
|
+
- b3976a2: Add workflow serialization support to all provider models.
|
|
157
|
+
|
|
158
|
+
**`@ai-sdk/provider-utils`:** New `serializeModel()` helper that extracts only serializable properties from a model instance, filtering out functions and objects containing functions. Third-party provider authors can use this to add workflow support to their own models.
|
|
159
|
+
|
|
160
|
+
**All providers:** `headers` is now optional in provider config types. This is non-breaking — existing code that passes `headers` continues to work. Custom provider implementations that construct model configs manually can now omit `headers`, which is useful when models are deserialized from a workflow step boundary where auth is provided separately.
|
|
161
|
+
|
|
162
|
+
All provider model classes now include `WORKFLOW_SERIALIZE` and `WORKFLOW_DESERIALIZE` static methods, enabling them to cross workflow step boundaries without serialization errors.
|
|
163
|
+
|
|
164
|
+
- ff5eba1: feat: roll `image-*` tool output types into their equivalent `file-*` types
|
|
165
|
+
- f9acbc0: feat(provider/openai): add gpt-image-2 model support
|
|
166
|
+
|
|
167
|
+
## 4.0.0-beta.77
|
|
168
|
+
|
|
169
|
+
### Patch Changes
|
|
170
|
+
|
|
171
|
+
- Updated dependencies [0416e3e]
|
|
172
|
+
- @ai-sdk/provider@4.0.0-beta.20
|
|
173
|
+
- @ai-sdk/provider-utils@5.0.0-beta.50
|
|
174
|
+
|
|
175
|
+
## 4.0.0-beta.76
|
|
176
|
+
|
|
177
|
+
### Patch Changes
|
|
178
|
+
|
|
179
|
+
- 2c4767d: feat(openai): add orchestration token usage details to Responses API usage
|
|
180
|
+
|
|
181
|
+
## 4.0.0-beta.75
|
|
182
|
+
|
|
183
|
+
### Patch Changes
|
|
184
|
+
|
|
185
|
+
- 1772a63: Default OpenAI Responses reasoning summaries to detailed when reasoning effort is enabled.
|
|
186
|
+
|
|
187
|
+
## 4.0.0-beta.74
|
|
188
|
+
|
|
189
|
+
### Patch Changes
|
|
190
|
+
|
|
191
|
+
- b8396f0: trigger initial beta release
|
|
192
|
+
- Updated dependencies [b8396f0]
|
|
193
|
+
- @ai-sdk/provider-utils@5.0.0-beta.49
|
|
194
|
+
- @ai-sdk/provider@4.0.0-beta.19
|
|
195
|
+
|
|
3
196
|
## 4.0.0-canary.73
|
|
4
197
|
|
|
5
198
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -244,9 +244,12 @@ declare const openaiResponsesChunkSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
244
244
|
output_tokens: number;
|
|
245
245
|
input_tokens_details?: {
|
|
246
246
|
cached_tokens?: number | null | undefined;
|
|
247
|
+
orchestration_input_tokens?: number | null | undefined;
|
|
248
|
+
orchestration_input_cached_tokens?: number | null | undefined;
|
|
247
249
|
} | null | undefined;
|
|
248
250
|
output_tokens_details?: {
|
|
249
251
|
reasoning_tokens?: number | null | undefined;
|
|
252
|
+
orchestration_output_tokens?: number | null | undefined;
|
|
250
253
|
} | null | undefined;
|
|
251
254
|
};
|
|
252
255
|
incomplete_details?: {
|
|
@@ -270,9 +273,12 @@ declare const openaiResponsesChunkSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
270
273
|
output_tokens: number;
|
|
271
274
|
input_tokens_details?: {
|
|
272
275
|
cached_tokens?: number | null | undefined;
|
|
276
|
+
orchestration_input_tokens?: number | null | undefined;
|
|
277
|
+
orchestration_input_cached_tokens?: number | null | undefined;
|
|
273
278
|
} | null | undefined;
|
|
274
279
|
output_tokens_details?: {
|
|
275
280
|
reasoning_tokens?: number | null | undefined;
|
|
281
|
+
orchestration_output_tokens?: number | null | undefined;
|
|
276
282
|
} | null | undefined;
|
|
277
283
|
} | null | undefined;
|
|
278
284
|
service_tier?: string | null | undefined;
|
package/dist/index.js
CHANGED
|
@@ -4260,9 +4260,16 @@ var openaiResponsesChunkSchema = lazySchema22(
|
|
|
4260
4260
|
incomplete_details: z24.object({ reason: z24.string() }).nullish(),
|
|
4261
4261
|
usage: z24.object({
|
|
4262
4262
|
input_tokens: z24.number(),
|
|
4263
|
-
input_tokens_details: z24.object({
|
|
4263
|
+
input_tokens_details: z24.object({
|
|
4264
|
+
cached_tokens: z24.number().nullish(),
|
|
4265
|
+
orchestration_input_tokens: z24.number().nullish(),
|
|
4266
|
+
orchestration_input_cached_tokens: z24.number().nullish()
|
|
4267
|
+
}).nullish(),
|
|
4264
4268
|
output_tokens: z24.number(),
|
|
4265
|
-
output_tokens_details: z24.object({
|
|
4269
|
+
output_tokens_details: z24.object({
|
|
4270
|
+
reasoning_tokens: z24.number().nullish(),
|
|
4271
|
+
orchestration_output_tokens: z24.number().nullish()
|
|
4272
|
+
}).nullish()
|
|
4266
4273
|
}),
|
|
4267
4274
|
service_tier: z24.string().nullish()
|
|
4268
4275
|
})
|
|
@@ -4278,9 +4285,16 @@ var openaiResponsesChunkSchema = lazySchema22(
|
|
|
4278
4285
|
incomplete_details: z24.object({ reason: z24.string() }).nullish(),
|
|
4279
4286
|
usage: z24.object({
|
|
4280
4287
|
input_tokens: z24.number(),
|
|
4281
|
-
input_tokens_details: z24.object({
|
|
4288
|
+
input_tokens_details: z24.object({
|
|
4289
|
+
cached_tokens: z24.number().nullish(),
|
|
4290
|
+
orchestration_input_tokens: z24.number().nullish(),
|
|
4291
|
+
orchestration_input_cached_tokens: z24.number().nullish()
|
|
4292
|
+
}).nullish(),
|
|
4282
4293
|
output_tokens: z24.number(),
|
|
4283
|
-
output_tokens_details: z24.object({
|
|
4294
|
+
output_tokens_details: z24.object({
|
|
4295
|
+
reasoning_tokens: z24.number().nullish(),
|
|
4296
|
+
orchestration_output_tokens: z24.number().nullish()
|
|
4297
|
+
}).nullish()
|
|
4284
4298
|
}).nullish(),
|
|
4285
4299
|
service_tier: z24.string().nullish()
|
|
4286
4300
|
})
|
|
@@ -5071,9 +5085,16 @@ var openaiResponsesResponseSchema = lazySchema22(
|
|
|
5071
5085
|
incomplete_details: z24.object({ reason: z24.string() }).nullish(),
|
|
5072
5086
|
usage: z24.object({
|
|
5073
5087
|
input_tokens: z24.number(),
|
|
5074
|
-
input_tokens_details: z24.object({
|
|
5088
|
+
input_tokens_details: z24.object({
|
|
5089
|
+
cached_tokens: z24.number().nullish(),
|
|
5090
|
+
orchestration_input_tokens: z24.number().nullish(),
|
|
5091
|
+
orchestration_input_cached_tokens: z24.number().nullish()
|
|
5092
|
+
}).nullish(),
|
|
5075
5093
|
output_tokens: z24.number(),
|
|
5076
|
-
output_tokens_details: z24.object({
|
|
5094
|
+
output_tokens_details: z24.object({
|
|
5095
|
+
reasoning_tokens: z24.number().nullish(),
|
|
5096
|
+
orchestration_output_tokens: z24.number().nullish()
|
|
5097
|
+
}).nullish()
|
|
5077
5098
|
}).optional()
|
|
5078
5099
|
})
|
|
5079
5100
|
)
|
|
@@ -5755,6 +5776,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
5755
5776
|
});
|
|
5756
5777
|
}
|
|
5757
5778
|
const resolvedReasoningEffort = (_a = openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null ? _a : isCustomReasoning2(reasoning) ? reasoning : void 0;
|
|
5779
|
+
const resolvedReasoningSummary = (openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) !== void 0 ? openaiOptions.reasoningSummary : resolvedReasoningEffort != null && resolvedReasoningEffort !== "none" ? "detailed" : void 0;
|
|
5758
5780
|
const isReasoningModel = (_b = openaiOptions == null ? void 0 : openaiOptions.forceReasoning) != null ? _b : modelCapabilities.isReasoningModel;
|
|
5759
5781
|
if ((openaiOptions == null ? void 0 : openaiOptions.conversation) && (openaiOptions == null ? void 0 : openaiOptions.previousResponseId)) {
|
|
5760
5782
|
warnings.push({
|
|
@@ -5881,13 +5903,13 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
5881
5903
|
}))
|
|
5882
5904
|
},
|
|
5883
5905
|
// model-specific settings:
|
|
5884
|
-
...isReasoningModel && (resolvedReasoningEffort != null ||
|
|
5906
|
+
...isReasoningModel && (resolvedReasoningEffort != null || resolvedReasoningSummary != null) && {
|
|
5885
5907
|
reasoning: {
|
|
5886
5908
|
...resolvedReasoningEffort != null && {
|
|
5887
5909
|
effort: resolvedReasoningEffort
|
|
5888
5910
|
},
|
|
5889
|
-
...
|
|
5890
|
-
summary:
|
|
5911
|
+
...resolvedReasoningSummary != null && {
|
|
5912
|
+
summary: resolvedReasoningSummary
|
|
5891
5913
|
}
|
|
5892
5914
|
}
|
|
5893
5915
|
}
|
|
@@ -7938,7 +7960,7 @@ var OpenAISkills = class {
|
|
|
7938
7960
|
};
|
|
7939
7961
|
|
|
7940
7962
|
// src/version.ts
|
|
7941
|
-
var VERSION = true ? "4.0.0
|
|
7963
|
+
var VERSION = true ? "4.0.0" : "0.0.0-test";
|
|
7942
7964
|
|
|
7943
7965
|
// src/openai-provider.ts
|
|
7944
7966
|
function createOpenAI(options = {}) {
|