@openrouter/ai-sdk-provider 1.2.2 → 1.2.3

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.
@@ -905,7 +905,7 @@ var CommonReasoningDetailSchema = import_v4.z.object({
905
905
  id: import_v4.z.string().nullish(),
906
906
  format: import_v4.z.nativeEnum(ReasoningFormat).nullish(),
907
907
  index: import_v4.z.number().optional()
908
- });
908
+ }).passthrough();
909
909
  var ReasoningDetailSummarySchema = import_v4.z.object({
910
910
  type: import_v4.z.literal("reasoning.summary" /* Summary */),
911
911
  summary: import_v4.z.string()
@@ -958,8 +958,8 @@ var OpenRouterErrorResponseSchema = import_v42.z.object({
958
958
  message: import_v42.z.string(),
959
959
  type: import_v42.z.string().nullable().optional().default(null),
960
960
  param: import_v42.z.any().nullable().optional().default(null)
961
- })
962
- });
961
+ }).passthrough()
962
+ }).passthrough();
963
963
  var openrouterFailedResponseHandler = createJsonErrorResponseHandler({
964
964
  errorSchema: OpenRouterErrorResponseSchema,
965
965
  errorToMessage: (data) => data.error.message
@@ -974,18 +974,18 @@ var OpenRouterProviderMetadataSchema = import_v43.z.object({
974
974
  promptTokens: import_v43.z.number(),
975
975
  promptTokensDetails: import_v43.z.object({
976
976
  cachedTokens: import_v43.z.number()
977
- }).optional(),
977
+ }).passthrough().optional(),
978
978
  completionTokens: import_v43.z.number(),
979
979
  completionTokensDetails: import_v43.z.object({
980
980
  reasoningTokens: import_v43.z.number()
981
- }).optional(),
981
+ }).passthrough().optional(),
982
982
  totalTokens: import_v43.z.number(),
983
983
  cost: import_v43.z.number().optional(),
984
984
  costDetails: import_v43.z.object({
985
985
  upstreamInferenceCost: import_v43.z.number()
986
- })
987
- })
988
- });
986
+ }).passthrough()
987
+ }).passthrough()
988
+ }).passthrough();
989
989
  var OpenRouterProviderOptionsSchema = import_v43.z.object({
990
990
  openrouter: import_v43.z.object({
991
991
  reasoning_details: import_v43.z.array(ReasoningDetailUnionSchema).optional()
@@ -1271,8 +1271,8 @@ var ImageResponseSchema = import_v45.z.object({
1271
1271
  type: import_v45.z.literal("image_url"),
1272
1272
  image_url: import_v45.z.object({
1273
1273
  url: import_v45.z.string()
1274
- })
1275
- });
1274
+ }).passthrough()
1275
+ }).passthrough();
1276
1276
  var ImageResponseWithUnknownSchema = import_v45.z.union([
1277
1277
  ImageResponseSchema,
1278
1278
  import_v45.z.unknown().transform(() => null)
@@ -1288,18 +1288,18 @@ var OpenRouterChatCompletionBaseResponseSchema = import_v46.z.object({
1288
1288
  prompt_tokens: import_v46.z.number(),
1289
1289
  prompt_tokens_details: import_v46.z.object({
1290
1290
  cached_tokens: import_v46.z.number()
1291
- }).nullish(),
1291
+ }).passthrough().nullish(),
1292
1292
  completion_tokens: import_v46.z.number(),
1293
1293
  completion_tokens_details: import_v46.z.object({
1294
1294
  reasoning_tokens: import_v46.z.number()
1295
- }).nullish(),
1295
+ }).passthrough().nullish(),
1296
1296
  total_tokens: import_v46.z.number(),
1297
1297
  cost: import_v46.z.number().optional(),
1298
1298
  cost_details: import_v46.z.object({
1299
1299
  upstream_inference_cost: import_v46.z.number().nullish()
1300
- }).nullish()
1301
- }).nullish()
1302
- });
1300
+ }).passthrough().nullish()
1301
+ }).passthrough().nullish()
1302
+ }).passthrough();
1303
1303
  var OpenRouterNonStreamChatCompletionResponseSchema = import_v46.z.union([
1304
1304
  // Success response with choices
1305
1305
  OpenRouterChatCompletionBaseResponseSchema.extend({
@@ -1318,8 +1318,8 @@ var OpenRouterNonStreamChatCompletionResponseSchema = import_v46.z.union([
1318
1318
  function: import_v46.z.object({
1319
1319
  name: import_v46.z.string(),
1320
1320
  arguments: import_v46.z.string()
1321
- })
1322
- })
1321
+ }).passthrough()
1322
+ }).passthrough()
1323
1323
  ).optional(),
1324
1324
  annotations: import_v46.z.array(
1325
1325
  import_v46.z.union([
@@ -1332,16 +1332,16 @@ var OpenRouterNonStreamChatCompletionResponseSchema = import_v46.z.union([
1332
1332
  title: import_v46.z.string(),
1333
1333
  url: import_v46.z.string(),
1334
1334
  content: import_v46.z.string().optional()
1335
- })
1336
- }),
1335
+ }).passthrough()
1336
+ }).passthrough(),
1337
1337
  // File annotation from FileParserPlugin (old format)
1338
1338
  import_v46.z.object({
1339
1339
  type: import_v46.z.literal("file_annotation"),
1340
1340
  file_annotation: import_v46.z.object({
1341
1341
  file_id: import_v46.z.string(),
1342
1342
  quote: import_v46.z.string().optional()
1343
- })
1344
- }),
1343
+ }).passthrough()
1344
+ }).passthrough(),
1345
1345
  // File annotation from FileParserPlugin (new format)
1346
1346
  import_v46.z.object({
1347
1347
  type: import_v46.z.literal("file"),
@@ -1352,13 +1352,13 @@ var OpenRouterNonStreamChatCompletionResponseSchema = import_v46.z.union([
1352
1352
  import_v46.z.object({
1353
1353
  type: import_v46.z.string(),
1354
1354
  text: import_v46.z.string()
1355
- })
1355
+ }).passthrough()
1356
1356
  ).optional()
1357
- })
1358
- })
1357
+ }).passthrough()
1358
+ }).passthrough()
1359
1359
  ])
1360
1360
  ).nullish()
1361
- }),
1361
+ }).passthrough(),
1362
1362
  index: import_v46.z.number().nullish(),
1363
1363
  logprobs: import_v46.z.object({
1364
1364
  content: import_v46.z.array(
@@ -1369,13 +1369,13 @@ var OpenRouterNonStreamChatCompletionResponseSchema = import_v46.z.union([
1369
1369
  import_v46.z.object({
1370
1370
  token: import_v46.z.string(),
1371
1371
  logprob: import_v46.z.number()
1372
- })
1372
+ }).passthrough()
1373
1373
  )
1374
- })
1374
+ }).passthrough()
1375
1375
  ).nullable()
1376
- }).nullable().optional(),
1376
+ }).passthrough().nullable().optional(),
1377
1377
  finish_reason: import_v46.z.string().optional().nullable()
1378
- })
1378
+ }).passthrough()
1379
1379
  )
1380
1380
  }),
1381
1381
  // Error response (HTTP 200 with error payload)
@@ -1401,8 +1401,8 @@ var OpenRouterStreamChatCompletionChunkSchema = import_v46.z.union([
1401
1401
  function: import_v46.z.object({
1402
1402
  name: import_v46.z.string().nullish(),
1403
1403
  arguments: import_v46.z.string().nullish()
1404
- })
1405
- })
1404
+ }).passthrough()
1405
+ }).passthrough()
1406
1406
  ).nullish(),
1407
1407
  annotations: import_v46.z.array(
1408
1408
  import_v46.z.union([
@@ -1415,16 +1415,16 @@ var OpenRouterStreamChatCompletionChunkSchema = import_v46.z.union([
1415
1415
  title: import_v46.z.string(),
1416
1416
  url: import_v46.z.string(),
1417
1417
  content: import_v46.z.string().optional()
1418
- })
1419
- }),
1418
+ }).passthrough()
1419
+ }).passthrough(),
1420
1420
  // File annotation from FileParserPlugin (old format)
1421
1421
  import_v46.z.object({
1422
1422
  type: import_v46.z.literal("file_annotation"),
1423
1423
  file_annotation: import_v46.z.object({
1424
1424
  file_id: import_v46.z.string(),
1425
1425
  quote: import_v46.z.string().optional()
1426
- })
1427
- }),
1426
+ }).passthrough()
1427
+ }).passthrough(),
1428
1428
  // File annotation from FileParserPlugin (new format)
1429
1429
  import_v46.z.object({
1430
1430
  type: import_v46.z.literal("file"),
@@ -1435,13 +1435,13 @@ var OpenRouterStreamChatCompletionChunkSchema = import_v46.z.union([
1435
1435
  import_v46.z.object({
1436
1436
  type: import_v46.z.string(),
1437
1437
  text: import_v46.z.string()
1438
- })
1438
+ }).passthrough()
1439
1439
  ).optional()
1440
- })
1441
- })
1440
+ }).passthrough()
1441
+ }).passthrough()
1442
1442
  ])
1443
1443
  ).nullish()
1444
- }).nullish(),
1444
+ }).passthrough().nullish(),
1445
1445
  logprobs: import_v46.z.object({
1446
1446
  content: import_v46.z.array(
1447
1447
  import_v46.z.object({
@@ -1451,14 +1451,14 @@ var OpenRouterStreamChatCompletionChunkSchema = import_v46.z.union([
1451
1451
  import_v46.z.object({
1452
1452
  token: import_v46.z.string(),
1453
1453
  logprob: import_v46.z.number()
1454
- })
1454
+ }).passthrough()
1455
1455
  )
1456
- })
1456
+ }).passthrough()
1457
1457
  ).nullable()
1458
- }).nullish(),
1458
+ }).passthrough().nullish(),
1459
1459
  finish_reason: import_v46.z.string().nullable().optional(),
1460
1460
  index: import_v46.z.number().nullish()
1461
- })
1461
+ }).passthrough()
1462
1462
  )
1463
1463
  }),
1464
1464
  OpenRouterErrorResponseSchema
@@ -1579,8 +1579,9 @@ var OpenRouterChatLanguageModel = class {
1579
1579
  fetch: this.config.fetch
1580
1580
  });
1581
1581
  if ("error" in responseValue) {
1582
+ const errorData = responseValue.error;
1582
1583
  throw new APICallError({
1583
- message: responseValue.error.message,
1584
+ message: errorData.message,
1584
1585
  url: this.config.url({
1585
1586
  path: "/chat/completions",
1586
1587
  modelId: this.modelId
@@ -1588,7 +1589,7 @@ var OpenRouterChatLanguageModel = class {
1588
1589
  requestBodyValues: args,
1589
1590
  statusCode: 200,
1590
1591
  responseHeaders,
1591
- data: responseValue.error
1592
+ data: errorData
1592
1593
  });
1593
1594
  }
1594
1595
  const response = responseValue;
@@ -2210,22 +2211,22 @@ var OpenRouterCompletionChunkSchema = import_v47.z.union([
2210
2211
  tokens: import_v47.z.array(import_v47.z.string()),
2211
2212
  token_logprobs: import_v47.z.array(import_v47.z.number()),
2212
2213
  top_logprobs: import_v47.z.array(import_v47.z.record(import_v47.z.string(), import_v47.z.number())).nullable()
2213
- }).nullable().optional()
2214
- })
2214
+ }).passthrough().nullable().optional()
2215
+ }).passthrough()
2215
2216
  ),
2216
2217
  usage: import_v47.z.object({
2217
2218
  prompt_tokens: import_v47.z.number(),
2218
2219
  prompt_tokens_details: import_v47.z.object({
2219
2220
  cached_tokens: import_v47.z.number()
2220
- }).nullish(),
2221
+ }).passthrough().nullish(),
2221
2222
  completion_tokens: import_v47.z.number(),
2222
2223
  completion_tokens_details: import_v47.z.object({
2223
2224
  reasoning_tokens: import_v47.z.number()
2224
- }).nullish(),
2225
+ }).passthrough().nullish(),
2225
2226
  total_tokens: import_v47.z.number(),
2226
2227
  cost: import_v47.z.number().optional()
2227
- }).nullish()
2228
- }),
2228
+ }).passthrough().nullish()
2229
+ }).passthrough(),
2229
2230
  OpenRouterErrorResponseSchema
2230
2231
  ]);
2231
2232
 
@@ -2321,8 +2322,9 @@ var OpenRouterCompletionLanguageModel = class {
2321
2322
  fetch: this.config.fetch
2322
2323
  });
2323
2324
  if ("error" in response) {
2325
+ const errorData = response.error;
2324
2326
  throw new APICallError({
2325
- message: response.error.message,
2327
+ message: errorData.message,
2326
2328
  url: this.config.url({
2327
2329
  path: "/completions",
2328
2330
  modelId: this.modelId
@@ -2330,7 +2332,7 @@ var OpenRouterCompletionLanguageModel = class {
2330
2332
  requestBodyValues: args,
2331
2333
  statusCode: 200,
2332
2334
  responseHeaders,
2333
- data: response.error
2335
+ data: errorData
2334
2336
  });
2335
2337
  }
2336
2338
  const choice = response.choices[0];