@ai-sdk/openai-compatible 2.0.86 → 2.0.88

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,
@@ -883,7 +885,7 @@ var OpenAICompatibleChatLanguageModel = class {
883
885
  };
884
886
  }
885
887
  };
886
- var openaiCompatibleTokenUsageSchema = z3.looseObject({
888
+ var openaiCompatibleTokenUsageSchema = () => z3.looseObject({
887
889
  prompt_tokens: z3.number().nullish(),
888
890
  completion_tokens: z3.number().nullish(),
889
891
  total_tokens: z3.number().nullish(),
@@ -896,7 +898,7 @@ var openaiCompatibleTokenUsageSchema = z3.looseObject({
896
898
  rejected_prediction_tokens: z3.number().nullish()
897
899
  }).nullish()
898
900
  }).nullish();
899
- var openAICompatibleContentSchema = z3.union([
901
+ var openAICompatibleContentSchema = () => z3.union([
900
902
  z3.string(),
901
903
  z3.array(
902
904
  z3.looseObject({
@@ -928,39 +930,43 @@ function convertOpenAICompatibleContent(content) {
928
930
  }
929
931
  return result;
930
932
  }
931
- var OpenAICompatibleChatResponseSchema = z3.looseObject({
932
- id: z3.string().nullish(),
933
- created: z3.number().nullish(),
934
- model: z3.string().nullish(),
935
- choices: z3.array(
936
- z3.object({
937
- message: z3.object({
938
- role: z3.literal("assistant").nullish(),
939
- content: openAICompatibleContentSchema,
940
- reasoning_content: z3.string().nullish(),
941
- reasoning: z3.string().nullish(),
942
- tool_calls: z3.array(
943
- z3.object({
944
- id: z3.string().nullish(),
945
- function: z3.object({
946
- name: z3.string(),
947
- arguments: z3.string()
948
- }),
949
- // Support for Google Gemini thought signatures via OpenAI compatibility
950
- extra_content: z3.object({
951
- google: z3.object({
952
- thought_signature: z3.string().nullish()
953
- }).nullish()
954
- }).nullish()
955
- })
956
- ).nullish()
957
- }),
958
- finish_reason: z3.string().nullish()
933
+ var OpenAICompatibleChatResponseSchema = lazySchema(
934
+ () => zodSchema(
935
+ z3.looseObject({
936
+ id: z3.string().nullish(),
937
+ created: z3.number().nullish(),
938
+ model: z3.string().nullish(),
939
+ choices: z3.array(
940
+ z3.object({
941
+ message: z3.object({
942
+ role: z3.literal("assistant").nullish(),
943
+ content: openAICompatibleContentSchema(),
944
+ reasoning_content: z3.string().nullish(),
945
+ reasoning: z3.string().nullish(),
946
+ tool_calls: z3.array(
947
+ z3.object({
948
+ id: z3.string().nullish(),
949
+ function: z3.object({
950
+ name: z3.string(),
951
+ arguments: z3.string()
952
+ }),
953
+ // Support for Google Gemini thought signatures via OpenAI compatibility
954
+ extra_content: z3.object({
955
+ google: z3.object({
956
+ thought_signature: z3.string().nullish()
957
+ }).nullish()
958
+ }).nullish()
959
+ })
960
+ ).nullish()
961
+ }),
962
+ finish_reason: z3.string().nullish()
963
+ })
964
+ ),
965
+ usage: openaiCompatibleTokenUsageSchema()
959
966
  })
960
- ),
961
- usage: openaiCompatibleTokenUsageSchema
962
- });
963
- var chunkBaseSchema = z3.looseObject({
967
+ )
968
+ );
969
+ var chunkBaseSchema = () => z3.looseObject({
964
970
  id: z3.string().nullish(),
965
971
  created: z3.number().nullish(),
966
972
  model: z3.string().nullish(),
@@ -968,7 +974,7 @@ var chunkBaseSchema = z3.looseObject({
968
974
  z3.object({
969
975
  delta: z3.object({
970
976
  role: z3.enum(["assistant", ""]).nullish(),
971
- content: openAICompatibleContentSchema,
977
+ content: openAICompatibleContentSchema(),
972
978
  // Most openai-compatible models set `reasoning_content`, but some
973
979
  // providers serving `gpt-oss` set `reasoning`. See #7866
974
980
  reasoning_content: z3.string().nullish(),
@@ -994,12 +1000,14 @@ var chunkBaseSchema = z3.looseObject({
994
1000
  finish_reason: z3.string().nullish()
995
1001
  })
996
1002
  ),
997
- usage: openaiCompatibleTokenUsageSchema
1003
+ usage: openaiCompatibleTokenUsageSchema()
998
1004
  });
999
- var createOpenAICompatibleChatChunkSchema = (errorSchema) => z3.union([chunkBaseSchema, errorSchema]);
1005
+ var createOpenAICompatibleChatChunkSchema = (errorSchema) => z3.union([chunkBaseSchema(), errorSchema]);
1000
1006
 
1001
1007
  // src/completion/openai-compatible-completion-language-model.ts
1002
1008
  import {
1009
+ lazySchema as lazySchema3,
1010
+ zodSchema as zodSchema3,
1003
1011
  combineHeaders as combineHeaders2,
1004
1012
  createEventSourceResponseHandler as createEventSourceResponseHandler2,
1005
1013
  createJsonErrorResponseHandler as createJsonErrorResponseHandler2,
@@ -1155,29 +1163,37 @@ function mapOpenAICompatibleFinishReason2(finishReason) {
1155
1163
  }
1156
1164
 
1157
1165
  // src/completion/openai-compatible-completion-options.ts
1166
+ import {
1167
+ lazySchema as lazySchema2,
1168
+ zodSchema as zodSchema2
1169
+ } from "@ai-sdk/provider-utils";
1158
1170
  import { z as z4 } from "zod/v4";
1159
- var openaiCompatibleLanguageModelCompletionOptions = z4.object({
1160
- /**
1161
- * Echo back the prompt in addition to the completion.
1162
- */
1163
- echo: z4.boolean().optional(),
1164
- /**
1165
- * Modify the likelihood of specified tokens appearing in the completion.
1166
- *
1167
- * Accepts a JSON object that maps tokens (specified by their token ID in
1168
- * the GPT tokenizer) to an associated bias value from -100 to 100.
1169
- */
1170
- logitBias: z4.record(z4.string(), z4.number()).optional(),
1171
- /**
1172
- * The suffix that comes after a completion of inserted text.
1173
- */
1174
- suffix: z4.string().optional(),
1175
- /**
1176
- * A unique identifier representing your end-user, which can help providers to
1177
- * monitor and detect abuse.
1178
- */
1179
- user: z4.string().optional()
1180
- });
1171
+ var openaiCompatibleLanguageModelCompletionOptions = lazySchema2(
1172
+ () => zodSchema2(
1173
+ z4.object({
1174
+ /**
1175
+ * Echo back the prompt in addition to the completion.
1176
+ */
1177
+ echo: z4.boolean().optional(),
1178
+ /**
1179
+ * Modify the likelihood of specified tokens appearing in the completion.
1180
+ *
1181
+ * Accepts a JSON object that maps tokens (specified by their token ID in
1182
+ * the GPT tokenizer) to an associated bias value from -100 to 100.
1183
+ */
1184
+ logitBias: z4.record(z4.string(), z4.number()).optional(),
1185
+ /**
1186
+ * The suffix that comes after a completion of inserted text.
1187
+ */
1188
+ suffix: z4.string().optional(),
1189
+ /**
1190
+ * A unique identifier representing your end-user, which can help providers to
1191
+ * monitor and detect abuse.
1192
+ */
1193
+ user: z4.string().optional()
1194
+ })
1195
+ )
1196
+ );
1181
1197
 
1182
1198
  // src/completion/openai-compatible-completion-language-model.ts
1183
1199
  var OpenAICompatibleCompletionLanguageModel = class {
@@ -1413,23 +1429,27 @@ var OpenAICompatibleCompletionLanguageModel = class {
1413
1429
  };
1414
1430
  }
1415
1431
  };
1416
- var usageSchema = z5.looseObject({
1432
+ var usageSchema = () => z5.looseObject({
1417
1433
  prompt_tokens: z5.number(),
1418
1434
  completion_tokens: z5.number(),
1419
1435
  total_tokens: z5.number()
1420
1436
  });
1421
- var openaiCompatibleCompletionResponseSchema = z5.object({
1422
- id: z5.string().nullish(),
1423
- created: z5.number().nullish(),
1424
- model: z5.string().nullish(),
1425
- choices: z5.array(
1437
+ var openaiCompatibleCompletionResponseSchema = lazySchema3(
1438
+ () => zodSchema3(
1426
1439
  z5.object({
1427
- text: z5.string(),
1428
- finish_reason: z5.string()
1440
+ id: z5.string().nullish(),
1441
+ created: z5.number().nullish(),
1442
+ model: z5.string().nullish(),
1443
+ choices: z5.array(
1444
+ z5.object({
1445
+ text: z5.string(),
1446
+ finish_reason: z5.string()
1447
+ })
1448
+ ),
1449
+ usage: usageSchema().nullish()
1429
1450
  })
1430
- ),
1431
- usage: usageSchema.nullish()
1432
- });
1451
+ )
1452
+ );
1433
1453
  var createOpenAICompatibleCompletionChunkSchema = (errorSchema) => z5.union([
1434
1454
  z5.object({
1435
1455
  id: z5.string().nullish(),
@@ -1442,7 +1462,7 @@ var createOpenAICompatibleCompletionChunkSchema = (errorSchema) => z5.union([
1442
1462
  index: z5.number()
1443
1463
  })
1444
1464
  ),
1445
- usage: usageSchema.nullish()
1465
+ usage: usageSchema().nullish()
1446
1466
  }),
1447
1467
  errorSchema
1448
1468
  ]);
@@ -1452,6 +1472,8 @@ import {
1452
1472
  TooManyEmbeddingValuesForCallError
1453
1473
  } from "@ai-sdk/provider";
1454
1474
  import {
1475
+ lazySchema as lazySchema5,
1476
+ zodSchema as zodSchema5,
1455
1477
  combineHeaders as combineHeaders3,
1456
1478
  createJsonErrorResponseHandler as createJsonErrorResponseHandler3,
1457
1479
  createJsonResponseHandler as createJsonResponseHandler3,
@@ -1461,19 +1483,27 @@ import {
1461
1483
  import { z as z7 } from "zod/v4";
1462
1484
 
1463
1485
  // src/embedding/openai-compatible-embedding-options.ts
1486
+ import {
1487
+ lazySchema as lazySchema4,
1488
+ zodSchema as zodSchema4
1489
+ } from "@ai-sdk/provider-utils";
1464
1490
  import { z as z6 } from "zod/v4";
1465
- var openaiCompatibleEmbeddingModelOptions = z6.object({
1466
- /**
1467
- * The number of dimensions the resulting output embeddings should have.
1468
- * Only supported in text-embedding-3 and later models.
1469
- */
1470
- dimensions: z6.number().optional(),
1471
- /**
1472
- * A unique identifier representing your end-user, which can help providers to
1473
- * monitor and detect abuse.
1474
- */
1475
- user: z6.string().optional()
1476
- });
1491
+ var openaiCompatibleEmbeddingModelOptions = lazySchema4(
1492
+ () => zodSchema4(
1493
+ z6.object({
1494
+ /**
1495
+ * The number of dimensions the resulting output embeddings should have.
1496
+ * Only supported in text-embedding-3 and later models.
1497
+ */
1498
+ dimensions: z6.number().optional(),
1499
+ /**
1500
+ * A unique identifier representing your end-user, which can help providers to
1501
+ * monitor and detect abuse.
1502
+ */
1503
+ user: z6.string().optional()
1504
+ })
1505
+ )
1506
+ );
1477
1507
 
1478
1508
  // src/embedding/openai-compatible-embedding-model.ts
1479
1509
  var OpenAICompatibleEmbeddingModel = class {
@@ -1571,17 +1601,23 @@ var OpenAICompatibleEmbeddingModel = class {
1571
1601
  };
1572
1602
  }
1573
1603
  };
1574
- var openaiTextEmbeddingResponseSchema = z7.object({
1575
- data: z7.array(z7.object({ embedding: z7.array(z7.number()) })),
1576
- usage: z7.object({ prompt_tokens: z7.number() }).nullish(),
1577
- providerMetadata: z7.record(z7.string(), z7.record(z7.string(), z7.any())).optional()
1578
- });
1604
+ var openaiTextEmbeddingResponseSchema = lazySchema5(
1605
+ () => zodSchema5(
1606
+ z7.object({
1607
+ data: z7.array(z7.object({ embedding: z7.array(z7.number()) })),
1608
+ usage: z7.object({ prompt_tokens: z7.number() }).nullish(),
1609
+ providerMetadata: z7.record(z7.string(), z7.record(z7.string(), z7.any())).optional()
1610
+ })
1611
+ )
1612
+ );
1579
1613
 
1580
1614
  // src/image/openai-compatible-image-model.ts
1581
1615
  import {
1582
1616
  InvalidResponseDataError as InvalidResponseDataError2
1583
1617
  } from "@ai-sdk/provider";
1584
1618
  import {
1619
+ lazySchema as lazySchema6,
1620
+ zodSchema as zodSchema6,
1585
1621
  combineHeaders as combineHeaders4,
1586
1622
  convertBase64ToUint8Array as convertBase64ToUint8Array2,
1587
1623
  convertToFormData,
@@ -1751,16 +1787,20 @@ var OpenAICompatibleImageModel = class {
1751
1787
  );
1752
1788
  }
1753
1789
  };
1754
- var openaiCompatibleImageResponseSchema = z8.object({
1755
- data: z8.array(
1790
+ var openaiCompatibleImageResponseSchema = lazySchema6(
1791
+ () => zodSchema6(
1756
1792
  z8.object({
1757
- b64_json: z8.string().nullish(),
1758
- url: z8.string().nullish()
1759
- }).refine((image) => image.b64_json != null || image.url != null, {
1760
- message: "Expected b64_json or url in the image response"
1793
+ data: z8.array(
1794
+ z8.object({
1795
+ b64_json: z8.string().nullish(),
1796
+ url: z8.string().nullish()
1797
+ }).refine((image) => image.b64_json != null || image.url != null, {
1798
+ message: "Expected b64_json or url in the image response"
1799
+ })
1800
+ )
1761
1801
  })
1762
1802
  )
1763
- });
1803
+ );
1764
1804
  async function fileToBlob(file) {
1765
1805
  if (file.type === "url") {
1766
1806
  return downloadBlob(file.url);
@@ -1776,7 +1816,7 @@ import {
1776
1816
  } from "@ai-sdk/provider-utils";
1777
1817
 
1778
1818
  // src/version.ts
1779
- var VERSION = true ? "2.0.86" : "0.0.0-test";
1819
+ var VERSION = true ? "2.0.88" : "0.0.0-test";
1780
1820
 
1781
1821
  // src/openai-compatible-provider.ts
1782
1822
  function createOpenAICompatible(options) {