@ai-sdk/openai 3.0.0-beta.61 → 3.0.0-beta.63

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.
@@ -481,4 +481,87 @@ declare const imageGeneration: (args?: ImageGenerationArgs) => _ai_sdk_provider_
481
481
  result: string;
482
482
  }>;
483
483
 
484
- 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 };
484
+ declare const webSearchPreviewArgsSchema: _ai_sdk_provider_utils.LazySchema<{
485
+ searchContextSize?: "low" | "medium" | "high" | undefined;
486
+ userLocation?: {
487
+ type: "approximate";
488
+ country?: string | undefined;
489
+ city?: string | undefined;
490
+ region?: string | undefined;
491
+ timezone?: string | undefined;
492
+ } | undefined;
493
+ }>;
494
+ declare const webSearchPreviewInputSchema: _ai_sdk_provider_utils.LazySchema<Record<string, never>>;
495
+ declare const webSearchPreview: _ai_sdk_provider_utils.ProviderDefinedToolFactoryWithOutputSchema<{}, {
496
+ /**
497
+ * An object describing the specific action taken in this web search call.
498
+ * Includes details on how the model used the web (search, open_page, find).
499
+ */
500
+ action: {
501
+ /**
502
+ * Action type "search" - Performs a web search query.
503
+ */
504
+ type: "search";
505
+ /**
506
+ * The search query.
507
+ */
508
+ query?: string;
509
+ } | {
510
+ /**
511
+ * Action type "openPage" - Opens a specific URL from search results.
512
+ */
513
+ type: "openPage";
514
+ /**
515
+ * The URL opened by the model.
516
+ */
517
+ url: string;
518
+ } | {
519
+ /**
520
+ * Action type "find": Searches for a pattern within a loaded page.
521
+ */
522
+ type: "find";
523
+ /**
524
+ * The URL of the page searched for the pattern.
525
+ */
526
+ url: string;
527
+ /**
528
+ * The pattern or text to search for within the page.
529
+ */
530
+ pattern: string;
531
+ };
532
+ }, {
533
+ /**
534
+ * Search context size to use for the web search.
535
+ * - high: Most comprehensive context, highest cost, slower response
536
+ * - medium: Balanced context, cost, and latency (default)
537
+ * - low: Least context, lowest cost, fastest response
538
+ */
539
+ searchContextSize?: "low" | "medium" | "high";
540
+ /**
541
+ * User location information to provide geographically relevant search results.
542
+ */
543
+ userLocation?: {
544
+ /**
545
+ * Type of location (always 'approximate')
546
+ */
547
+ type: "approximate";
548
+ /**
549
+ * Two-letter ISO country code (e.g., 'US', 'GB')
550
+ */
551
+ country?: string;
552
+ /**
553
+ * City name (free text, e.g., 'Minneapolis')
554
+ */
555
+ city?: string;
556
+ /**
557
+ * Region name (free text, e.g., 'Minnesota')
558
+ */
559
+ region?: string;
560
+ /**
561
+ * IANA timezone (e.g., 'America/Chicago')
562
+ */
563
+ timezone?: string;
564
+ };
565
+ }>;
566
+
567
+ 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 };
@@ -481,4 +481,87 @@ declare const imageGeneration: (args?: ImageGenerationArgs) => _ai_sdk_provider_
481
481
  result: string;
482
482
  }>;
483
483
 
484
- 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 };
484
+ declare const webSearchPreviewArgsSchema: _ai_sdk_provider_utils.LazySchema<{
485
+ searchContextSize?: "low" | "medium" | "high" | undefined;
486
+ userLocation?: {
487
+ type: "approximate";
488
+ country?: string | undefined;
489
+ city?: string | undefined;
490
+ region?: string | undefined;
491
+ timezone?: string | undefined;
492
+ } | undefined;
493
+ }>;
494
+ declare const webSearchPreviewInputSchema: _ai_sdk_provider_utils.LazySchema<Record<string, never>>;
495
+ declare const webSearchPreview: _ai_sdk_provider_utils.ProviderDefinedToolFactoryWithOutputSchema<{}, {
496
+ /**
497
+ * An object describing the specific action taken in this web search call.
498
+ * Includes details on how the model used the web (search, open_page, find).
499
+ */
500
+ action: {
501
+ /**
502
+ * Action type "search" - Performs a web search query.
503
+ */
504
+ type: "search";
505
+ /**
506
+ * The search query.
507
+ */
508
+ query?: string;
509
+ } | {
510
+ /**
511
+ * Action type "openPage" - Opens a specific URL from search results.
512
+ */
513
+ type: "openPage";
514
+ /**
515
+ * The URL opened by the model.
516
+ */
517
+ url: string;
518
+ } | {
519
+ /**
520
+ * Action type "find": Searches for a pattern within a loaded page.
521
+ */
522
+ type: "find";
523
+ /**
524
+ * The URL of the page searched for the pattern.
525
+ */
526
+ url: string;
527
+ /**
528
+ * The pattern or text to search for within the page.
529
+ */
530
+ pattern: string;
531
+ };
532
+ }, {
533
+ /**
534
+ * Search context size to use for the web search.
535
+ * - high: Most comprehensive context, highest cost, slower response
536
+ * - medium: Balanced context, cost, and latency (default)
537
+ * - low: Least context, lowest cost, fastest response
538
+ */
539
+ searchContextSize?: "low" | "medium" | "high";
540
+ /**
541
+ * User location information to provide geographically relevant search results.
542
+ */
543
+ userLocation?: {
544
+ /**
545
+ * Type of location (always 'approximate')
546
+ */
547
+ type: "approximate";
548
+ /**
549
+ * Two-letter ISO country code (e.g., 'US', 'GB')
550
+ */
551
+ country?: string;
552
+ /**
553
+ * City name (free text, e.g., 'Minneapolis')
554
+ */
555
+ city?: string;
556
+ /**
557
+ * Region name (free text, e.g., 'Minnesota')
558
+ */
559
+ region?: string;
560
+ /**
561
+ * IANA timezone (e.g., 'America/Chicago')
562
+ */
563
+ timezone?: string;
564
+ };
565
+ }>;
566
+
567
+ 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
 
@@ -2759,6 +2762,8 @@ var openaiResponsesChunkSchema = (0, import_provider_utils21.lazySchema)(
2759
2762
  annotation: import_v414.z.discriminatedUnion("type", [
2760
2763
  import_v414.z.object({
2761
2764
  type: import_v414.z.literal("url_citation"),
2765
+ start_index: import_v414.z.number(),
2766
+ end_index: import_v414.z.number(),
2762
2767
  url: import_v414.z.string(),
2763
2768
  title: import_v414.z.string()
2764
2769
  }),
@@ -4304,6 +4309,7 @@ var OpenAIResponsesLanguageModel = class {
4304
4309
  const logprobs = [];
4305
4310
  let responseId = null;
4306
4311
  const ongoingToolCalls = {};
4312
+ const ongoingAnnotations = [];
4307
4313
  let hasFunctionCall = false;
4308
4314
  const activeReasoning = {};
4309
4315
  let serviceTier;
@@ -4353,7 +4359,7 @@ var OpenAIResponsesLanguageModel = class {
4353
4359
  controller.enqueue({
4354
4360
  type: "tool-call",
4355
4361
  toolCallId: value.item.id,
4356
- toolName: "web_search",
4362
+ toolName: webSearchToolName != null ? webSearchToolName : "web_search",
4357
4363
  input: JSON.stringify({}),
4358
4364
  providerExecuted: true
4359
4365
  });
@@ -4412,6 +4418,7 @@ var OpenAIResponsesLanguageModel = class {
4412
4418
  providerExecuted: true
4413
4419
  });
4414
4420
  } else if (value.item.type === "message") {
4421
+ ongoingAnnotations.splice(0, ongoingAnnotations.length);
4415
4422
  controller.enqueue({
4416
4423
  type: "text-start",
4417
4424
  id: value.item.id,
@@ -4437,7 +4444,7 @@ var OpenAIResponsesLanguageModel = class {
4437
4444
  }
4438
4445
  });
4439
4446
  }
4440
- } else if (isResponseOutputItemDoneChunk(value)) {
4447
+ } else if (isResponseOutputItemDoneChunk(value) && value.item.type !== "message") {
4441
4448
  if (value.item.type === "function_call") {
4442
4449
  ongoingToolCalls[value.output_index] = void 0;
4443
4450
  hasFunctionCall = true;
@@ -4461,7 +4468,7 @@ var OpenAIResponsesLanguageModel = class {
4461
4468
  controller.enqueue({
4462
4469
  type: "tool-result",
4463
4470
  toolCallId: value.item.id,
4464
- toolName: "web_search",
4471
+ toolName: webSearchToolName != null ? webSearchToolName : "web_search",
4465
4472
  result: mapWebSearchOutput(value.item.action)
4466
4473
  });
4467
4474
  } else if (value.item.type === "computer_call") {
@@ -4592,11 +4599,6 @@ var OpenAIResponsesLanguageModel = class {
4592
4599
  openai: { itemId: value.item.id }
4593
4600
  }
4594
4601
  });
4595
- } else if (value.item.type === "message") {
4596
- controller.enqueue({
4597
- type: "text-end",
4598
- id: value.item.id
4599
- });
4600
4602
  } else if (value.item.type === "reasoning") {
4601
4603
  const activeReasoningPart = activeReasoning[value.item.id];
4602
4604
  const summaryPartIndices = Object.entries(
@@ -4753,6 +4755,7 @@ var OpenAIResponsesLanguageModel = class {
4753
4755
  serviceTier = value.response.service_tier;
4754
4756
  }
4755
4757
  } else if (isResponseAnnotationAddedChunk(value)) {
4758
+ ongoingAnnotations.push(value.annotation);
4756
4759
  if (value.annotation.type === "url_citation") {
4757
4760
  controller.enqueue({
4758
4761
  type: "source",
@@ -4809,6 +4812,19 @@ var OpenAIResponsesLanguageModel = class {
4809
4812
  }
4810
4813
  });
4811
4814
  }
4815
+ } else if (isResponseOutputItemDoneChunk(value) && value.item.type === "message") {
4816
+ controller.enqueue({
4817
+ type: "text-end",
4818
+ id: value.item.id,
4819
+ providerMetadata: {
4820
+ openai: {
4821
+ itemId: value.item.id,
4822
+ ...ongoingAnnotations.length > 0 && {
4823
+ annotations: ongoingAnnotations
4824
+ }
4825
+ }
4826
+ }
4827
+ });
4812
4828
  } else if (isErrorChunk(value)) {
4813
4829
  controller.enqueue({ type: "error", error: value });
4814
4830
  }
@@ -4927,6 +4943,9 @@ function mapWebSearchOutput(action) {
4927
4943
  openaiChatLanguageModelOptions,
4928
4944
  openaiCompletionProviderOptions,
4929
4945
  openaiEmbeddingProviderOptions,
4930
- openaiSpeechProviderOptionsSchema
4946
+ openaiSpeechProviderOptionsSchema,
4947
+ webSearchPreview,
4948
+ webSearchPreviewArgsSchema,
4949
+ webSearchPreviewInputSchema
4931
4950
  });
4932
4951
  //# sourceMappingURL=index.js.map