@ai-sdk/openai-compatible 1.0.58 → 1.0.60

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.mjs CHANGED
@@ -3,6 +3,8 @@ import {
3
3
  InvalidResponseDataError
4
4
  } from "@ai-sdk/provider";
5
5
  import {
6
+ lazySchema,
7
+ zodSchema,
6
8
  StreamingToolCallTracker,
7
9
  combineHeaders,
8
10
  createEventSourceResponseHandler,
@@ -643,7 +645,7 @@ var OpenAICompatibleChatLanguageModel = class {
643
645
  };
644
646
  }
645
647
  };
646
- var openaiCompatibleTokenUsageSchema = z3.object({
648
+ var openaiCompatibleTokenUsageSchema = () => z3.object({
647
649
  prompt_tokens: z3.number().nullish(),
648
650
  completion_tokens: z3.number().nullish(),
649
651
  total_tokens: z3.number().nullish(),
@@ -666,32 +668,36 @@ function convertOpenAICompatibleChatUsage(usage) {
666
668
  cachedInputTokens: (_g = (_f = usage == null ? void 0 : usage.prompt_tokens_details) == null ? void 0 : _f.cached_tokens) != null ? _g : void 0
667
669
  };
668
670
  }
669
- var OpenAICompatibleChatResponseSchema = z3.object({
670
- id: z3.string().nullish(),
671
- created: z3.number().nullish(),
672
- model: z3.string().nullish(),
673
- choices: z3.array(
671
+ var OpenAICompatibleChatResponseSchema = lazySchema(
672
+ () => zodSchema(
674
673
  z3.object({
675
- message: z3.object({
676
- role: z3.literal("assistant").nullish(),
677
- content: z3.string().nullish(),
678
- reasoning_content: z3.string().nullish(),
679
- reasoning: z3.string().nullish(),
680
- tool_calls: z3.array(
681
- z3.object({
682
- id: z3.string().nullish(),
683
- function: z3.object({
684
- name: z3.string(),
685
- arguments: z3.string()
686
- })
687
- })
688
- ).nullish()
689
- }),
690
- finish_reason: z3.string().nullish()
674
+ id: z3.string().nullish(),
675
+ created: z3.number().nullish(),
676
+ model: z3.string().nullish(),
677
+ choices: z3.array(
678
+ z3.object({
679
+ message: z3.object({
680
+ role: z3.literal("assistant").nullish(),
681
+ content: z3.string().nullish(),
682
+ reasoning_content: z3.string().nullish(),
683
+ reasoning: z3.string().nullish(),
684
+ tool_calls: z3.array(
685
+ z3.object({
686
+ id: z3.string().nullish(),
687
+ function: z3.object({
688
+ name: z3.string(),
689
+ arguments: z3.string()
690
+ })
691
+ })
692
+ ).nullish()
693
+ }),
694
+ finish_reason: z3.string().nullish()
695
+ })
696
+ ),
697
+ usage: openaiCompatibleTokenUsageSchema()
691
698
  })
692
- ),
693
- usage: openaiCompatibleTokenUsageSchema
694
- });
699
+ )
700
+ );
695
701
  var createOpenAICompatibleChatChunkSchema = (errorSchema) => z3.union([
696
702
  z3.object({
697
703
  id: z3.string().nullish(),
@@ -718,16 +724,18 @@ var createOpenAICompatibleChatChunkSchema = (errorSchema) => z3.union([
718
724
  ).nullish()
719
725
  }).nullish(),
720
726
  finish_reason: z3.string().nullish(),
721
- usage: openaiCompatibleTokenUsageSchema
727
+ usage: openaiCompatibleTokenUsageSchema()
722
728
  })
723
729
  ),
724
- usage: openaiCompatibleTokenUsageSchema
730
+ usage: openaiCompatibleTokenUsageSchema()
725
731
  }),
726
732
  errorSchema
727
733
  ]);
728
734
 
729
735
  // src/completion/openai-compatible-completion-language-model.ts
730
736
  import {
737
+ lazySchema as lazySchema3,
738
+ zodSchema as zodSchema3,
731
739
  combineHeaders as combineHeaders2,
732
740
  createEventSourceResponseHandler as createEventSourceResponseHandler2,
733
741
  createJsonErrorResponseHandler as createJsonErrorResponseHandler2,
@@ -846,29 +854,37 @@ function mapOpenAICompatibleFinishReason2(finishReason) {
846
854
  }
847
855
 
848
856
  // src/completion/openai-compatible-completion-options.ts
857
+ import {
858
+ lazySchema as lazySchema2,
859
+ zodSchema as zodSchema2
860
+ } from "@ai-sdk/provider-utils";
849
861
  import { z as z4 } from "zod/v4";
850
- var openaiCompatibleCompletionProviderOptions = z4.object({
851
- /**
852
- * Echo back the prompt in addition to the completion.
853
- */
854
- echo: z4.boolean().optional(),
855
- /**
856
- * Modify the likelihood of specified tokens appearing in the completion.
857
- *
858
- * Accepts a JSON object that maps tokens (specified by their token ID in
859
- * the GPT tokenizer) to an associated bias value from -100 to 100.
860
- */
861
- logitBias: z4.record(z4.string(), z4.number()).optional(),
862
- /**
863
- * The suffix that comes after a completion of inserted text.
864
- */
865
- suffix: z4.string().optional(),
866
- /**
867
- * A unique identifier representing your end-user, which can help providers to
868
- * monitor and detect abuse.
869
- */
870
- user: z4.string().optional()
871
- });
862
+ var openaiCompatibleCompletionProviderOptions = lazySchema2(
863
+ () => zodSchema2(
864
+ z4.object({
865
+ /**
866
+ * Echo back the prompt in addition to the completion.
867
+ */
868
+ echo: z4.boolean().optional(),
869
+ /**
870
+ * Modify the likelihood of specified tokens appearing in the completion.
871
+ *
872
+ * Accepts a JSON object that maps tokens (specified by their token ID in
873
+ * the GPT tokenizer) to an associated bias value from -100 to 100.
874
+ */
875
+ logitBias: z4.record(z4.string(), z4.number()).optional(),
876
+ /**
877
+ * The suffix that comes after a completion of inserted text.
878
+ */
879
+ suffix: z4.string().optional(),
880
+ /**
881
+ * A unique identifier representing your end-user, which can help providers to
882
+ * monitor and detect abuse.
883
+ */
884
+ user: z4.string().optional()
885
+ })
886
+ )
887
+ );
872
888
 
873
889
  // src/completion/openai-compatible-completion-language-model.ts
874
890
  var OpenAICompatibleCompletionLanguageModel = class {
@@ -1100,23 +1116,27 @@ var OpenAICompatibleCompletionLanguageModel = class {
1100
1116
  };
1101
1117
  }
1102
1118
  };
1103
- var usageSchema = z5.object({
1119
+ var usageSchema = () => z5.object({
1104
1120
  prompt_tokens: z5.number(),
1105
1121
  completion_tokens: z5.number(),
1106
1122
  total_tokens: z5.number()
1107
1123
  });
1108
- var openaiCompatibleCompletionResponseSchema = z5.object({
1109
- id: z5.string().nullish(),
1110
- created: z5.number().nullish(),
1111
- model: z5.string().nullish(),
1112
- choices: z5.array(
1124
+ var openaiCompatibleCompletionResponseSchema = lazySchema3(
1125
+ () => zodSchema3(
1113
1126
  z5.object({
1114
- text: z5.string(),
1115
- finish_reason: z5.string()
1127
+ id: z5.string().nullish(),
1128
+ created: z5.number().nullish(),
1129
+ model: z5.string().nullish(),
1130
+ choices: z5.array(
1131
+ z5.object({
1132
+ text: z5.string(),
1133
+ finish_reason: z5.string()
1134
+ })
1135
+ ),
1136
+ usage: usageSchema().nullish()
1116
1137
  })
1117
- ),
1118
- usage: usageSchema.nullish()
1119
- });
1138
+ )
1139
+ );
1120
1140
  var createOpenAICompatibleCompletionChunkSchema = (errorSchema) => z5.union([
1121
1141
  z5.object({
1122
1142
  id: z5.string().nullish(),
@@ -1129,7 +1149,7 @@ var createOpenAICompatibleCompletionChunkSchema = (errorSchema) => z5.union([
1129
1149
  index: z5.number()
1130
1150
  })
1131
1151
  ),
1132
- usage: usageSchema.nullish()
1152
+ usage: usageSchema().nullish()
1133
1153
  }),
1134
1154
  errorSchema
1135
1155
  ]);
@@ -1139,6 +1159,8 @@ import {
1139
1159
  TooManyEmbeddingValuesForCallError
1140
1160
  } from "@ai-sdk/provider";
1141
1161
  import {
1162
+ lazySchema as lazySchema5,
1163
+ zodSchema as zodSchema5,
1142
1164
  combineHeaders as combineHeaders3,
1143
1165
  createJsonErrorResponseHandler as createJsonErrorResponseHandler3,
1144
1166
  createJsonResponseHandler as createJsonResponseHandler3,
@@ -1148,19 +1170,27 @@ import {
1148
1170
  import { z as z7 } from "zod/v4";
1149
1171
 
1150
1172
  // src/embedding/openai-compatible-embedding-options.ts
1173
+ import {
1174
+ lazySchema as lazySchema4,
1175
+ zodSchema as zodSchema4
1176
+ } from "@ai-sdk/provider-utils";
1151
1177
  import { z as z6 } from "zod/v4";
1152
- var openaiCompatibleEmbeddingProviderOptions = z6.object({
1153
- /**
1154
- * The number of dimensions the resulting output embeddings should have.
1155
- * Only supported in text-embedding-3 and later models.
1156
- */
1157
- dimensions: z6.number().optional(),
1158
- /**
1159
- * A unique identifier representing your end-user, which can help providers to
1160
- * monitor and detect abuse.
1161
- */
1162
- user: z6.string().optional()
1163
- });
1178
+ var openaiCompatibleEmbeddingProviderOptions = lazySchema4(
1179
+ () => zodSchema4(
1180
+ z6.object({
1181
+ /**
1182
+ * The number of dimensions the resulting output embeddings should have.
1183
+ * Only supported in text-embedding-3 and later models.
1184
+ */
1185
+ dimensions: z6.number().optional(),
1186
+ /**
1187
+ * A unique identifier representing your end-user, which can help providers to
1188
+ * monitor and detect abuse.
1189
+ */
1190
+ user: z6.string().optional()
1191
+ })
1192
+ )
1193
+ );
1164
1194
 
1165
1195
  // src/embedding/openai-compatible-embedding-model.ts
1166
1196
  var OpenAICompatibleEmbeddingModel = class {
@@ -1244,14 +1274,20 @@ var OpenAICompatibleEmbeddingModel = class {
1244
1274
  };
1245
1275
  }
1246
1276
  };
1247
- var openaiTextEmbeddingResponseSchema = z7.object({
1248
- data: z7.array(z7.object({ embedding: z7.array(z7.number()) })),
1249
- usage: z7.object({ prompt_tokens: z7.number() }).nullish(),
1250
- providerMetadata: z7.record(z7.string(), z7.record(z7.string(), z7.any())).optional()
1251
- });
1277
+ var openaiTextEmbeddingResponseSchema = lazySchema5(
1278
+ () => zodSchema5(
1279
+ z7.object({
1280
+ data: z7.array(z7.object({ embedding: z7.array(z7.number()) })),
1281
+ usage: z7.object({ prompt_tokens: z7.number() }).nullish(),
1282
+ providerMetadata: z7.record(z7.string(), z7.record(z7.string(), z7.any())).optional()
1283
+ })
1284
+ )
1285
+ );
1252
1286
 
1253
1287
  // src/image/openai-compatible-image-model.ts
1254
1288
  import {
1289
+ lazySchema as lazySchema6,
1290
+ zodSchema as zodSchema6,
1255
1291
  combineHeaders as combineHeaders4,
1256
1292
  createJsonErrorResponseHandler as createJsonErrorResponseHandler4,
1257
1293
  createJsonResponseHandler as createJsonResponseHandler4,
@@ -1331,9 +1367,13 @@ var OpenAICompatibleImageModel = class {
1331
1367
  };
1332
1368
  }
1333
1369
  };
1334
- var openaiCompatibleImageResponseSchema = z8.object({
1335
- data: z8.array(z8.object({ b64_json: z8.string() }))
1336
- });
1370
+ var openaiCompatibleImageResponseSchema = lazySchema6(
1371
+ () => zodSchema6(
1372
+ z8.object({
1373
+ data: z8.array(z8.object({ b64_json: z8.string() }))
1374
+ })
1375
+ )
1376
+ );
1337
1377
 
1338
1378
  // src/openai-compatible-provider.ts
1339
1379
  import {
@@ -1342,7 +1382,7 @@ import {
1342
1382
  } from "@ai-sdk/provider-utils";
1343
1383
 
1344
1384
  // src/version.ts
1345
- var VERSION = true ? "1.0.58" : "0.0.0-test";
1385
+ var VERSION = true ? "1.0.60" : "0.0.0-test";
1346
1386
 
1347
1387
  // src/openai-compatible-provider.ts
1348
1388
  function createOpenAICompatible(options) {