@ai-sdk/openai-compatible 1.0.0-canary.6 → 1.0.0-canary.7

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_zod2 = require("zod");
34
+ var import_zod3 = require("zod");
35
35
 
36
36
  // src/convert-to-openai-compatible-chat-messages.ts
37
37
  var import_provider = require("@ai-sdk/provider");
@@ -170,17 +170,27 @@ function mapOpenAICompatibleFinishReason(finishReason) {
170
170
  }
171
171
  }
172
172
 
173
- // src/openai-compatible-error.ts
173
+ // src/openai-compatible-chat-options.ts
174
174
  var import_zod = require("zod");
175
- var openaiCompatibleErrorDataSchema = import_zod.z.object({
176
- error: import_zod.z.object({
177
- message: import_zod.z.string(),
175
+ var openaiCompatibleProviderOptions = import_zod.z.object({
176
+ /**
177
+ * A unique identifier representing your end-user, which can help the provider to
178
+ * monitor and detect abuse.
179
+ */
180
+ user: import_zod.z.string().optional()
181
+ });
182
+
183
+ // src/openai-compatible-error.ts
184
+ var import_zod2 = require("zod");
185
+ var openaiCompatibleErrorDataSchema = import_zod2.z.object({
186
+ error: import_zod2.z.object({
187
+ message: import_zod2.z.string(),
178
188
  // The additional information below is handled loosely to support
179
189
  // OpenAI-compatible providers that have slightly different error
180
190
  // responses:
181
- type: import_zod.z.string().nullish(),
182
- param: import_zod.z.any().nullish(),
183
- code: import_zod.z.union([import_zod.z.string(), import_zod.z.number()]).nullish()
191
+ type: import_zod2.z.string().nullish(),
192
+ param: import_zod2.z.any().nullish(),
193
+ code: import_zod2.z.union([import_zod2.z.string(), import_zod2.z.number()]).nullish()
184
194
  })
185
195
  });
186
196
  var defaultOpenAICompatibleErrorStructure = {
@@ -244,11 +254,10 @@ function prepareTools({
244
254
  // src/openai-compatible-chat-language-model.ts
245
255
  var OpenAICompatibleChatLanguageModel = class {
246
256
  // type inferred via constructor
247
- constructor(modelId, settings, config) {
257
+ constructor(modelId, config) {
248
258
  this.specificationVersion = "v2";
249
259
  var _a, _b;
250
260
  this.modelId = modelId;
251
- this.settings = settings;
252
261
  this.config = config;
253
262
  const errorStructure = (_a = config.errorStructure) != null ? _a : defaultOpenAICompatibleErrorStructure;
254
263
  this.chunkSchema = createOpenAICompatibleChatChunkSchema(
@@ -281,8 +290,20 @@ var OpenAICompatibleChatLanguageModel = class {
281
290
  toolChoice,
282
291
  tools
283
292
  }) {
284
- var _a;
293
+ var _a, _b, _c;
285
294
  const warnings = [];
295
+ const compatibleOptions = Object.assign(
296
+ (_a = (0, import_provider_utils.parseProviderOptions)({
297
+ provider: "openai-compatible",
298
+ providerOptions,
299
+ schema: openaiCompatibleProviderOptions
300
+ })) != null ? _a : {},
301
+ (_b = (0, import_provider_utils.parseProviderOptions)({
302
+ provider: this.providerOptionsName,
303
+ providerOptions,
304
+ schema: openaiCompatibleProviderOptions
305
+ })) != null ? _b : {}
306
+ );
286
307
  if (topK != null) {
287
308
  warnings.push({ type: "unsupported-setting", setting: "topK" });
288
309
  }
@@ -306,7 +327,7 @@ var OpenAICompatibleChatLanguageModel = class {
306
327
  // model id:
307
328
  model: this.modelId,
308
329
  // model specific settings:
309
- user: this.settings.user,
330
+ user: compatibleOptions.user,
310
331
  // standardized settings:
311
332
  max_tokens: maxOutputTokens,
312
333
  temperature,
@@ -317,7 +338,7 @@ var OpenAICompatibleChatLanguageModel = class {
317
338
  type: "json_schema",
318
339
  json_schema: {
319
340
  schema: responseFormat.schema,
320
- name: (_a = responseFormat.name) != null ? _a : "response",
341
+ name: (_c = responseFormat.name) != null ? _c : "response",
321
342
  description: responseFormat.description
322
343
  }
323
344
  } : { type: "json_object" } : void 0,
@@ -334,7 +355,7 @@ var OpenAICompatibleChatLanguageModel = class {
334
355
  };
335
356
  }
336
357
  async doGenerate(options) {
337
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
358
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
338
359
  const { args, warnings } = this.getArgs({ ...options });
339
360
  const body = JSON.stringify(args);
340
361
  const {
@@ -378,11 +399,18 @@ var OpenAICompatibleChatLanguageModel = class {
378
399
  providerMetadata[this.providerOptionsName].cachedPromptTokens = promptTokenDetails == null ? void 0 : promptTokenDetails.cached_tokens;
379
400
  }
380
401
  return {
381
- text: (_e = choice.message.content) != null ? _e : void 0,
382
- reasoning: (_f = choice.message.reasoning_content) != null ? _f : void 0,
383
- toolCalls: (_g = choice.message.tool_calls) == null ? void 0 : _g.map((toolCall) => {
402
+ text: choice.message.content != null ? { type: "text", text: choice.message.content } : void 0,
403
+ reasoning: choice.message.reasoning_content ? [
404
+ {
405
+ type: "reasoning",
406
+ reasoningType: "text",
407
+ text: choice.message.reasoning_content
408
+ }
409
+ ] : void 0,
410
+ toolCalls: (_e = choice.message.tool_calls) == null ? void 0 : _e.map((toolCall) => {
384
411
  var _a2;
385
412
  return {
413
+ type: "tool-call",
386
414
  toolCallType: "function",
387
415
  toolCallId: (_a2 = toolCall.id) != null ? _a2 : (0, import_provider_utils.generateId)(),
388
416
  toolName: toolCall.function.name,
@@ -391,8 +419,8 @@ var OpenAICompatibleChatLanguageModel = class {
391
419
  }),
392
420
  finishReason: mapOpenAICompatibleFinishReason(choice.finish_reason),
393
421
  usage: {
394
- inputTokens: (_i = (_h = responseBody.usage) == null ? void 0 : _h.prompt_tokens) != null ? _i : void 0,
395
- outputTokens: (_k = (_j = responseBody.usage) == null ? void 0 : _j.completion_tokens) != null ? _k : void 0
422
+ inputTokens: (_g = (_f = responseBody.usage) == null ? void 0 : _f.prompt_tokens) != null ? _g : void 0,
423
+ outputTokens: (_i = (_h = responseBody.usage) == null ? void 0 : _h.completion_tokens) != null ? _i : void 0
396
424
  },
397
425
  providerMetadata,
398
426
  request: { body },
@@ -502,13 +530,14 @@ var OpenAICompatibleChatLanguageModel = class {
502
530
  if (delta.reasoning_content != null) {
503
531
  controller.enqueue({
504
532
  type: "reasoning",
505
- textDelta: delta.reasoning_content
533
+ reasoningType: "text",
534
+ text: delta.reasoning_content
506
535
  });
507
536
  }
508
537
  if (delta.content != null) {
509
538
  controller.enqueue({
510
- type: "text-delta",
511
- textDelta: delta.content
539
+ type: "text",
540
+ text: delta.content
512
541
  });
513
542
  }
514
543
  if (delta.tool_calls != null) {
@@ -629,68 +658,68 @@ var OpenAICompatibleChatLanguageModel = class {
629
658
  };
630
659
  }
631
660
  };
632
- var openaiCompatibleTokenUsageSchema = import_zod2.z.object({
633
- prompt_tokens: import_zod2.z.number().nullish(),
634
- completion_tokens: import_zod2.z.number().nullish(),
635
- prompt_tokens_details: import_zod2.z.object({
636
- cached_tokens: import_zod2.z.number().nullish()
661
+ var openaiCompatibleTokenUsageSchema = import_zod3.z.object({
662
+ prompt_tokens: import_zod3.z.number().nullish(),
663
+ completion_tokens: import_zod3.z.number().nullish(),
664
+ prompt_tokens_details: import_zod3.z.object({
665
+ cached_tokens: import_zod3.z.number().nullish()
637
666
  }).nullish(),
638
- completion_tokens_details: import_zod2.z.object({
639
- reasoning_tokens: import_zod2.z.number().nullish(),
640
- accepted_prediction_tokens: import_zod2.z.number().nullish(),
641
- rejected_prediction_tokens: import_zod2.z.number().nullish()
667
+ completion_tokens_details: import_zod3.z.object({
668
+ reasoning_tokens: import_zod3.z.number().nullish(),
669
+ accepted_prediction_tokens: import_zod3.z.number().nullish(),
670
+ rejected_prediction_tokens: import_zod3.z.number().nullish()
642
671
  }).nullish()
643
672
  }).nullish();
644
- var OpenAICompatibleChatResponseSchema = import_zod2.z.object({
645
- id: import_zod2.z.string().nullish(),
646
- created: import_zod2.z.number().nullish(),
647
- model: import_zod2.z.string().nullish(),
648
- choices: import_zod2.z.array(
649
- import_zod2.z.object({
650
- message: import_zod2.z.object({
651
- role: import_zod2.z.literal("assistant").nullish(),
652
- content: import_zod2.z.string().nullish(),
653
- reasoning_content: import_zod2.z.string().nullish(),
654
- tool_calls: import_zod2.z.array(
655
- import_zod2.z.object({
656
- id: import_zod2.z.string().nullish(),
657
- type: import_zod2.z.literal("function"),
658
- function: import_zod2.z.object({
659
- name: import_zod2.z.string(),
660
- arguments: import_zod2.z.string()
673
+ var OpenAICompatibleChatResponseSchema = import_zod3.z.object({
674
+ id: import_zod3.z.string().nullish(),
675
+ created: import_zod3.z.number().nullish(),
676
+ model: import_zod3.z.string().nullish(),
677
+ choices: import_zod3.z.array(
678
+ import_zod3.z.object({
679
+ message: import_zod3.z.object({
680
+ role: import_zod3.z.literal("assistant").nullish(),
681
+ content: import_zod3.z.string().nullish(),
682
+ reasoning_content: import_zod3.z.string().nullish(),
683
+ tool_calls: import_zod3.z.array(
684
+ import_zod3.z.object({
685
+ id: import_zod3.z.string().nullish(),
686
+ type: import_zod3.z.literal("function"),
687
+ function: import_zod3.z.object({
688
+ name: import_zod3.z.string(),
689
+ arguments: import_zod3.z.string()
661
690
  })
662
691
  })
663
692
  ).nullish()
664
693
  }),
665
- finish_reason: import_zod2.z.string().nullish()
694
+ finish_reason: import_zod3.z.string().nullish()
666
695
  })
667
696
  ),
668
697
  usage: openaiCompatibleTokenUsageSchema
669
698
  });
670
- var createOpenAICompatibleChatChunkSchema = (errorSchema) => import_zod2.z.union([
671
- import_zod2.z.object({
672
- id: import_zod2.z.string().nullish(),
673
- created: import_zod2.z.number().nullish(),
674
- model: import_zod2.z.string().nullish(),
675
- choices: import_zod2.z.array(
676
- import_zod2.z.object({
677
- delta: import_zod2.z.object({
678
- role: import_zod2.z.enum(["assistant"]).nullish(),
679
- content: import_zod2.z.string().nullish(),
680
- reasoning_content: import_zod2.z.string().nullish(),
681
- tool_calls: import_zod2.z.array(
682
- import_zod2.z.object({
683
- index: import_zod2.z.number(),
684
- id: import_zod2.z.string().nullish(),
685
- type: import_zod2.z.literal("function").optional(),
686
- function: import_zod2.z.object({
687
- name: import_zod2.z.string().nullish(),
688
- arguments: import_zod2.z.string().nullish()
699
+ var createOpenAICompatibleChatChunkSchema = (errorSchema) => import_zod3.z.union([
700
+ import_zod3.z.object({
701
+ id: import_zod3.z.string().nullish(),
702
+ created: import_zod3.z.number().nullish(),
703
+ model: import_zod3.z.string().nullish(),
704
+ choices: import_zod3.z.array(
705
+ import_zod3.z.object({
706
+ delta: import_zod3.z.object({
707
+ role: import_zod3.z.enum(["assistant"]).nullish(),
708
+ content: import_zod3.z.string().nullish(),
709
+ reasoning_content: import_zod3.z.string().nullish(),
710
+ tool_calls: import_zod3.z.array(
711
+ import_zod3.z.object({
712
+ index: import_zod3.z.number(),
713
+ id: import_zod3.z.string().nullish(),
714
+ type: import_zod3.z.literal("function").optional(),
715
+ function: import_zod3.z.object({
716
+ name: import_zod3.z.string().nullish(),
717
+ arguments: import_zod3.z.string().nullish()
689
718
  })
690
719
  })
691
720
  ).nullish()
692
721
  }).nullish(),
693
- finish_reason: import_zod2.z.string().nullish()
722
+ finish_reason: import_zod3.z.string().nullish()
694
723
  })
695
724
  ),
696
725
  usage: openaiCompatibleTokenUsageSchema
@@ -700,7 +729,7 @@ var createOpenAICompatibleChatChunkSchema = (errorSchema) => import_zod2.z.union
700
729
 
701
730
  // src/openai-compatible-completion-language-model.ts
702
731
  var import_provider_utils2 = require("@ai-sdk/provider-utils");
703
- var import_zod3 = require("zod");
732
+ var import_zod5 = require("zod");
704
733
 
705
734
  // src/convert-to-openai-compatible-completion-prompt.ts
706
735
  var import_provider4 = require("@ai-sdk/provider");
@@ -781,15 +810,39 @@ ${user}:`]
781
810
  };
782
811
  }
783
812
 
813
+ // src/openai-compatible-completion-options.ts
814
+ var import_zod4 = require("zod");
815
+ var openaiCompatibleCompletionProviderOptions = import_zod4.z.object({
816
+ /**
817
+ * Echo back the prompt in addition to the completion.
818
+ */
819
+ echo: import_zod4.z.boolean().optional(),
820
+ /**
821
+ * Modify the likelihood of specified tokens appearing in the completion.
822
+ *
823
+ * Accepts a JSON object that maps tokens (specified by their token ID in
824
+ * the GPT tokenizer) to an associated bias value from -100 to 100.
825
+ */
826
+ logitBias: import_zod4.z.record(import_zod4.z.number(), import_zod4.z.number()).optional(),
827
+ /**
828
+ * The suffix that comes after a completion of inserted text.
829
+ */
830
+ suffix: import_zod4.z.string().optional(),
831
+ /**
832
+ * A unique identifier representing your end-user, which can help providers to
833
+ * monitor and detect abuse.
834
+ */
835
+ user: import_zod4.z.string().optional()
836
+ });
837
+
784
838
  // src/openai-compatible-completion-language-model.ts
785
839
  var OpenAICompatibleCompletionLanguageModel = class {
786
840
  // type inferred via constructor
787
- constructor(modelId, settings, config) {
841
+ constructor(modelId, config) {
788
842
  this.specificationVersion = "v2";
789
843
  this.defaultObjectGenerationMode = void 0;
790
844
  var _a;
791
845
  this.modelId = modelId;
792
- this.settings = settings;
793
846
  this.config = config;
794
847
  const errorStructure = (_a = config.errorStructure) != null ? _a : defaultOpenAICompatibleErrorStructure;
795
848
  this.chunkSchema = createOpenAICompatibleCompletionChunkSchema(
@@ -819,7 +872,13 @@ var OpenAICompatibleCompletionLanguageModel = class {
819
872
  tools,
820
873
  toolChoice
821
874
  }) {
875
+ var _a;
822
876
  const warnings = [];
877
+ const completionOptions = (_a = (0, import_provider_utils2.parseProviderOptions)({
878
+ provider: this.providerOptionsName,
879
+ providerOptions,
880
+ schema: openaiCompatibleCompletionProviderOptions
881
+ })) != null ? _a : {};
823
882
  if (topK != null) {
824
883
  warnings.push({ type: "unsupported-setting", setting: "topK" });
825
884
  }
@@ -843,10 +902,10 @@ var OpenAICompatibleCompletionLanguageModel = class {
843
902
  // model id:
844
903
  model: this.modelId,
845
904
  // model specific settings:
846
- echo: this.settings.echo,
847
- logit_bias: this.settings.logitBias,
848
- suffix: this.settings.suffix,
849
- user: this.settings.user,
905
+ echo: completionOptions.echo,
906
+ logit_bias: completionOptions.logitBias,
907
+ suffix: completionOptions.suffix,
908
+ user: completionOptions.user,
850
909
  // standardized settings:
851
910
  max_tokens: maxOutputTokens,
852
911
  temperature,
@@ -886,7 +945,7 @@ var OpenAICompatibleCompletionLanguageModel = class {
886
945
  });
887
946
  const choice = response.choices[0];
888
947
  return {
889
- text: choice.text,
948
+ text: { type: "text", text: choice.text },
890
949
  usage: {
891
950
  inputTokens: (_b = (_a = response.usage) == null ? void 0 : _a.prompt_tokens) != null ? _b : void 0,
892
951
  outputTokens: (_d = (_c = response.usage) == null ? void 0 : _c.completion_tokens) != null ? _d : void 0
@@ -962,8 +1021,8 @@ var OpenAICompatibleCompletionLanguageModel = class {
962
1021
  }
963
1022
  if ((choice == null ? void 0 : choice.text) != null) {
964
1023
  controller.enqueue({
965
- type: "text-delta",
966
- textDelta: choice.text
1024
+ type: "text",
1025
+ text: choice.text
967
1026
  });
968
1027
  }
969
1028
  },
@@ -982,36 +1041,36 @@ var OpenAICompatibleCompletionLanguageModel = class {
982
1041
  };
983
1042
  }
984
1043
  };
985
- var openaiCompatibleCompletionResponseSchema = import_zod3.z.object({
986
- id: import_zod3.z.string().nullish(),
987
- created: import_zod3.z.number().nullish(),
988
- model: import_zod3.z.string().nullish(),
989
- choices: import_zod3.z.array(
990
- import_zod3.z.object({
991
- text: import_zod3.z.string(),
992
- finish_reason: import_zod3.z.string()
1044
+ var openaiCompatibleCompletionResponseSchema = import_zod5.z.object({
1045
+ id: import_zod5.z.string().nullish(),
1046
+ created: import_zod5.z.number().nullish(),
1047
+ model: import_zod5.z.string().nullish(),
1048
+ choices: import_zod5.z.array(
1049
+ import_zod5.z.object({
1050
+ text: import_zod5.z.string(),
1051
+ finish_reason: import_zod5.z.string()
993
1052
  })
994
1053
  ),
995
- usage: import_zod3.z.object({
996
- prompt_tokens: import_zod3.z.number(),
997
- completion_tokens: import_zod3.z.number()
1054
+ usage: import_zod5.z.object({
1055
+ prompt_tokens: import_zod5.z.number(),
1056
+ completion_tokens: import_zod5.z.number()
998
1057
  }).nullish()
999
1058
  });
1000
- var createOpenAICompatibleCompletionChunkSchema = (errorSchema) => import_zod3.z.union([
1001
- import_zod3.z.object({
1002
- id: import_zod3.z.string().nullish(),
1003
- created: import_zod3.z.number().nullish(),
1004
- model: import_zod3.z.string().nullish(),
1005
- choices: import_zod3.z.array(
1006
- import_zod3.z.object({
1007
- text: import_zod3.z.string(),
1008
- finish_reason: import_zod3.z.string().nullish(),
1009
- index: import_zod3.z.number()
1059
+ var createOpenAICompatibleCompletionChunkSchema = (errorSchema) => import_zod5.z.union([
1060
+ import_zod5.z.object({
1061
+ id: import_zod5.z.string().nullish(),
1062
+ created: import_zod5.z.number().nullish(),
1063
+ model: import_zod5.z.string().nullish(),
1064
+ choices: import_zod5.z.array(
1065
+ import_zod5.z.object({
1066
+ text: import_zod5.z.string(),
1067
+ finish_reason: import_zod5.z.string().nullish(),
1068
+ index: import_zod5.z.number()
1010
1069
  })
1011
1070
  ),
1012
- usage: import_zod3.z.object({
1013
- prompt_tokens: import_zod3.z.number(),
1014
- completion_tokens: import_zod3.z.number()
1071
+ usage: import_zod5.z.object({
1072
+ prompt_tokens: import_zod5.z.number(),
1073
+ completion_tokens: import_zod5.z.number()
1015
1074
  }).nullish()
1016
1075
  }),
1017
1076
  errorSchema
@@ -1020,12 +1079,28 @@ var createOpenAICompatibleCompletionChunkSchema = (errorSchema) => import_zod3.z
1020
1079
  // src/openai-compatible-embedding-model.ts
1021
1080
  var import_provider5 = require("@ai-sdk/provider");
1022
1081
  var import_provider_utils3 = require("@ai-sdk/provider-utils");
1023
- var import_zod4 = require("zod");
1082
+ var import_zod7 = require("zod");
1083
+
1084
+ // src/openai-compatible-embedding-options.ts
1085
+ var import_zod6 = require("zod");
1086
+ var openaiCompatibleEmbeddingProviderOptions = import_zod6.z.object({
1087
+ /**
1088
+ * The number of dimensions the resulting output embeddings should have.
1089
+ * Only supported in text-embedding-3 and later models.
1090
+ */
1091
+ dimensions: import_zod6.z.number().optional(),
1092
+ /**
1093
+ * A unique identifier representing your end-user, which can help providers to
1094
+ * monitor and detect abuse.
1095
+ */
1096
+ user: import_zod6.z.string().optional()
1097
+ });
1098
+
1099
+ // src/openai-compatible-embedding-model.ts
1024
1100
  var OpenAICompatibleEmbeddingModel = class {
1025
- constructor(modelId, settings, config) {
1026
- this.specificationVersion = "v1";
1101
+ constructor(modelId, config) {
1102
+ this.specificationVersion = "v2";
1027
1103
  this.modelId = modelId;
1028
- this.settings = settings;
1029
1104
  this.config = config;
1030
1105
  }
1031
1106
  get provider() {
@@ -1039,12 +1114,28 @@ var OpenAICompatibleEmbeddingModel = class {
1039
1114
  var _a;
1040
1115
  return (_a = this.config.supportsParallelCalls) != null ? _a : true;
1041
1116
  }
1117
+ get providerOptionsName() {
1118
+ return this.config.provider.split(".")[0].trim();
1119
+ }
1042
1120
  async doEmbed({
1043
1121
  values,
1044
1122
  headers,
1045
- abortSignal
1123
+ abortSignal,
1124
+ providerOptions
1046
1125
  }) {
1047
- var _a;
1126
+ var _a, _b, _c;
1127
+ const compatibleOptions = Object.assign(
1128
+ (_a = (0, import_provider_utils3.parseProviderOptions)({
1129
+ provider: "openai-compatible",
1130
+ providerOptions,
1131
+ schema: openaiCompatibleEmbeddingProviderOptions
1132
+ })) != null ? _a : {},
1133
+ (_b = (0, import_provider_utils3.parseProviderOptions)({
1134
+ provider: this.providerOptionsName,
1135
+ providerOptions,
1136
+ schema: openaiCompatibleEmbeddingProviderOptions
1137
+ })) != null ? _b : {}
1138
+ );
1048
1139
  if (values.length > this.maxEmbeddingsPerCall) {
1049
1140
  throw new import_provider5.TooManyEmbeddingValuesForCallError({
1050
1141
  provider: this.provider,
@@ -1053,7 +1144,11 @@ var OpenAICompatibleEmbeddingModel = class {
1053
1144
  values
1054
1145
  });
1055
1146
  }
1056
- const { responseHeaders, value: response } = await (0, import_provider_utils3.postJsonToApi)({
1147
+ const {
1148
+ responseHeaders,
1149
+ value: response,
1150
+ rawValue
1151
+ } = await (0, import_provider_utils3.postJsonToApi)({
1057
1152
  url: this.config.url({
1058
1153
  path: "/embeddings",
1059
1154
  modelId: this.modelId
@@ -1063,11 +1158,11 @@ var OpenAICompatibleEmbeddingModel = class {
1063
1158
  model: this.modelId,
1064
1159
  input: values,
1065
1160
  encoding_format: "float",
1066
- dimensions: this.settings.dimensions,
1067
- user: this.settings.user
1161
+ dimensions: compatibleOptions.dimensions,
1162
+ user: compatibleOptions.user
1068
1163
  },
1069
1164
  failedResponseHandler: (0, import_provider_utils3.createJsonErrorResponseHandler)(
1070
- (_a = this.config.errorStructure) != null ? _a : defaultOpenAICompatibleErrorStructure
1165
+ (_c = this.config.errorStructure) != null ? _c : defaultOpenAICompatibleErrorStructure
1071
1166
  ),
1072
1167
  successfulResponseHandler: (0, import_provider_utils3.createJsonResponseHandler)(
1073
1168
  openaiTextEmbeddingResponseSchema
@@ -1078,18 +1173,18 @@ var OpenAICompatibleEmbeddingModel = class {
1078
1173
  return {
1079
1174
  embeddings: response.data.map((item) => item.embedding),
1080
1175
  usage: response.usage ? { tokens: response.usage.prompt_tokens } : void 0,
1081
- rawResponse: { headers: responseHeaders }
1176
+ response: { headers: responseHeaders, body: rawValue }
1082
1177
  };
1083
1178
  }
1084
1179
  };
1085
- var openaiTextEmbeddingResponseSchema = import_zod4.z.object({
1086
- data: import_zod4.z.array(import_zod4.z.object({ embedding: import_zod4.z.array(import_zod4.z.number()) })),
1087
- usage: import_zod4.z.object({ prompt_tokens: import_zod4.z.number() }).nullish()
1180
+ var openaiTextEmbeddingResponseSchema = import_zod7.z.object({
1181
+ data: import_zod7.z.array(import_zod7.z.object({ embedding: import_zod7.z.array(import_zod7.z.number()) })),
1182
+ usage: import_zod7.z.object({ prompt_tokens: import_zod7.z.number() }).nullish()
1088
1183
  });
1089
1184
 
1090
1185
  // src/openai-compatible-image-model.ts
1091
1186
  var import_provider_utils4 = require("@ai-sdk/provider-utils");
1092
- var import_zod5 = require("zod");
1187
+ var import_zod8 = require("zod");
1093
1188
  var OpenAICompatibleImageModel = class {
1094
1189
  constructor(modelId, settings, config) {
1095
1190
  this.modelId = modelId;
@@ -1162,8 +1257,8 @@ var OpenAICompatibleImageModel = class {
1162
1257
  };
1163
1258
  }
1164
1259
  };
1165
- var openaiCompatibleImageResponseSchema = import_zod5.z.object({
1166
- data: import_zod5.z.array(import_zod5.z.object({ b64_json: import_zod5.z.string() }))
1260
+ var openaiCompatibleImageResponseSchema = import_zod8.z.object({
1261
+ data: import_zod8.z.array(import_zod8.z.object({ b64_json: import_zod8.z.string() }))
1167
1262
  });
1168
1263
 
1169
1264
  // src/openai-compatible-provider.ts
@@ -1187,27 +1282,24 @@ function createOpenAICompatible(options) {
1187
1282
  headers: getHeaders,
1188
1283
  fetch: options.fetch
1189
1284
  });
1190
- const createLanguageModel = (modelId, settings = {}) => createChatModel(modelId, settings);
1191
- const createChatModel = (modelId, settings = {}) => new OpenAICompatibleChatLanguageModel(modelId, settings, {
1285
+ const createLanguageModel = (modelId) => createChatModel(modelId);
1286
+ const createChatModel = (modelId) => new OpenAICompatibleChatLanguageModel(modelId, {
1192
1287
  ...getCommonModelConfig("chat"),
1193
1288
  defaultObjectGenerationMode: "tool"
1194
1289
  });
1195
- const createCompletionModel = (modelId, settings = {}) => new OpenAICompatibleCompletionLanguageModel(
1290
+ const createCompletionModel = (modelId) => new OpenAICompatibleCompletionLanguageModel(
1196
1291
  modelId,
1197
- settings,
1198
1292
  getCommonModelConfig("completion")
1199
1293
  );
1200
- const createEmbeddingModel = (modelId, settings = {}) => new OpenAICompatibleEmbeddingModel(
1201
- modelId,
1202
- settings,
1203
- getCommonModelConfig("embedding")
1204
- );
1294
+ const createEmbeddingModel = (modelId) => new OpenAICompatibleEmbeddingModel(modelId, {
1295
+ ...getCommonModelConfig("embedding")
1296
+ });
1205
1297
  const createImageModel = (modelId, settings = {}) => new OpenAICompatibleImageModel(
1206
1298
  modelId,
1207
1299
  settings,
1208
1300
  getCommonModelConfig("image")
1209
1301
  );
1210
- const provider = (modelId, settings) => createLanguageModel(modelId, settings);
1302
+ const provider = (modelId) => createLanguageModel(modelId);
1211
1303
  provider.languageModel = createLanguageModel;
1212
1304
  provider.chatModel = createChatModel;
1213
1305
  provider.completionModel = createCompletionModel;