@ai-sdk/openai-compatible 1.0.0-alpha.9 → 1.0.0-beta.10

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/dist/index.js CHANGED
@@ -31,7 +31,7 @@ module.exports = __toCommonJS(src_exports);
31
31
  // src/openai-compatible-chat-language-model.ts
32
32
  var import_provider3 = require("@ai-sdk/provider");
33
33
  var import_provider_utils = require("@ai-sdk/provider-utils");
34
- var import_zod3 = require("zod");
34
+ var import_v43 = require("zod/v4");
35
35
 
36
36
  // src/convert-to-openai-compatible-chat-messages.ts
37
37
  var import_provider = require("@ai-sdk/provider");
@@ -103,7 +103,7 @@ function convertToOpenAICompatibleChatMessages(prompt) {
103
103
  type: "function",
104
104
  function: {
105
105
  name: part.toolName,
106
- arguments: JSON.stringify(part.args)
106
+ arguments: JSON.stringify(part.input)
107
107
  },
108
108
  ...partMetadata
109
109
  });
@@ -121,11 +121,24 @@ function convertToOpenAICompatibleChatMessages(prompt) {
121
121
  }
122
122
  case "tool": {
123
123
  for (const toolResponse of content) {
124
+ const output = toolResponse.output;
125
+ let contentValue;
126
+ switch (output.type) {
127
+ case "text":
128
+ case "error-text":
129
+ contentValue = output.value;
130
+ break;
131
+ case "content":
132
+ case "json":
133
+ case "error-json":
134
+ contentValue = JSON.stringify(output.value);
135
+ break;
136
+ }
124
137
  const toolResponseMetadata = getOpenAIMetadata(toolResponse);
125
138
  messages.push({
126
139
  role: "tool",
127
140
  tool_call_id: toolResponse.toolCallId,
128
- content: JSON.stringify(toolResponse.result),
141
+ content: contentValue,
129
142
  ...toolResponseMetadata
130
143
  });
131
144
  }
@@ -171,30 +184,30 @@ function mapOpenAICompatibleFinishReason(finishReason) {
171
184
  }
172
185
 
173
186
  // src/openai-compatible-chat-options.ts
174
- var import_zod = require("zod");
175
- var openaiCompatibleProviderOptions = import_zod.z.object({
187
+ var import_v4 = require("zod/v4");
188
+ var openaiCompatibleProviderOptions = import_v4.z.object({
176
189
  /**
177
190
  * A unique identifier representing your end-user, which can help the provider to
178
191
  * monitor and detect abuse.
179
192
  */
180
- user: import_zod.z.string().optional(),
193
+ user: import_v4.z.string().optional(),
181
194
  /**
182
195
  * Reasoning effort for reasoning models. Defaults to `medium`.
183
196
  */
184
- reasoningEffort: import_zod.z.enum(["low", "medium", "high"]).optional()
197
+ reasoningEffort: import_v4.z.string().optional()
185
198
  });
186
199
 
187
200
  // src/openai-compatible-error.ts
188
- var import_zod2 = require("zod");
189
- var openaiCompatibleErrorDataSchema = import_zod2.z.object({
190
- error: import_zod2.z.object({
191
- message: import_zod2.z.string(),
201
+ var import_v42 = require("zod/v4");
202
+ var openaiCompatibleErrorDataSchema = import_v42.z.object({
203
+ error: import_v42.z.object({
204
+ message: import_v42.z.string(),
192
205
  // The additional information below is handled loosely to support
193
206
  // OpenAI-compatible providers that have slightly different error
194
207
  // responses:
195
- type: import_zod2.z.string().nullish(),
196
- param: import_zod2.z.any().nullish(),
197
- code: import_zod2.z.union([import_zod2.z.string(), import_zod2.z.number()]).nullish()
208
+ type: import_v42.z.string().nullish(),
209
+ param: import_v42.z.any().nullish(),
210
+ code: import_v42.z.union([import_v42.z.string(), import_v42.z.number()]).nullish()
198
211
  })
199
212
  });
200
213
  var defaultOpenAICompatibleErrorStructure = {
@@ -223,7 +236,7 @@ function prepareTools({
223
236
  function: {
224
237
  name: tool.name,
225
238
  description: tool.description,
226
- parameters: tool.parameters
239
+ parameters: tool.inputSchema
227
240
  }
228
241
  });
229
242
  }
@@ -399,10 +412,9 @@ var OpenAICompatibleChatLanguageModel = class {
399
412
  for (const toolCall of choice.message.tool_calls) {
400
413
  content.push({
401
414
  type: "tool-call",
402
- toolCallType: "function",
403
415
  toolCallId: (_a = toolCall.id) != null ? _a : (0, import_provider_utils.generateId)(),
404
416
  toolName: toolCall.function.name,
405
- args: toolCall.function.arguments
417
+ input: toolCall.function.arguments
406
418
  });
407
419
  }
408
420
  }
@@ -480,6 +492,8 @@ var OpenAICompatibleChatLanguageModel = class {
480
492
  };
481
493
  let isFirstChunk = true;
482
494
  const providerOptionsName = this.providerOptionsName;
495
+ let isActiveReasoning = false;
496
+ let isActiveText = false;
483
497
  return {
484
498
  stream: response.pipeThrough(
485
499
  new TransformStream({
@@ -489,6 +503,9 @@ var OpenAICompatibleChatLanguageModel = class {
489
503
  // TODO we lost type safety on Chunk, most likely due to the error schema. MUST FIX
490
504
  transform(chunk, controller) {
491
505
  var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
506
+ if (options.includeRawChunks) {
507
+ controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
508
+ }
492
509
  if (!chunk.success) {
493
510
  finishReason = "error";
494
511
  controller.enqueue({ type: "error", error: chunk.error });
@@ -543,27 +560,34 @@ var OpenAICompatibleChatLanguageModel = class {
543
560
  }
544
561
  const delta = choice.delta;
545
562
  if (delta.reasoning_content != null) {
563
+ if (!isActiveReasoning) {
564
+ controller.enqueue({
565
+ type: "reasoning-start",
566
+ id: "reasoning-0"
567
+ });
568
+ isActiveReasoning = true;
569
+ }
546
570
  controller.enqueue({
547
- type: "reasoning",
548
- text: delta.reasoning_content
571
+ type: "reasoning-delta",
572
+ id: "reasoning-0",
573
+ delta: delta.reasoning_content
549
574
  });
550
575
  }
551
576
  if (delta.content != null) {
577
+ if (!isActiveText) {
578
+ controller.enqueue({ type: "text-start", id: "txt-0" });
579
+ isActiveText = true;
580
+ }
552
581
  controller.enqueue({
553
- type: "text",
554
- text: delta.content
582
+ type: "text-delta",
583
+ id: "txt-0",
584
+ delta: delta.content
555
585
  });
556
586
  }
557
587
  if (delta.tool_calls != null) {
558
588
  for (const toolCallDelta of delta.tool_calls) {
559
589
  const index = toolCallDelta.index;
560
590
  if (toolCalls[index] == null) {
561
- if (toolCallDelta.type !== "function") {
562
- throw new import_provider3.InvalidResponseDataError({
563
- data: toolCallDelta,
564
- message: `Expected 'function' type.`
565
- });
566
- }
567
591
  if (toolCallDelta.id == null) {
568
592
  throw new import_provider3.InvalidResponseDataError({
569
593
  data: toolCallDelta,
@@ -576,6 +600,11 @@ var OpenAICompatibleChatLanguageModel = class {
576
600
  message: `Expected 'function.name' to be a string.`
577
601
  });
578
602
  }
603
+ controller.enqueue({
604
+ type: "tool-input-start",
605
+ id: toolCallDelta.id,
606
+ toolName: toolCallDelta.function.name
607
+ });
579
608
  toolCalls[index] = {
580
609
  id: toolCallDelta.id,
581
610
  type: "function",
@@ -589,20 +618,21 @@ var OpenAICompatibleChatLanguageModel = class {
589
618
  if (((_c = toolCall2.function) == null ? void 0 : _c.name) != null && ((_d = toolCall2.function) == null ? void 0 : _d.arguments) != null) {
590
619
  if (toolCall2.function.arguments.length > 0) {
591
620
  controller.enqueue({
592
- type: "tool-call-delta",
593
- toolCallType: "function",
594
- toolCallId: toolCall2.id,
595
- toolName: toolCall2.function.name,
596
- argsTextDelta: toolCall2.function.arguments
621
+ type: "tool-input-start",
622
+ id: toolCall2.id,
623
+ toolName: toolCall2.function.name
597
624
  });
598
625
  }
599
626
  if ((0, import_provider_utils.isParsableJson)(toolCall2.function.arguments)) {
627
+ controller.enqueue({
628
+ type: "tool-input-end",
629
+ id: toolCall2.id
630
+ });
600
631
  controller.enqueue({
601
632
  type: "tool-call",
602
- toolCallType: "function",
603
633
  toolCallId: (_e = toolCall2.id) != null ? _e : (0, import_provider_utils.generateId)(),
604
634
  toolName: toolCall2.function.name,
605
- args: toolCall2.function.arguments
635
+ input: toolCall2.function.arguments
606
636
  });
607
637
  toolCall2.hasFinished = true;
608
638
  }
@@ -617,19 +647,20 @@ var OpenAICompatibleChatLanguageModel = class {
617
647
  toolCall.function.arguments += (_h = (_g = toolCallDelta.function) == null ? void 0 : _g.arguments) != null ? _h : "";
618
648
  }
619
649
  controller.enqueue({
620
- type: "tool-call-delta",
621
- toolCallType: "function",
622
- toolCallId: toolCall.id,
623
- toolName: toolCall.function.name,
624
- argsTextDelta: (_i = toolCallDelta.function.arguments) != null ? _i : ""
650
+ type: "tool-input-delta",
651
+ id: toolCall.id,
652
+ delta: (_i = toolCallDelta.function.arguments) != null ? _i : ""
625
653
  });
626
654
  if (((_j = toolCall.function) == null ? void 0 : _j.name) != null && ((_k = toolCall.function) == null ? void 0 : _k.arguments) != null && (0, import_provider_utils.isParsableJson)(toolCall.function.arguments)) {
655
+ controller.enqueue({
656
+ type: "tool-input-end",
657
+ id: toolCall.id
658
+ });
627
659
  controller.enqueue({
628
660
  type: "tool-call",
629
- toolCallType: "function",
630
661
  toolCallId: (_l = toolCall.id) != null ? _l : (0, import_provider_utils.generateId)(),
631
662
  toolName: toolCall.function.name,
632
- args: toolCall.function.arguments
663
+ input: toolCall.function.arguments
633
664
  });
634
665
  toolCall.hasFinished = true;
635
666
  }
@@ -637,7 +668,27 @@ var OpenAICompatibleChatLanguageModel = class {
637
668
  }
638
669
  },
639
670
  flush(controller) {
640
- var _a2, _b, _c, _d, _e;
671
+ var _a2, _b, _c, _d, _e, _f;
672
+ if (isActiveReasoning) {
673
+ controller.enqueue({ type: "reasoning-end", id: "reasoning-0" });
674
+ }
675
+ if (isActiveText) {
676
+ controller.enqueue({ type: "text-end", id: "txt-0" });
677
+ }
678
+ for (const toolCall of toolCalls.filter(
679
+ (toolCall2) => !toolCall2.hasFinished
680
+ )) {
681
+ controller.enqueue({
682
+ type: "tool-input-end",
683
+ id: toolCall.id
684
+ });
685
+ controller.enqueue({
686
+ type: "tool-call",
687
+ toolCallId: (_a2 = toolCall.id) != null ? _a2 : (0, import_provider_utils.generateId)(),
688
+ toolName: toolCall.function.name,
689
+ input: toolCall.function.arguments
690
+ });
691
+ }
641
692
  const providerMetadata = {
642
693
  [providerOptionsName]: {},
643
694
  ...metadataExtractor == null ? void 0 : metadataExtractor.buildMetadata()
@@ -652,11 +703,11 @@ var OpenAICompatibleChatLanguageModel = class {
652
703
  type: "finish",
653
704
  finishReason,
654
705
  usage: {
655
- inputTokens: (_a2 = usage.promptTokens) != null ? _a2 : void 0,
656
- outputTokens: (_b = usage.completionTokens) != null ? _b : void 0,
657
- totalTokens: (_c = usage.totalTokens) != null ? _c : void 0,
658
- reasoningTokens: (_d = usage.completionTokensDetails.reasoningTokens) != null ? _d : void 0,
659
- cachedInputTokens: (_e = usage.promptTokensDetails.cachedTokens) != null ? _e : void 0
706
+ inputTokens: (_b = usage.promptTokens) != null ? _b : void 0,
707
+ outputTokens: (_c = usage.completionTokens) != null ? _c : void 0,
708
+ totalTokens: (_d = usage.totalTokens) != null ? _d : void 0,
709
+ reasoningTokens: (_e = usage.completionTokensDetails.reasoningTokens) != null ? _e : void 0,
710
+ cachedInputTokens: (_f = usage.promptTokensDetails.cachedTokens) != null ? _f : void 0
660
711
  },
661
712
  providerMetadata
662
713
  });
@@ -668,69 +719,67 @@ var OpenAICompatibleChatLanguageModel = class {
668
719
  };
669
720
  }
670
721
  };
671
- var openaiCompatibleTokenUsageSchema = import_zod3.z.object({
672
- prompt_tokens: import_zod3.z.number().nullish(),
673
- completion_tokens: import_zod3.z.number().nullish(),
674
- total_tokens: import_zod3.z.number().nullish(),
675
- prompt_tokens_details: import_zod3.z.object({
676
- cached_tokens: import_zod3.z.number().nullish()
722
+ var openaiCompatibleTokenUsageSchema = import_v43.z.object({
723
+ prompt_tokens: import_v43.z.number().nullish(),
724
+ completion_tokens: import_v43.z.number().nullish(),
725
+ total_tokens: import_v43.z.number().nullish(),
726
+ prompt_tokens_details: import_v43.z.object({
727
+ cached_tokens: import_v43.z.number().nullish()
677
728
  }).nullish(),
678
- completion_tokens_details: import_zod3.z.object({
679
- reasoning_tokens: import_zod3.z.number().nullish(),
680
- accepted_prediction_tokens: import_zod3.z.number().nullish(),
681
- rejected_prediction_tokens: import_zod3.z.number().nullish()
729
+ completion_tokens_details: import_v43.z.object({
730
+ reasoning_tokens: import_v43.z.number().nullish(),
731
+ accepted_prediction_tokens: import_v43.z.number().nullish(),
732
+ rejected_prediction_tokens: import_v43.z.number().nullish()
682
733
  }).nullish()
683
734
  }).nullish();
684
- var OpenAICompatibleChatResponseSchema = import_zod3.z.object({
685
- id: import_zod3.z.string().nullish(),
686
- created: import_zod3.z.number().nullish(),
687
- model: import_zod3.z.string().nullish(),
688
- choices: import_zod3.z.array(
689
- import_zod3.z.object({
690
- message: import_zod3.z.object({
691
- role: import_zod3.z.literal("assistant").nullish(),
692
- content: import_zod3.z.string().nullish(),
693
- reasoning_content: import_zod3.z.string().nullish(),
694
- tool_calls: import_zod3.z.array(
695
- import_zod3.z.object({
696
- id: import_zod3.z.string().nullish(),
697
- type: import_zod3.z.literal("function"),
698
- function: import_zod3.z.object({
699
- name: import_zod3.z.string(),
700
- arguments: import_zod3.z.string()
735
+ var OpenAICompatibleChatResponseSchema = import_v43.z.object({
736
+ id: import_v43.z.string().nullish(),
737
+ created: import_v43.z.number().nullish(),
738
+ model: import_v43.z.string().nullish(),
739
+ choices: import_v43.z.array(
740
+ import_v43.z.object({
741
+ message: import_v43.z.object({
742
+ role: import_v43.z.literal("assistant").nullish(),
743
+ content: import_v43.z.string().nullish(),
744
+ reasoning_content: import_v43.z.string().nullish(),
745
+ tool_calls: import_v43.z.array(
746
+ import_v43.z.object({
747
+ id: import_v43.z.string().nullish(),
748
+ function: import_v43.z.object({
749
+ name: import_v43.z.string(),
750
+ arguments: import_v43.z.string()
701
751
  })
702
752
  })
703
753
  ).nullish()
704
754
  }),
705
- finish_reason: import_zod3.z.string().nullish()
755
+ finish_reason: import_v43.z.string().nullish()
706
756
  })
707
757
  ),
708
758
  usage: openaiCompatibleTokenUsageSchema
709
759
  });
710
- var createOpenAICompatibleChatChunkSchema = (errorSchema) => import_zod3.z.union([
711
- import_zod3.z.object({
712
- id: import_zod3.z.string().nullish(),
713
- created: import_zod3.z.number().nullish(),
714
- model: import_zod3.z.string().nullish(),
715
- choices: import_zod3.z.array(
716
- import_zod3.z.object({
717
- delta: import_zod3.z.object({
718
- role: import_zod3.z.enum(["assistant"]).nullish(),
719
- content: import_zod3.z.string().nullish(),
720
- reasoning_content: import_zod3.z.string().nullish(),
721
- tool_calls: import_zod3.z.array(
722
- import_zod3.z.object({
723
- index: import_zod3.z.number(),
724
- id: import_zod3.z.string().nullish(),
725
- type: import_zod3.z.literal("function").nullish(),
726
- function: import_zod3.z.object({
727
- name: import_zod3.z.string().nullish(),
728
- arguments: import_zod3.z.string().nullish()
760
+ var createOpenAICompatibleChatChunkSchema = (errorSchema) => import_v43.z.union([
761
+ import_v43.z.object({
762
+ id: import_v43.z.string().nullish(),
763
+ created: import_v43.z.number().nullish(),
764
+ model: import_v43.z.string().nullish(),
765
+ choices: import_v43.z.array(
766
+ import_v43.z.object({
767
+ delta: import_v43.z.object({
768
+ role: import_v43.z.enum(["assistant"]).nullish(),
769
+ content: import_v43.z.string().nullish(),
770
+ reasoning_content: import_v43.z.string().nullish(),
771
+ tool_calls: import_v43.z.array(
772
+ import_v43.z.object({
773
+ index: import_v43.z.number(),
774
+ id: import_v43.z.string().nullish(),
775
+ function: import_v43.z.object({
776
+ name: import_v43.z.string().nullish(),
777
+ arguments: import_v43.z.string().nullish()
729
778
  })
730
779
  })
731
780
  ).nullish()
732
781
  }).nullish(),
733
- finish_reason: import_zod3.z.string().nullish()
782
+ finish_reason: import_v43.z.string().nullish()
734
783
  })
735
784
  ),
736
785
  usage: openaiCompatibleTokenUsageSchema
@@ -740,7 +789,7 @@ var createOpenAICompatibleChatChunkSchema = (errorSchema) => import_zod3.z.union
740
789
 
741
790
  // src/openai-compatible-completion-language-model.ts
742
791
  var import_provider_utils2 = require("@ai-sdk/provider-utils");
743
- var import_zod5 = require("zod");
792
+ var import_v45 = require("zod/v4");
744
793
 
745
794
  // src/convert-to-openai-compatible-completion-prompt.ts
746
795
  var import_provider4 = require("@ai-sdk/provider");
@@ -818,28 +867,28 @@ ${user}:`]
818
867
  }
819
868
 
820
869
  // src/openai-compatible-completion-options.ts
821
- var import_zod4 = require("zod");
822
- var openaiCompatibleCompletionProviderOptions = import_zod4.z.object({
870
+ var import_v44 = require("zod/v4");
871
+ var openaiCompatibleCompletionProviderOptions = import_v44.z.object({
823
872
  /**
824
873
  * Echo back the prompt in addition to the completion.
825
874
  */
826
- echo: import_zod4.z.boolean().optional(),
875
+ echo: import_v44.z.boolean().optional(),
827
876
  /**
828
877
  * Modify the likelihood of specified tokens appearing in the completion.
829
878
  *
830
879
  * Accepts a JSON object that maps tokens (specified by their token ID in
831
880
  * the GPT tokenizer) to an associated bias value from -100 to 100.
832
881
  */
833
- logitBias: import_zod4.z.record(import_zod4.z.string(), import_zod4.z.number()).optional(),
882
+ logitBias: import_v44.z.record(import_v44.z.string(), import_v44.z.number()).optional(),
834
883
  /**
835
884
  * The suffix that comes after a completion of inserted text.
836
885
  */
837
- suffix: import_zod4.z.string().optional(),
886
+ suffix: import_v44.z.string().optional(),
838
887
  /**
839
888
  * A unique identifier representing your end-user, which can help providers to
840
889
  * monitor and detect abuse.
841
890
  */
842
- user: import_zod4.z.string().optional()
891
+ user: import_v44.z.string().optional()
843
892
  });
844
893
 
845
894
  // src/openai-compatible-completion-language-model.ts
@@ -1011,6 +1060,9 @@ var OpenAICompatibleCompletionLanguageModel = class {
1011
1060
  },
1012
1061
  transform(chunk, controller) {
1013
1062
  var _a, _b, _c;
1063
+ if (options.includeRawChunks) {
1064
+ controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
1065
+ }
1014
1066
  if (!chunk.success) {
1015
1067
  finishReason = "error";
1016
1068
  controller.enqueue({ type: "error", error: chunk.error });
@@ -1028,6 +1080,10 @@ var OpenAICompatibleCompletionLanguageModel = class {
1028
1080
  type: "response-metadata",
1029
1081
  ...getResponseMetadata(value)
1030
1082
  });
1083
+ controller.enqueue({
1084
+ type: "text-start",
1085
+ id: "0"
1086
+ });
1031
1087
  }
1032
1088
  if (value.usage != null) {
1033
1089
  usage.inputTokens = (_a = value.usage.prompt_tokens) != null ? _a : void 0;
@@ -1042,12 +1098,16 @@ var OpenAICompatibleCompletionLanguageModel = class {
1042
1098
  }
1043
1099
  if ((choice == null ? void 0 : choice.text) != null) {
1044
1100
  controller.enqueue({
1045
- type: "text",
1046
- text: choice.text
1101
+ type: "text-delta",
1102
+ id: "0",
1103
+ delta: choice.text
1047
1104
  });
1048
1105
  }
1049
1106
  },
1050
1107
  flush(controller) {
1108
+ if (!isFirstChunk) {
1109
+ controller.enqueue({ type: "text-end", id: "0" });
1110
+ }
1051
1111
  controller.enqueue({
1052
1112
  type: "finish",
1053
1113
  finishReason,
@@ -1061,33 +1121,33 @@ var OpenAICompatibleCompletionLanguageModel = class {
1061
1121
  };
1062
1122
  }
1063
1123
  };
1064
- var usageSchema = import_zod5.z.object({
1065
- prompt_tokens: import_zod5.z.number(),
1066
- completion_tokens: import_zod5.z.number(),
1067
- total_tokens: import_zod5.z.number()
1124
+ var usageSchema = import_v45.z.object({
1125
+ prompt_tokens: import_v45.z.number(),
1126
+ completion_tokens: import_v45.z.number(),
1127
+ total_tokens: import_v45.z.number()
1068
1128
  });
1069
- var openaiCompatibleCompletionResponseSchema = import_zod5.z.object({
1070
- id: import_zod5.z.string().nullish(),
1071
- created: import_zod5.z.number().nullish(),
1072
- model: import_zod5.z.string().nullish(),
1073
- choices: import_zod5.z.array(
1074
- import_zod5.z.object({
1075
- text: import_zod5.z.string(),
1076
- finish_reason: import_zod5.z.string()
1129
+ var openaiCompatibleCompletionResponseSchema = import_v45.z.object({
1130
+ id: import_v45.z.string().nullish(),
1131
+ created: import_v45.z.number().nullish(),
1132
+ model: import_v45.z.string().nullish(),
1133
+ choices: import_v45.z.array(
1134
+ import_v45.z.object({
1135
+ text: import_v45.z.string(),
1136
+ finish_reason: import_v45.z.string()
1077
1137
  })
1078
1138
  ),
1079
1139
  usage: usageSchema.nullish()
1080
1140
  });
1081
- var createOpenAICompatibleCompletionChunkSchema = (errorSchema) => import_zod5.z.union([
1082
- import_zod5.z.object({
1083
- id: import_zod5.z.string().nullish(),
1084
- created: import_zod5.z.number().nullish(),
1085
- model: import_zod5.z.string().nullish(),
1086
- choices: import_zod5.z.array(
1087
- import_zod5.z.object({
1088
- text: import_zod5.z.string(),
1089
- finish_reason: import_zod5.z.string().nullish(),
1090
- index: import_zod5.z.number()
1141
+ var createOpenAICompatibleCompletionChunkSchema = (errorSchema) => import_v45.z.union([
1142
+ import_v45.z.object({
1143
+ id: import_v45.z.string().nullish(),
1144
+ created: import_v45.z.number().nullish(),
1145
+ model: import_v45.z.string().nullish(),
1146
+ choices: import_v45.z.array(
1147
+ import_v45.z.object({
1148
+ text: import_v45.z.string(),
1149
+ finish_reason: import_v45.z.string().nullish(),
1150
+ index: import_v45.z.number()
1091
1151
  })
1092
1152
  ),
1093
1153
  usage: usageSchema.nullish()
@@ -1098,21 +1158,21 @@ var createOpenAICompatibleCompletionChunkSchema = (errorSchema) => import_zod5.z
1098
1158
  // src/openai-compatible-embedding-model.ts
1099
1159
  var import_provider5 = require("@ai-sdk/provider");
1100
1160
  var import_provider_utils3 = require("@ai-sdk/provider-utils");
1101
- var import_zod7 = require("zod");
1161
+ var import_v47 = require("zod/v4");
1102
1162
 
1103
1163
  // src/openai-compatible-embedding-options.ts
1104
- var import_zod6 = require("zod");
1105
- var openaiCompatibleEmbeddingProviderOptions = import_zod6.z.object({
1164
+ var import_v46 = require("zod/v4");
1165
+ var openaiCompatibleEmbeddingProviderOptions = import_v46.z.object({
1106
1166
  /**
1107
1167
  * The number of dimensions the resulting output embeddings should have.
1108
1168
  * Only supported in text-embedding-3 and later models.
1109
1169
  */
1110
- dimensions: import_zod6.z.number().optional(),
1170
+ dimensions: import_v46.z.number().optional(),
1111
1171
  /**
1112
1172
  * A unique identifier representing your end-user, which can help providers to
1113
1173
  * monitor and detect abuse.
1114
1174
  */
1115
- user: import_zod6.z.string().optional()
1175
+ user: import_v46.z.string().optional()
1116
1176
  });
1117
1177
 
1118
1178
  // src/openai-compatible-embedding-model.ts
@@ -1196,14 +1256,14 @@ var OpenAICompatibleEmbeddingModel = class {
1196
1256
  };
1197
1257
  }
1198
1258
  };
1199
- var openaiTextEmbeddingResponseSchema = import_zod7.z.object({
1200
- data: import_zod7.z.array(import_zod7.z.object({ embedding: import_zod7.z.array(import_zod7.z.number()) })),
1201
- usage: import_zod7.z.object({ prompt_tokens: import_zod7.z.number() }).nullish()
1259
+ var openaiTextEmbeddingResponseSchema = import_v47.z.object({
1260
+ data: import_v47.z.array(import_v47.z.object({ embedding: import_v47.z.array(import_v47.z.number()) })),
1261
+ usage: import_v47.z.object({ prompt_tokens: import_v47.z.number() }).nullish()
1202
1262
  });
1203
1263
 
1204
1264
  // src/openai-compatible-image-model.ts
1205
1265
  var import_provider_utils4 = require("@ai-sdk/provider-utils");
1206
- var import_zod8 = require("zod");
1266
+ var import_v48 = require("zod/v4");
1207
1267
  var OpenAICompatibleImageModel = class {
1208
1268
  constructor(modelId, config) {
1209
1269
  this.modelId = modelId;
@@ -1271,8 +1331,8 @@ var OpenAICompatibleImageModel = class {
1271
1331
  };
1272
1332
  }
1273
1333
  };
1274
- var openaiCompatibleImageResponseSchema = import_zod8.z.object({
1275
- data: import_zod8.z.array(import_zod8.z.object({ b64_json: import_zod8.z.string() }))
1334
+ var openaiCompatibleImageResponseSchema = import_v48.z.object({
1335
+ data: import_v48.z.array(import_v48.z.object({ b64_json: import_v48.z.string() }))
1276
1336
  });
1277
1337
 
1278
1338
  // src/openai-compatible-provider.ts
@@ -1297,14 +1357,14 @@ function createOpenAICompatible(options) {
1297
1357
  fetch: options.fetch
1298
1358
  });
1299
1359
  const createLanguageModel = (modelId) => createChatModel(modelId);
1300
- const createChatModel = (modelId) => new OpenAICompatibleChatLanguageModel(
1301
- modelId,
1302
- getCommonModelConfig("chat")
1303
- );
1304
- const createCompletionModel = (modelId) => new OpenAICompatibleCompletionLanguageModel(
1305
- modelId,
1306
- getCommonModelConfig("completion")
1307
- );
1360
+ const createChatModel = (modelId) => new OpenAICompatibleChatLanguageModel(modelId, {
1361
+ ...getCommonModelConfig("chat"),
1362
+ includeUsage: options.includeUsage
1363
+ });
1364
+ const createCompletionModel = (modelId) => new OpenAICompatibleCompletionLanguageModel(modelId, {
1365
+ ...getCommonModelConfig("completion"),
1366
+ includeUsage: options.includeUsage
1367
+ });
1308
1368
  const createEmbeddingModel = (modelId) => new OpenAICompatibleEmbeddingModel(modelId, {
1309
1369
  ...getCommonModelConfig("embedding")
1310
1370
  });