@ai-sdk/openai 4.0.0-canary.73 → 4.0.1

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 CHANGED
@@ -1,5 +1,204 @@
1
1
  # @ai-sdk/openai
2
2
 
3
+ ## 4.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 9507724: feat(openai): add support for web_search_call.results include option
8
+
9
+ ## 4.0.0
10
+
11
+ ### Major Changes
12
+
13
+ - 34bd95d: feat(ai): add support for uploading provider skills using the provider references abstraction
14
+ - ef992f8: Remove CommonJS exports from all packages. All packages are now ESM-only (`"type": "module"`). Consumers using `require()` must switch to ESM `import` syntax.
15
+ - c29a26f: feat(provider): add support for provider references and uploading files as supported per provider
16
+ - 3887c70: feat(provider): add new top-level reasoning parameter to spec and support it in `generateText` and `streamText`
17
+ - 61753c3: ### `@ai-sdk/openai`: remove redundant `name` argument from `openai.tools.customTool()`
18
+
19
+ `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).
20
+
21
+ migration: remove the `name` property from `customTool()` calls. the object key is now used as the tool name sent to the openai api.
22
+
23
+ before:
24
+
25
+ ```ts
26
+ tools: {
27
+ write_sql: openai.tools.customTool({
28
+ name: 'write_sql',
29
+ description: '...',
30
+ }),
31
+ }
32
+ ```
33
+
34
+ after:
35
+
36
+ ```ts
37
+ tools: {
38
+ write_sql: openai.tools.customTool({
39
+ description: '...',
40
+ }),
41
+ }
42
+ ```
43
+
44
+ ### `@ai-sdk/provider-utils`: `createToolNameMapping()` no longer accepts the `resolveProviderToolName` parameter
45
+
46
+ before: tool name can be set dynamically
47
+
48
+ ```ts
49
+ const toolNameMapping = createToolNameMapping({
50
+ tools,
51
+ providerToolNames: {
52
+ "openai.code_interpreter": "code_interpreter",
53
+ "openai.file_search": "file_search",
54
+ "openai.image_generation": "image_generation",
55
+ "openai.local_shell": "local_shell",
56
+ "openai.shell": "shell",
57
+ "openai.web_search": "web_search",
58
+ "openai.web_search_preview": "web_search_preview",
59
+ "openai.mcp": "mcp",
60
+ "openai.apply_patch": "apply_patch",
61
+ },
62
+ resolveProviderToolName: (tool) =>
63
+ tool.id === "openai.custom"
64
+ ? (tool.args as { name?: string }).name
65
+ : undefined,
66
+ });
67
+ ```
68
+
69
+ after: tool name is static based on `tools` keys
70
+
71
+ ```
72
+ const toolNameMapping = createToolNameMapping({
73
+ tools,
74
+ providerToolNames: {
75
+ 'openai.code_interpreter': 'code_interpreter',
76
+ 'openai.file_search': 'file_search',
77
+ 'openai.image_generation': 'image_generation',
78
+ 'openai.local_shell': 'local_shell',
79
+ 'openai.shell': 'shell',
80
+ 'openai.web_search': 'web_search',
81
+ 'openai.web_search_preview': 'web_search_preview',
82
+ 'openai.mcp': 'mcp',
83
+ 'openai.apply_patch': 'apply_patch',
84
+ }
85
+ });
86
+ ```
87
+
88
+ - 8359612: Start v7 pre-release
89
+ - 04e9009: chore: make provider implementations code patterns more consistent, including renaming certain exported symbols
90
+
91
+ For all externally exported symbols that were renamed, the old names continue to work via deprecated aliases.
92
+
93
+ ### Patch Changes
94
+
95
+ - 29e6ac6: feat: add allowedTools provider option for OpenAI Responses
96
+ - 38fc777: Add AI Gateway hint to provider READMEs
97
+ - a71d345: fix(provider/openai): drop reasoning parts without encrypted content when store: false
98
+ - 7afaece: feat(provider/openai): add GPT-5.4 model support
99
+ - 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.
100
+ - 1772a63: Default OpenAI Responses reasoning summaries to detailed when reasoning effort is enabled.
101
+ - 83f9d04: feat(openai): upgrade v3 specs to v4
102
+ - 45b3d76: fix(security): prevent streaming tool calls from finalizing on parsable partial JSON
103
+
104
+ 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.
105
+
106
+ - bf837fe: feat(provider/gateway): add speech and transcription model support
107
+ - d6c79e3: feat(openai): add GPT-5.5 chat model IDs
108
+ - e776fc7: feat(provider/azure):web search tool in the Azure OpenAI Responses API.
109
+ - 817a1a6: fix(openai): support file-url parts in tool output content
110
+ - 1f509d4: fix(ai): force template check on 'kind' param
111
+ - 0c4ac8a: fix(openai): default undefined tool-call input to empty object before serializing tool arguments
112
+ - 9f0e36c: trigger release for all packages after provenance setup
113
+ - 58a2ad7: fix: more precise default message for tool execution denial
114
+ - 6a5800e: feat(openai): add namespaces for tool definitions
115
+ - ae7f932: fix(openai): throw retryable errors for OpenAI stream failures before output starts
116
+ - 2c4767d: feat(openai): add orchestration token usage details to Responses API usage
117
+ - bada0f3: feat(openai): preserve `namespace` on function_call output items
118
+ - cd3de8b: feat(openai): forward `web_search_call.action.queries` from Responses API
119
+ - 94eba1b: fix(openai): round-trip `namespace` on function_call input items
120
+
121
+ 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.`
122
+
123
+ `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.
124
+
125
+ - 7bbc194: feat(provider/openai): forward imageDetail providerOptions on tool-result image content
126
+ - 156cdf0: feat(openai): add new tool search tool
127
+ - f7295cb: revert incorrect fix https://github.com/vercel/ai/pull/13172
128
+ - 9ea40e0: chore(provider/openai): add type for image model options for type-safe processing
129
+ - 7fc6bd6: Raise minimum supported Node.js version to 22. Supported versions: 22, 24, and 26.
130
+ - 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.
131
+ - d9a1e9a: feat(openai): add server side compaction for openai
132
+ - 0c4c275: trigger initial canary release
133
+ - ac18f89: feat(provider/openai): add `gpt-5.3-chat-latest`
134
+ - 6fd51c0: fix(provider): preserve error type prefix in getErrorMessage
135
+ - cd9c311: fix(openai, openai-compatible): only send null content for assistant messages with tool calls
136
+ - e6376c2: fix(openai): preserve raw finish reason for failed responses stream events
137
+
138
+ 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`.
139
+
140
+ - ce769dd: feat(provider): add experimental Realtime API support for voice conversations
141
+
142
+ Adds first-class support for realtime (speech-to-speech) APIs:
143
+
144
+ - `Experimental_RealtimeModelV4` spec in `@ai-sdk/provider` with normalized event types and factory
145
+ - OpenAI, Google, and xAI realtime provider implementations
146
+ - `openai.experimental_realtime()` / `google.experimental_realtime()` / `xai.experimental_realtime()` work in both server and browser
147
+ - `.getToken()` static method on each provider for server-side ephemeral token creation
148
+ - `experimental_getRealtimeToolDefinitions` helper for provider session tool definitions
149
+ - `experimental_useRealtime` hook in `@ai-sdk/react` returning `UIMessage[]` (aligned with `useChat`), with `onToolCall` and `addToolOutput` for client-driven tool execution
150
+ - `inputAudioTranscription` session config for showing transcribed user audio messages when supported by the provider
151
+
152
+ - e311194: feat(ai): allow passing provider instance to `uploadFile` and `uploadSkill` as shorthand
153
+ - 9bd6512: feat(provider): change file part data property to be tagged with a type and remove the image part type
154
+ - 258c093: chore: ensure consistent import handling and avoid import duplicates or cycles
155
+ - 685cec7: feat(openai): add opt-in pass-through for unsupported file media types
156
+ - 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
157
+ - 5463d0d: feat(provider): align tool result output content file part types with top-level message file part types
158
+ - b8396f0: trigger initial beta release
159
+ - bfb756d: patch - send content: null instead of empty string for tool-only assistant messages
160
+ - 90e2d8a: chore: fix unused vars not being flagged by our lint tooling
161
+ - 17b5597: fix(openai): skip passing reasoning items when using previous response id
162
+ - b3976a2: Add workflow serialization support to all provider models.
163
+
164
+ **`@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.
165
+
166
+ **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.
167
+
168
+ All provider model classes now include `WORKFLOW_SERIALIZE` and `WORKFLOW_DESERIALIZE` static methods, enabling them to cross workflow step boundaries without serialization errors.
169
+
170
+ - ff5eba1: feat: roll `image-*` tool output types into their equivalent `file-*` types
171
+ - f9acbc0: feat(provider/openai): add gpt-image-2 model support
172
+
173
+ ## 4.0.0-beta.77
174
+
175
+ ### Patch Changes
176
+
177
+ - Updated dependencies [0416e3e]
178
+ - @ai-sdk/provider@4.0.0-beta.20
179
+ - @ai-sdk/provider-utils@5.0.0-beta.50
180
+
181
+ ## 4.0.0-beta.76
182
+
183
+ ### Patch Changes
184
+
185
+ - 2c4767d: feat(openai): add orchestration token usage details to Responses API usage
186
+
187
+ ## 4.0.0-beta.75
188
+
189
+ ### Patch Changes
190
+
191
+ - 1772a63: Default OpenAI Responses reasoning summaries to detailed when reasoning effort is enabled.
192
+
193
+ ## 4.0.0-beta.74
194
+
195
+ ### Patch Changes
196
+
197
+ - b8396f0: trigger initial beta release
198
+ - Updated dependencies [b8396f0]
199
+ - @ai-sdk/provider-utils@5.0.0-beta.49
200
+ - @ai-sdk/provider@4.0.0-beta.19
201
+
3
202
  ## 4.0.0-canary.73
4
203
 
5
204
  ### 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;
@@ -1058,7 +1064,7 @@ declare const openaiTools: {
1058
1064
  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 & {});
1059
1065
  declare const openaiLanguageModelResponsesOptionsSchema: _ai_sdk_provider_utils.LazySchema<{
1060
1066
  conversation?: string | null | undefined;
1061
- include?: ("file_search_call.results" | "message.output_text.logprobs" | "reasoning.encrypted_content")[] | null | undefined;
1067
+ include?: ("web_search_call.results" | "file_search_call.results" | "message.output_text.logprobs" | "reasoning.encrypted_content")[] | null | undefined;
1062
1068
  instructions?: string | null | undefined;
1063
1069
  logprobs?: number | boolean | undefined;
1064
1070
  maxToolCalls?: number | 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({ cached_tokens: z24.number().nullish() }).nullish(),
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({ reasoning_tokens: z24.number().nullish() }).nullish()
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({ cached_tokens: z24.number().nullish() }).nullish(),
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({ reasoning_tokens: z24.number().nullish() }).nullish()
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({ cached_tokens: z24.number().nullish() }).nullish(),
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({ reasoning_tokens: z24.number().nullish() }).nullish()
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
  )
@@ -5164,13 +5185,14 @@ var openaiLanguageModelResponsesOptionsSchema = lazySchema23(
5164
5185
  conversation: z25.string().nullish(),
5165
5186
  /**
5166
5187
  * The set of extra fields to include in the response (advanced, usually not needed).
5167
- * Example values: 'reasoning.encrypted_content', 'file_search_call.results', 'message.output_text.logprobs'.
5188
+ * Example values: 'reasoning.encrypted_content', 'file_search_call.results', 'web_search_call.results', 'message.output_text.logprobs'.
5168
5189
  */
5169
5190
  include: z25.array(
5170
5191
  z25.enum([
5171
5192
  "reasoning.encrypted_content",
5172
5193
  // handled internally by default, only needed for unknown reasoning models
5173
5194
  "file_search_call.results",
5195
+ "web_search_call.results",
5174
5196
  "message.output_text.logprobs"
5175
5197
  ])
5176
5198
  ).nullish(),
@@ -5755,6 +5777,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
5755
5777
  });
5756
5778
  }
5757
5779
  const resolvedReasoningEffort = (_a = openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null ? _a : isCustomReasoning2(reasoning) ? reasoning : void 0;
5780
+ const resolvedReasoningSummary = (openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) !== void 0 ? openaiOptions.reasoningSummary : resolvedReasoningEffort != null && resolvedReasoningEffort !== "none" ? "detailed" : void 0;
5758
5781
  const isReasoningModel = (_b = openaiOptions == null ? void 0 : openaiOptions.forceReasoning) != null ? _b : modelCapabilities.isReasoningModel;
5759
5782
  if ((openaiOptions == null ? void 0 : openaiOptions.conversation) && (openaiOptions == null ? void 0 : openaiOptions.previousResponseId)) {
5760
5783
  warnings.push({
@@ -5881,13 +5904,13 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
5881
5904
  }))
5882
5905
  },
5883
5906
  // model-specific settings:
5884
- ...isReasoningModel && (resolvedReasoningEffort != null || (openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) != null) && {
5907
+ ...isReasoningModel && (resolvedReasoningEffort != null || resolvedReasoningSummary != null) && {
5885
5908
  reasoning: {
5886
5909
  ...resolvedReasoningEffort != null && {
5887
5910
  effort: resolvedReasoningEffort
5888
5911
  },
5889
- ...(openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) != null && {
5890
- summary: openaiOptions.reasoningSummary
5912
+ ...resolvedReasoningSummary != null && {
5913
+ summary: resolvedReasoningSummary
5891
5914
  }
5892
5915
  }
5893
5916
  }
@@ -7938,7 +7961,7 @@ var OpenAISkills = class {
7938
7961
  };
7939
7962
 
7940
7963
  // src/version.ts
7941
- var VERSION = true ? "4.0.0-canary.73" : "0.0.0-test";
7964
+ var VERSION = true ? "4.0.1" : "0.0.0-test";
7942
7965
 
7943
7966
  // src/openai-provider.ts
7944
7967
  function createOpenAI(options = {}) {