@ai-sdk/openai 2.0.69 → 2.0.71

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.
@@ -477,4 +477,87 @@ declare const imageGeneration: (args?: ImageGenerationArgs) => _ai_sdk_provider_
477
477
  result: string;
478
478
  }>;
479
479
 
480
- export { OpenAIChatLanguageModel, type OpenAIChatLanguageModelOptions, type OpenAIChatModelId, OpenAICompletionLanguageModel, type OpenAICompletionModelId, type OpenAICompletionProviderOptions, OpenAIEmbeddingModel, type OpenAIEmbeddingModelId, type OpenAIEmbeddingProviderOptions, OpenAIImageModel, type OpenAIImageModelId, OpenAIResponsesLanguageModel, type OpenAISpeechCallOptions, OpenAISpeechModel, type OpenAISpeechModelId, type OpenAITranscriptionCallOptions, OpenAITranscriptionModel, type OpenAITranscriptionModelId, type OpenAITranscriptionProviderOptions, codeInterpreter, codeInterpreterArgsSchema, codeInterpreterInputSchema, codeInterpreterOutputSchema, codeInterpreterToolFactory, fileSearch, fileSearchArgsSchema, fileSearchOutputSchema, hasDefaultResponseFormat, imageGeneration, imageGenerationArgsSchema, imageGenerationOutputSchema, modelMaxImagesPerCall, openAITranscriptionProviderOptions, openaiChatLanguageModelOptions, openaiCompletionProviderOptions, openaiEmbeddingProviderOptions, openaiSpeechProviderOptionsSchema };
480
+ declare const webSearchPreviewArgsSchema: _ai_sdk_provider_utils.LazySchema<{
481
+ searchContextSize?: "low" | "medium" | "high" | undefined;
482
+ userLocation?: {
483
+ type: "approximate";
484
+ country?: string | undefined;
485
+ city?: string | undefined;
486
+ region?: string | undefined;
487
+ timezone?: string | undefined;
488
+ } | undefined;
489
+ }>;
490
+ declare const webSearchPreviewInputSchema: _ai_sdk_provider_utils.LazySchema<Record<string, never>>;
491
+ declare const webSearchPreview: _ai_sdk_provider_utils.ProviderDefinedToolFactoryWithOutputSchema<{}, {
492
+ /**
493
+ * An object describing the specific action taken in this web search call.
494
+ * Includes details on how the model used the web (search, open_page, find).
495
+ */
496
+ action: {
497
+ /**
498
+ * Action type "search" - Performs a web search query.
499
+ */
500
+ type: "search";
501
+ /**
502
+ * The search query.
503
+ */
504
+ query?: string;
505
+ } | {
506
+ /**
507
+ * Action type "openPage" - Opens a specific URL from search results.
508
+ */
509
+ type: "openPage";
510
+ /**
511
+ * The URL opened by the model.
512
+ */
513
+ url: string;
514
+ } | {
515
+ /**
516
+ * Action type "find": Searches for a pattern within a loaded page.
517
+ */
518
+ type: "find";
519
+ /**
520
+ * The URL of the page searched for the pattern.
521
+ */
522
+ url: string;
523
+ /**
524
+ * The pattern or text to search for within the page.
525
+ */
526
+ pattern: string;
527
+ };
528
+ }, {
529
+ /**
530
+ * Search context size to use for the web search.
531
+ * - high: Most comprehensive context, highest cost, slower response
532
+ * - medium: Balanced context, cost, and latency (default)
533
+ * - low: Least context, lowest cost, fastest response
534
+ */
535
+ searchContextSize?: "low" | "medium" | "high";
536
+ /**
537
+ * User location information to provide geographically relevant search results.
538
+ */
539
+ userLocation?: {
540
+ /**
541
+ * Type of location (always 'approximate')
542
+ */
543
+ type: "approximate";
544
+ /**
545
+ * Two-letter ISO country code (e.g., 'US', 'GB')
546
+ */
547
+ country?: string;
548
+ /**
549
+ * City name (free text, e.g., 'Minneapolis')
550
+ */
551
+ city?: string;
552
+ /**
553
+ * Region name (free text, e.g., 'Minnesota')
554
+ */
555
+ region?: string;
556
+ /**
557
+ * IANA timezone (e.g., 'America/Chicago')
558
+ */
559
+ timezone?: string;
560
+ };
561
+ }>;
562
+
563
+ export { OpenAIChatLanguageModel, type OpenAIChatLanguageModelOptions, type OpenAIChatModelId, OpenAICompletionLanguageModel, type OpenAICompletionModelId, type OpenAICompletionProviderOptions, OpenAIEmbeddingModel, type OpenAIEmbeddingModelId, type OpenAIEmbeddingProviderOptions, OpenAIImageModel, type OpenAIImageModelId, OpenAIResponsesLanguageModel, type OpenAISpeechCallOptions, OpenAISpeechModel, type OpenAISpeechModelId, type OpenAITranscriptionCallOptions, OpenAITranscriptionModel, type OpenAITranscriptionModelId, type OpenAITranscriptionProviderOptions, codeInterpreter, codeInterpreterArgsSchema, codeInterpreterInputSchema, codeInterpreterOutputSchema, codeInterpreterToolFactory, fileSearch, fileSearchArgsSchema, fileSearchOutputSchema, hasDefaultResponseFormat, imageGeneration, imageGenerationArgsSchema, imageGenerationOutputSchema, modelMaxImagesPerCall, openAITranscriptionProviderOptions, openaiChatLanguageModelOptions, openaiCompletionProviderOptions, openaiEmbeddingProviderOptions, openaiSpeechProviderOptionsSchema, webSearchPreview, webSearchPreviewArgsSchema, webSearchPreviewInputSchema };
@@ -477,4 +477,87 @@ declare const imageGeneration: (args?: ImageGenerationArgs) => _ai_sdk_provider_
477
477
  result: string;
478
478
  }>;
479
479
 
480
- export { OpenAIChatLanguageModel, type OpenAIChatLanguageModelOptions, type OpenAIChatModelId, OpenAICompletionLanguageModel, type OpenAICompletionModelId, type OpenAICompletionProviderOptions, OpenAIEmbeddingModel, type OpenAIEmbeddingModelId, type OpenAIEmbeddingProviderOptions, OpenAIImageModel, type OpenAIImageModelId, OpenAIResponsesLanguageModel, type OpenAISpeechCallOptions, OpenAISpeechModel, type OpenAISpeechModelId, type OpenAITranscriptionCallOptions, OpenAITranscriptionModel, type OpenAITranscriptionModelId, type OpenAITranscriptionProviderOptions, codeInterpreter, codeInterpreterArgsSchema, codeInterpreterInputSchema, codeInterpreterOutputSchema, codeInterpreterToolFactory, fileSearch, fileSearchArgsSchema, fileSearchOutputSchema, hasDefaultResponseFormat, imageGeneration, imageGenerationArgsSchema, imageGenerationOutputSchema, modelMaxImagesPerCall, openAITranscriptionProviderOptions, openaiChatLanguageModelOptions, openaiCompletionProviderOptions, openaiEmbeddingProviderOptions, openaiSpeechProviderOptionsSchema };
480
+ declare const webSearchPreviewArgsSchema: _ai_sdk_provider_utils.LazySchema<{
481
+ searchContextSize?: "low" | "medium" | "high" | undefined;
482
+ userLocation?: {
483
+ type: "approximate";
484
+ country?: string | undefined;
485
+ city?: string | undefined;
486
+ region?: string | undefined;
487
+ timezone?: string | undefined;
488
+ } | undefined;
489
+ }>;
490
+ declare const webSearchPreviewInputSchema: _ai_sdk_provider_utils.LazySchema<Record<string, never>>;
491
+ declare const webSearchPreview: _ai_sdk_provider_utils.ProviderDefinedToolFactoryWithOutputSchema<{}, {
492
+ /**
493
+ * An object describing the specific action taken in this web search call.
494
+ * Includes details on how the model used the web (search, open_page, find).
495
+ */
496
+ action: {
497
+ /**
498
+ * Action type "search" - Performs a web search query.
499
+ */
500
+ type: "search";
501
+ /**
502
+ * The search query.
503
+ */
504
+ query?: string;
505
+ } | {
506
+ /**
507
+ * Action type "openPage" - Opens a specific URL from search results.
508
+ */
509
+ type: "openPage";
510
+ /**
511
+ * The URL opened by the model.
512
+ */
513
+ url: string;
514
+ } | {
515
+ /**
516
+ * Action type "find": Searches for a pattern within a loaded page.
517
+ */
518
+ type: "find";
519
+ /**
520
+ * The URL of the page searched for the pattern.
521
+ */
522
+ url: string;
523
+ /**
524
+ * The pattern or text to search for within the page.
525
+ */
526
+ pattern: string;
527
+ };
528
+ }, {
529
+ /**
530
+ * Search context size to use for the web search.
531
+ * - high: Most comprehensive context, highest cost, slower response
532
+ * - medium: Balanced context, cost, and latency (default)
533
+ * - low: Least context, lowest cost, fastest response
534
+ */
535
+ searchContextSize?: "low" | "medium" | "high";
536
+ /**
537
+ * User location information to provide geographically relevant search results.
538
+ */
539
+ userLocation?: {
540
+ /**
541
+ * Type of location (always 'approximate')
542
+ */
543
+ type: "approximate";
544
+ /**
545
+ * Two-letter ISO country code (e.g., 'US', 'GB')
546
+ */
547
+ country?: string;
548
+ /**
549
+ * City name (free text, e.g., 'Minneapolis')
550
+ */
551
+ city?: string;
552
+ /**
553
+ * Region name (free text, e.g., 'Minnesota')
554
+ */
555
+ region?: string;
556
+ /**
557
+ * IANA timezone (e.g., 'America/Chicago')
558
+ */
559
+ timezone?: string;
560
+ };
561
+ }>;
562
+
563
+ export { OpenAIChatLanguageModel, type OpenAIChatLanguageModelOptions, type OpenAIChatModelId, OpenAICompletionLanguageModel, type OpenAICompletionModelId, type OpenAICompletionProviderOptions, OpenAIEmbeddingModel, type OpenAIEmbeddingModelId, type OpenAIEmbeddingProviderOptions, OpenAIImageModel, type OpenAIImageModelId, OpenAIResponsesLanguageModel, type OpenAISpeechCallOptions, OpenAISpeechModel, type OpenAISpeechModelId, type OpenAITranscriptionCallOptions, OpenAITranscriptionModel, type OpenAITranscriptionModelId, type OpenAITranscriptionProviderOptions, codeInterpreter, codeInterpreterArgsSchema, codeInterpreterInputSchema, codeInterpreterOutputSchema, codeInterpreterToolFactory, fileSearch, fileSearchArgsSchema, fileSearchOutputSchema, hasDefaultResponseFormat, imageGeneration, imageGenerationArgsSchema, imageGenerationOutputSchema, modelMaxImagesPerCall, openAITranscriptionProviderOptions, openaiChatLanguageModelOptions, openaiCompletionProviderOptions, openaiEmbeddingProviderOptions, openaiSpeechProviderOptionsSchema, webSearchPreview, webSearchPreviewArgsSchema, webSearchPreviewInputSchema };
@@ -44,7 +44,10 @@ __export(internal_exports, {
44
44
  openaiChatLanguageModelOptions: () => openaiChatLanguageModelOptions,
45
45
  openaiCompletionProviderOptions: () => openaiCompletionProviderOptions,
46
46
  openaiEmbeddingProviderOptions: () => openaiEmbeddingProviderOptions,
47
- openaiSpeechProviderOptionsSchema: () => openaiSpeechProviderOptionsSchema
47
+ openaiSpeechProviderOptionsSchema: () => openaiSpeechProviderOptionsSchema,
48
+ webSearchPreview: () => webSearchPreview,
49
+ webSearchPreviewArgsSchema: () => webSearchPreviewArgsSchema,
50
+ webSearchPreviewInputSchema: () => webSearchPreviewInputSchema
48
51
  });
49
52
  module.exports = __toCommonJS(internal_exports);
50
53
 
@@ -2683,6 +2686,8 @@ var openaiResponsesChunkSchema = (0, import_provider_utils21.lazyValidator)(
2683
2686
  annotation: import_v414.z.discriminatedUnion("type", [
2684
2687
  import_v414.z.object({
2685
2688
  type: import_v414.z.literal("url_citation"),
2689
+ start_index: import_v414.z.number(),
2690
+ end_index: import_v414.z.number(),
2686
2691
  url: import_v414.z.string(),
2687
2692
  title: import_v414.z.string()
2688
2693
  }),
@@ -3948,6 +3953,7 @@ var OpenAIResponsesLanguageModel = class {
3948
3953
  const logprobs = [];
3949
3954
  let responseId = null;
3950
3955
  const ongoingToolCalls = {};
3956
+ const ongoingAnnotations = [];
3951
3957
  let hasFunctionCall = false;
3952
3958
  const activeReasoning = {};
3953
3959
  let serviceTier;
@@ -3997,7 +4003,7 @@ var OpenAIResponsesLanguageModel = class {
3997
4003
  controller.enqueue({
3998
4004
  type: "tool-call",
3999
4005
  toolCallId: value.item.id,
4000
- toolName: "web_search",
4006
+ toolName: webSearchToolName != null ? webSearchToolName : "web_search",
4001
4007
  input: JSON.stringify({}),
4002
4008
  providerExecuted: true
4003
4009
  });
@@ -4048,6 +4054,7 @@ var OpenAIResponsesLanguageModel = class {
4048
4054
  providerExecuted: true
4049
4055
  });
4050
4056
  } else if (value.item.type === "message") {
4057
+ ongoingAnnotations.splice(0, ongoingAnnotations.length);
4051
4058
  controller.enqueue({
4052
4059
  type: "text-start",
4053
4060
  id: value.item.id,
@@ -4073,7 +4080,7 @@ var OpenAIResponsesLanguageModel = class {
4073
4080
  }
4074
4081
  });
4075
4082
  }
4076
- } else if (isResponseOutputItemDoneChunk(value)) {
4083
+ } else if (isResponseOutputItemDoneChunk(value) && value.item.type !== "message") {
4077
4084
  if (value.item.type === "function_call") {
4078
4085
  ongoingToolCalls[value.output_index] = void 0;
4079
4086
  hasFunctionCall = true;
@@ -4097,7 +4104,7 @@ var OpenAIResponsesLanguageModel = class {
4097
4104
  controller.enqueue({
4098
4105
  type: "tool-result",
4099
4106
  toolCallId: value.item.id,
4100
- toolName: "web_search",
4107
+ toolName: webSearchToolName != null ? webSearchToolName : "web_search",
4101
4108
  result: mapWebSearchOutput(value.item.action),
4102
4109
  providerExecuted: true
4103
4110
  });
@@ -4183,11 +4190,6 @@ var OpenAIResponsesLanguageModel = class {
4183
4190
  openai: { itemId: value.item.id }
4184
4191
  }
4185
4192
  });
4186
- } else if (value.item.type === "message") {
4187
- controller.enqueue({
4188
- type: "text-end",
4189
- id: value.item.id
4190
- });
4191
4193
  } else if (value.item.type === "reasoning") {
4192
4194
  const activeReasoningPart = activeReasoning[value.item.id];
4193
4195
  const summaryPartIndices = Object.entries(
@@ -4334,6 +4336,7 @@ var OpenAIResponsesLanguageModel = class {
4334
4336
  serviceTier = value.response.service_tier;
4335
4337
  }
4336
4338
  } else if (isResponseAnnotationAddedChunk(value)) {
4339
+ ongoingAnnotations.push(value.annotation);
4337
4340
  if (value.annotation.type === "url_citation") {
4338
4341
  controller.enqueue({
4339
4342
  type: "source",
@@ -4359,6 +4362,19 @@ var OpenAIResponsesLanguageModel = class {
4359
4362
  } : {}
4360
4363
  });
4361
4364
  }
4365
+ } else if (isResponseOutputItemDoneChunk(value) && value.item.type === "message") {
4366
+ controller.enqueue({
4367
+ type: "text-end",
4368
+ id: value.item.id,
4369
+ providerMetadata: {
4370
+ openai: {
4371
+ itemId: value.item.id,
4372
+ ...ongoingAnnotations.length > 0 && {
4373
+ annotations: ongoingAnnotations
4374
+ }
4375
+ }
4376
+ }
4377
+ });
4362
4378
  } else if (isErrorChunk(value)) {
4363
4379
  controller.enqueue({ type: "error", error: value });
4364
4380
  }
@@ -4488,6 +4504,9 @@ function mapWebSearchOutput(action) {
4488
4504
  openaiChatLanguageModelOptions,
4489
4505
  openaiCompletionProviderOptions,
4490
4506
  openaiEmbeddingProviderOptions,
4491
- openaiSpeechProviderOptionsSchema
4507
+ openaiSpeechProviderOptionsSchema,
4508
+ webSearchPreview,
4509
+ webSearchPreviewArgsSchema,
4510
+ webSearchPreviewInputSchema
4492
4511
  });
4493
4512
  //# sourceMappingURL=index.js.map