@ai-sdk/openai 2.0.125 → 2.0.127

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,22 @@
1
1
  # @ai-sdk/openai
2
2
 
3
+ ## 2.0.127
4
+
5
+ ### Patch Changes
6
+
7
+ - fd889a3: fix(openai): return an AI SDK error for empty chat completion choices
8
+ - Updated dependencies [c2089a9]
9
+ - Updated dependencies [ab3990f]
10
+ - @ai-sdk/provider@2.0.4
11
+ - @ai-sdk/provider-utils@3.0.37
12
+
13
+ ## 2.0.126
14
+
15
+ ### Patch Changes
16
+
17
+ - 022f24b: Include explicit message item types in Azure AI Foundry Responses requests.
18
+ - a15b75a: Add async function tool calling support for OpenAI Responses models.
19
+
3
20
  ## 2.0.125
4
21
 
5
22
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -187,6 +187,249 @@ type OpenAIResponsesFileSearchToolCompoundFilter = {
187
187
  */
188
188
  filters: Array<OpenAIResponsesFileSearchToolComparisonFilter | OpenAIResponsesFileSearchToolCompoundFilter>;
189
189
  };
190
+ declare const openaiResponsesChunkSchema: _ai_sdk_provider_utils.LazyValidator<{
191
+ type: "unknown_chunk";
192
+ message: string;
193
+ } | {
194
+ type: "response.output_text.delta";
195
+ item_id: string;
196
+ delta: string;
197
+ logprobs?: {
198
+ token: string;
199
+ logprob: number;
200
+ top_logprobs: {
201
+ token: string;
202
+ logprob: number;
203
+ }[];
204
+ }[] | null | undefined;
205
+ } | {
206
+ type: "response.completed" | "response.incomplete";
207
+ response: {
208
+ usage: {
209
+ input_tokens: number;
210
+ output_tokens: number;
211
+ input_tokens_details?: {
212
+ cached_tokens?: number | null | undefined;
213
+ cache_write_tokens?: number | null | undefined;
214
+ orchestration_input_tokens?: number | null | undefined;
215
+ orchestration_input_cached_tokens?: number | null | undefined;
216
+ } | null | undefined;
217
+ output_tokens_details?: {
218
+ reasoning_tokens?: number | null | undefined;
219
+ orchestration_output_tokens?: number | null | undefined;
220
+ } | null | undefined;
221
+ };
222
+ incomplete_details?: {
223
+ reason: string;
224
+ } | null | undefined;
225
+ reasoning?: {
226
+ context?: string | null | undefined;
227
+ } | null | undefined;
228
+ service_tier?: string | null | undefined;
229
+ };
230
+ } | {
231
+ type: "response.created";
232
+ response: {
233
+ id: string;
234
+ created_at: number;
235
+ model: string;
236
+ service_tier?: string | null | undefined;
237
+ };
238
+ } | {
239
+ type: "response.output_item.added";
240
+ output_index: number;
241
+ item: {
242
+ type: "message";
243
+ id: string;
244
+ phase?: "commentary" | "final_answer" | null | undefined;
245
+ } | {
246
+ type: "reasoning";
247
+ id: string;
248
+ encrypted_content?: string | null | undefined;
249
+ } | {
250
+ type: "function_call";
251
+ id: string;
252
+ call_id: string;
253
+ name: string;
254
+ arguments: string;
255
+ async?: boolean | null | undefined;
256
+ } | {
257
+ type: "web_search_call";
258
+ id: string;
259
+ status: string;
260
+ } | {
261
+ type: "computer_call";
262
+ id: string;
263
+ status: string;
264
+ } | {
265
+ type: "file_search_call";
266
+ id: string;
267
+ } | {
268
+ type: "image_generation_call";
269
+ id: string;
270
+ } | {
271
+ type: "code_interpreter_call";
272
+ id: string;
273
+ container_id: string;
274
+ code: string | null;
275
+ outputs: ({
276
+ type: "logs";
277
+ logs: string;
278
+ } | {
279
+ type: "image";
280
+ url: string;
281
+ })[] | null;
282
+ status: string;
283
+ };
284
+ } | {
285
+ type: "response.output_item.done";
286
+ output_index: number;
287
+ item: {
288
+ type: "message";
289
+ id: string;
290
+ phase?: "commentary" | "final_answer" | null | undefined;
291
+ } | {
292
+ type: "reasoning";
293
+ id: string;
294
+ encrypted_content?: string | null | undefined;
295
+ } | {
296
+ type: "function_call";
297
+ id: string;
298
+ call_id: string;
299
+ name: string;
300
+ arguments: string;
301
+ status: "completed";
302
+ async?: boolean | null | undefined;
303
+ } | {
304
+ type: "code_interpreter_call";
305
+ id: string;
306
+ code: string | null;
307
+ container_id: string;
308
+ outputs: ({
309
+ type: "logs";
310
+ logs: string;
311
+ } | {
312
+ type: "image";
313
+ url: string;
314
+ })[] | null;
315
+ } | {
316
+ type: "image_generation_call";
317
+ id: string;
318
+ result: string;
319
+ } | {
320
+ type: "web_search_call";
321
+ id: string;
322
+ status: string;
323
+ action?: {
324
+ type: "search";
325
+ query?: string | null | undefined;
326
+ sources?: ({
327
+ type: "url";
328
+ url: string;
329
+ } | {
330
+ type: "api";
331
+ name: string;
332
+ })[] | null | undefined;
333
+ } | {
334
+ type: "open_page";
335
+ url?: string | null | undefined;
336
+ } | {
337
+ type: "find_in_page";
338
+ url?: string | null | undefined;
339
+ pattern?: string | null | undefined;
340
+ } | null | undefined;
341
+ } | {
342
+ type: "file_search_call";
343
+ id: string;
344
+ queries: string[];
345
+ results?: {
346
+ attributes: Record<string, unknown>;
347
+ file_id: string;
348
+ filename: string;
349
+ score: number;
350
+ text: string;
351
+ }[] | null | undefined;
352
+ } | {
353
+ type: "local_shell_call";
354
+ id: string;
355
+ call_id: string;
356
+ action: {
357
+ type: "exec";
358
+ command: string[];
359
+ timeout_ms?: number | undefined;
360
+ user?: string | undefined;
361
+ working_directory?: string | undefined;
362
+ env?: Record<string, string> | undefined;
363
+ };
364
+ } | {
365
+ type: "computer_call";
366
+ id: string;
367
+ status: "completed";
368
+ };
369
+ } | {
370
+ type: "response.function_call_arguments.delta";
371
+ item_id: string;
372
+ output_index: number;
373
+ delta: string;
374
+ } | {
375
+ type: "response.image_generation_call.partial_image";
376
+ item_id: string;
377
+ output_index: number;
378
+ partial_image_b64: string;
379
+ } | {
380
+ type: "response.code_interpreter_call_code.delta";
381
+ item_id: string;
382
+ output_index: number;
383
+ delta: string;
384
+ } | {
385
+ type: "response.code_interpreter_call_code.done";
386
+ item_id: string;
387
+ output_index: number;
388
+ code: string;
389
+ } | {
390
+ type: "response.output_text.annotation.added";
391
+ annotation: {
392
+ type: "url_citation";
393
+ start_index: number;
394
+ end_index: number;
395
+ url: string;
396
+ title: string;
397
+ } | {
398
+ type: "file_citation";
399
+ file_id: string;
400
+ filename?: string | null | undefined;
401
+ index?: number | null | undefined;
402
+ start_index?: number | null | undefined;
403
+ end_index?: number | null | undefined;
404
+ quote?: string | null | undefined;
405
+ };
406
+ } | {
407
+ type: "response.reasoning_summary_part.added";
408
+ item_id: string;
409
+ summary_index: number;
410
+ } | {
411
+ type: "response.reasoning_summary_text.delta";
412
+ item_id: string;
413
+ summary_index: number;
414
+ delta: string;
415
+ } | {
416
+ type: "response.reasoning_summary_part.done";
417
+ item_id: string;
418
+ summary_index: number;
419
+ } | {
420
+ type: "error";
421
+ sequence_number: number;
422
+ error: {
423
+ type: string;
424
+ code: string;
425
+ message: string;
426
+ param?: string | null | undefined;
427
+ };
428
+ }>;
429
+ type OpenAIResponsesChunk = InferValidator<typeof openaiResponsesChunkSchema>;
430
+ type OpenAIResponsesLogprobs = NonNullable<(OpenAIResponsesChunk & {
431
+ type: 'response.output_text.delta';
432
+ })['logprobs']> | null;
190
433
 
191
434
  declare const openaiTools: {
192
435
  /**
@@ -484,6 +727,42 @@ Default OpenAI provider instance.
484
727
  */
485
728
  declare const openai: OpenAIProvider;
486
729
 
730
+ type OpenAIToolOptions = {
731
+ /**
732
+ * Whether the model can continue generating after calling this tool without
733
+ * waiting for its result.
734
+ */
735
+ async?: boolean;
736
+ };
737
+
738
+ type ResponsesProviderMetadata = {
739
+ responseId: string | null | undefined;
740
+ logprobs?: Array<OpenAIResponsesLogprobs>;
741
+ serviceTier?: string;
742
+ reasoningContext?: string;
743
+ /**
744
+ * Provider-specific token usage details, including prompt cache writes and
745
+ * orchestration usage. Surfaced here so downstream consumers can bill it.
746
+ */
747
+ usage?: ResponsesUsageProviderMetadata;
748
+ };
749
+ type ResponsesUsageProviderMetadata = {
750
+ cacheWriteTokens?: number;
751
+ orchestrationInputTokens?: number;
752
+ orchestrationInputCachedTokens?: number;
753
+ orchestrationOutputTokens?: number;
754
+ };
755
+ type OpenaiResponsesProviderMetadata = {
756
+ openai: ResponsesProviderMetadata;
757
+ };
758
+ type ResponsesToolCallProviderMetadata = {
759
+ itemId: string;
760
+ async?: boolean;
761
+ };
762
+ type OpenaiResponsesToolCallProviderMetadata = {
763
+ openai: ResponsesToolCallProviderMetadata;
764
+ };
765
+
487
766
  declare const VERSION: string;
488
767
 
489
- export { type OpenAIChatLanguageModelOptions, type OpenAIImageModelGenerationOptions, type OpenAIImageModelOptions, type OpenAIProvider, type OpenAIProviderSettings, type OpenAIResponsesProviderOptions, VERSION, createOpenAI, openai };
768
+ export { type OpenAIChatLanguageModelOptions, type OpenAIImageModelGenerationOptions, type OpenAIImageModelOptions, type OpenAIProvider, type OpenAIProviderSettings, type OpenAIResponsesProviderOptions, type OpenAIToolOptions, type OpenaiResponsesProviderMetadata, type OpenaiResponsesToolCallProviderMetadata, VERSION, createOpenAI, openai };
package/dist/index.d.ts CHANGED
@@ -187,6 +187,249 @@ type OpenAIResponsesFileSearchToolCompoundFilter = {
187
187
  */
188
188
  filters: Array<OpenAIResponsesFileSearchToolComparisonFilter | OpenAIResponsesFileSearchToolCompoundFilter>;
189
189
  };
190
+ declare const openaiResponsesChunkSchema: _ai_sdk_provider_utils.LazyValidator<{
191
+ type: "unknown_chunk";
192
+ message: string;
193
+ } | {
194
+ type: "response.output_text.delta";
195
+ item_id: string;
196
+ delta: string;
197
+ logprobs?: {
198
+ token: string;
199
+ logprob: number;
200
+ top_logprobs: {
201
+ token: string;
202
+ logprob: number;
203
+ }[];
204
+ }[] | null | undefined;
205
+ } | {
206
+ type: "response.completed" | "response.incomplete";
207
+ response: {
208
+ usage: {
209
+ input_tokens: number;
210
+ output_tokens: number;
211
+ input_tokens_details?: {
212
+ cached_tokens?: number | null | undefined;
213
+ cache_write_tokens?: number | null | undefined;
214
+ orchestration_input_tokens?: number | null | undefined;
215
+ orchestration_input_cached_tokens?: number | null | undefined;
216
+ } | null | undefined;
217
+ output_tokens_details?: {
218
+ reasoning_tokens?: number | null | undefined;
219
+ orchestration_output_tokens?: number | null | undefined;
220
+ } | null | undefined;
221
+ };
222
+ incomplete_details?: {
223
+ reason: string;
224
+ } | null | undefined;
225
+ reasoning?: {
226
+ context?: string | null | undefined;
227
+ } | null | undefined;
228
+ service_tier?: string | null | undefined;
229
+ };
230
+ } | {
231
+ type: "response.created";
232
+ response: {
233
+ id: string;
234
+ created_at: number;
235
+ model: string;
236
+ service_tier?: string | null | undefined;
237
+ };
238
+ } | {
239
+ type: "response.output_item.added";
240
+ output_index: number;
241
+ item: {
242
+ type: "message";
243
+ id: string;
244
+ phase?: "commentary" | "final_answer" | null | undefined;
245
+ } | {
246
+ type: "reasoning";
247
+ id: string;
248
+ encrypted_content?: string | null | undefined;
249
+ } | {
250
+ type: "function_call";
251
+ id: string;
252
+ call_id: string;
253
+ name: string;
254
+ arguments: string;
255
+ async?: boolean | null | undefined;
256
+ } | {
257
+ type: "web_search_call";
258
+ id: string;
259
+ status: string;
260
+ } | {
261
+ type: "computer_call";
262
+ id: string;
263
+ status: string;
264
+ } | {
265
+ type: "file_search_call";
266
+ id: string;
267
+ } | {
268
+ type: "image_generation_call";
269
+ id: string;
270
+ } | {
271
+ type: "code_interpreter_call";
272
+ id: string;
273
+ container_id: string;
274
+ code: string | null;
275
+ outputs: ({
276
+ type: "logs";
277
+ logs: string;
278
+ } | {
279
+ type: "image";
280
+ url: string;
281
+ })[] | null;
282
+ status: string;
283
+ };
284
+ } | {
285
+ type: "response.output_item.done";
286
+ output_index: number;
287
+ item: {
288
+ type: "message";
289
+ id: string;
290
+ phase?: "commentary" | "final_answer" | null | undefined;
291
+ } | {
292
+ type: "reasoning";
293
+ id: string;
294
+ encrypted_content?: string | null | undefined;
295
+ } | {
296
+ type: "function_call";
297
+ id: string;
298
+ call_id: string;
299
+ name: string;
300
+ arguments: string;
301
+ status: "completed";
302
+ async?: boolean | null | undefined;
303
+ } | {
304
+ type: "code_interpreter_call";
305
+ id: string;
306
+ code: string | null;
307
+ container_id: string;
308
+ outputs: ({
309
+ type: "logs";
310
+ logs: string;
311
+ } | {
312
+ type: "image";
313
+ url: string;
314
+ })[] | null;
315
+ } | {
316
+ type: "image_generation_call";
317
+ id: string;
318
+ result: string;
319
+ } | {
320
+ type: "web_search_call";
321
+ id: string;
322
+ status: string;
323
+ action?: {
324
+ type: "search";
325
+ query?: string | null | undefined;
326
+ sources?: ({
327
+ type: "url";
328
+ url: string;
329
+ } | {
330
+ type: "api";
331
+ name: string;
332
+ })[] | null | undefined;
333
+ } | {
334
+ type: "open_page";
335
+ url?: string | null | undefined;
336
+ } | {
337
+ type: "find_in_page";
338
+ url?: string | null | undefined;
339
+ pattern?: string | null | undefined;
340
+ } | null | undefined;
341
+ } | {
342
+ type: "file_search_call";
343
+ id: string;
344
+ queries: string[];
345
+ results?: {
346
+ attributes: Record<string, unknown>;
347
+ file_id: string;
348
+ filename: string;
349
+ score: number;
350
+ text: string;
351
+ }[] | null | undefined;
352
+ } | {
353
+ type: "local_shell_call";
354
+ id: string;
355
+ call_id: string;
356
+ action: {
357
+ type: "exec";
358
+ command: string[];
359
+ timeout_ms?: number | undefined;
360
+ user?: string | undefined;
361
+ working_directory?: string | undefined;
362
+ env?: Record<string, string> | undefined;
363
+ };
364
+ } | {
365
+ type: "computer_call";
366
+ id: string;
367
+ status: "completed";
368
+ };
369
+ } | {
370
+ type: "response.function_call_arguments.delta";
371
+ item_id: string;
372
+ output_index: number;
373
+ delta: string;
374
+ } | {
375
+ type: "response.image_generation_call.partial_image";
376
+ item_id: string;
377
+ output_index: number;
378
+ partial_image_b64: string;
379
+ } | {
380
+ type: "response.code_interpreter_call_code.delta";
381
+ item_id: string;
382
+ output_index: number;
383
+ delta: string;
384
+ } | {
385
+ type: "response.code_interpreter_call_code.done";
386
+ item_id: string;
387
+ output_index: number;
388
+ code: string;
389
+ } | {
390
+ type: "response.output_text.annotation.added";
391
+ annotation: {
392
+ type: "url_citation";
393
+ start_index: number;
394
+ end_index: number;
395
+ url: string;
396
+ title: string;
397
+ } | {
398
+ type: "file_citation";
399
+ file_id: string;
400
+ filename?: string | null | undefined;
401
+ index?: number | null | undefined;
402
+ start_index?: number | null | undefined;
403
+ end_index?: number | null | undefined;
404
+ quote?: string | null | undefined;
405
+ };
406
+ } | {
407
+ type: "response.reasoning_summary_part.added";
408
+ item_id: string;
409
+ summary_index: number;
410
+ } | {
411
+ type: "response.reasoning_summary_text.delta";
412
+ item_id: string;
413
+ summary_index: number;
414
+ delta: string;
415
+ } | {
416
+ type: "response.reasoning_summary_part.done";
417
+ item_id: string;
418
+ summary_index: number;
419
+ } | {
420
+ type: "error";
421
+ sequence_number: number;
422
+ error: {
423
+ type: string;
424
+ code: string;
425
+ message: string;
426
+ param?: string | null | undefined;
427
+ };
428
+ }>;
429
+ type OpenAIResponsesChunk = InferValidator<typeof openaiResponsesChunkSchema>;
430
+ type OpenAIResponsesLogprobs = NonNullable<(OpenAIResponsesChunk & {
431
+ type: 'response.output_text.delta';
432
+ })['logprobs']> | null;
190
433
 
191
434
  declare const openaiTools: {
192
435
  /**
@@ -484,6 +727,42 @@ Default OpenAI provider instance.
484
727
  */
485
728
  declare const openai: OpenAIProvider;
486
729
 
730
+ type OpenAIToolOptions = {
731
+ /**
732
+ * Whether the model can continue generating after calling this tool without
733
+ * waiting for its result.
734
+ */
735
+ async?: boolean;
736
+ };
737
+
738
+ type ResponsesProviderMetadata = {
739
+ responseId: string | null | undefined;
740
+ logprobs?: Array<OpenAIResponsesLogprobs>;
741
+ serviceTier?: string;
742
+ reasoningContext?: string;
743
+ /**
744
+ * Provider-specific token usage details, including prompt cache writes and
745
+ * orchestration usage. Surfaced here so downstream consumers can bill it.
746
+ */
747
+ usage?: ResponsesUsageProviderMetadata;
748
+ };
749
+ type ResponsesUsageProviderMetadata = {
750
+ cacheWriteTokens?: number;
751
+ orchestrationInputTokens?: number;
752
+ orchestrationInputCachedTokens?: number;
753
+ orchestrationOutputTokens?: number;
754
+ };
755
+ type OpenaiResponsesProviderMetadata = {
756
+ openai: ResponsesProviderMetadata;
757
+ };
758
+ type ResponsesToolCallProviderMetadata = {
759
+ itemId: string;
760
+ async?: boolean;
761
+ };
762
+ type OpenaiResponsesToolCallProviderMetadata = {
763
+ openai: ResponsesToolCallProviderMetadata;
764
+ };
765
+
487
766
  declare const VERSION: string;
488
767
 
489
- export { type OpenAIChatLanguageModelOptions, type OpenAIImageModelGenerationOptions, type OpenAIImageModelOptions, type OpenAIProvider, type OpenAIProviderSettings, type OpenAIResponsesProviderOptions, VERSION, createOpenAI, openai };
768
+ export { type OpenAIChatLanguageModelOptions, type OpenAIImageModelGenerationOptions, type OpenAIImageModelOptions, type OpenAIProvider, type OpenAIProviderSettings, type OpenAIResponsesProviderOptions, type OpenAIToolOptions, type OpenaiResponsesProviderMetadata, type OpenaiResponsesToolCallProviderMetadata, VERSION, createOpenAI, openai };