@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.
package/dist/index.js CHANGED
@@ -951,7 +951,7 @@ var CommonReasoningDetailSchema = import_v4.z.object({
951
951
  id: import_v4.z.string().nullish(),
952
952
  format: import_v4.z.nativeEnum(ReasoningFormat).nullish(),
953
953
  index: import_v4.z.number().optional()
954
- });
954
+ }).passthrough();
955
955
  var ReasoningDetailSummarySchema = import_v4.z.object({
956
956
  type: import_v4.z.literal("reasoning.summary" /* Summary */),
957
957
  summary: import_v4.z.string()
@@ -1004,8 +1004,8 @@ var OpenRouterErrorResponseSchema = import_v42.z.object({
1004
1004
  message: import_v42.z.string(),
1005
1005
  type: import_v42.z.string().nullable().optional().default(null),
1006
1006
  param: import_v42.z.any().nullable().optional().default(null)
1007
- })
1008
- });
1007
+ }).passthrough()
1008
+ }).passthrough();
1009
1009
  var openrouterFailedResponseHandler = createJsonErrorResponseHandler({
1010
1010
  errorSchema: OpenRouterErrorResponseSchema,
1011
1011
  errorToMessage: (data) => data.error.message
@@ -1020,18 +1020,18 @@ var OpenRouterProviderMetadataSchema = import_v43.z.object({
1020
1020
  promptTokens: import_v43.z.number(),
1021
1021
  promptTokensDetails: import_v43.z.object({
1022
1022
  cachedTokens: import_v43.z.number()
1023
- }).optional(),
1023
+ }).passthrough().optional(),
1024
1024
  completionTokens: import_v43.z.number(),
1025
1025
  completionTokensDetails: import_v43.z.object({
1026
1026
  reasoningTokens: import_v43.z.number()
1027
- }).optional(),
1027
+ }).passthrough().optional(),
1028
1028
  totalTokens: import_v43.z.number(),
1029
1029
  cost: import_v43.z.number().optional(),
1030
1030
  costDetails: import_v43.z.object({
1031
1031
  upstreamInferenceCost: import_v43.z.number()
1032
- })
1033
- })
1034
- });
1032
+ }).passthrough()
1033
+ }).passthrough()
1034
+ }).passthrough();
1035
1035
  var OpenRouterProviderOptionsSchema = import_v43.z.object({
1036
1036
  openrouter: import_v43.z.object({
1037
1037
  reasoning_details: import_v43.z.array(ReasoningDetailUnionSchema).optional()
@@ -1317,8 +1317,8 @@ var ImageResponseSchema = import_v45.z.object({
1317
1317
  type: import_v45.z.literal("image_url"),
1318
1318
  image_url: import_v45.z.object({
1319
1319
  url: import_v45.z.string()
1320
- })
1321
- });
1320
+ }).passthrough()
1321
+ }).passthrough();
1322
1322
  var ImageResponseWithUnknownSchema = import_v45.z.union([
1323
1323
  ImageResponseSchema,
1324
1324
  import_v45.z.unknown().transform(() => null)
@@ -1334,18 +1334,18 @@ var OpenRouterChatCompletionBaseResponseSchema = import_v46.z.object({
1334
1334
  prompt_tokens: import_v46.z.number(),
1335
1335
  prompt_tokens_details: import_v46.z.object({
1336
1336
  cached_tokens: import_v46.z.number()
1337
- }).nullish(),
1337
+ }).passthrough().nullish(),
1338
1338
  completion_tokens: import_v46.z.number(),
1339
1339
  completion_tokens_details: import_v46.z.object({
1340
1340
  reasoning_tokens: import_v46.z.number()
1341
- }).nullish(),
1341
+ }).passthrough().nullish(),
1342
1342
  total_tokens: import_v46.z.number(),
1343
1343
  cost: import_v46.z.number().optional(),
1344
1344
  cost_details: import_v46.z.object({
1345
1345
  upstream_inference_cost: import_v46.z.number().nullish()
1346
- }).nullish()
1347
- }).nullish()
1348
- });
1346
+ }).passthrough().nullish()
1347
+ }).passthrough().nullish()
1348
+ }).passthrough();
1349
1349
  var OpenRouterNonStreamChatCompletionResponseSchema = import_v46.z.union([
1350
1350
  // Success response with choices
1351
1351
  OpenRouterChatCompletionBaseResponseSchema.extend({
@@ -1364,8 +1364,8 @@ var OpenRouterNonStreamChatCompletionResponseSchema = import_v46.z.union([
1364
1364
  function: import_v46.z.object({
1365
1365
  name: import_v46.z.string(),
1366
1366
  arguments: import_v46.z.string()
1367
- })
1368
- })
1367
+ }).passthrough()
1368
+ }).passthrough()
1369
1369
  ).optional(),
1370
1370
  annotations: import_v46.z.array(
1371
1371
  import_v46.z.union([
@@ -1378,16 +1378,16 @@ var OpenRouterNonStreamChatCompletionResponseSchema = import_v46.z.union([
1378
1378
  title: import_v46.z.string(),
1379
1379
  url: import_v46.z.string(),
1380
1380
  content: import_v46.z.string().optional()
1381
- })
1382
- }),
1381
+ }).passthrough()
1382
+ }).passthrough(),
1383
1383
  // File annotation from FileParserPlugin (old format)
1384
1384
  import_v46.z.object({
1385
1385
  type: import_v46.z.literal("file_annotation"),
1386
1386
  file_annotation: import_v46.z.object({
1387
1387
  file_id: import_v46.z.string(),
1388
1388
  quote: import_v46.z.string().optional()
1389
- })
1390
- }),
1389
+ }).passthrough()
1390
+ }).passthrough(),
1391
1391
  // File annotation from FileParserPlugin (new format)
1392
1392
  import_v46.z.object({
1393
1393
  type: import_v46.z.literal("file"),
@@ -1398,13 +1398,13 @@ var OpenRouterNonStreamChatCompletionResponseSchema = import_v46.z.union([
1398
1398
  import_v46.z.object({
1399
1399
  type: import_v46.z.string(),
1400
1400
  text: import_v46.z.string()
1401
- })
1401
+ }).passthrough()
1402
1402
  ).optional()
1403
- })
1404
- })
1403
+ }).passthrough()
1404
+ }).passthrough()
1405
1405
  ])
1406
1406
  ).nullish()
1407
- }),
1407
+ }).passthrough(),
1408
1408
  index: import_v46.z.number().nullish(),
1409
1409
  logprobs: import_v46.z.object({
1410
1410
  content: import_v46.z.array(
@@ -1415,13 +1415,13 @@ var OpenRouterNonStreamChatCompletionResponseSchema = import_v46.z.union([
1415
1415
  import_v46.z.object({
1416
1416
  token: import_v46.z.string(),
1417
1417
  logprob: import_v46.z.number()
1418
- })
1418
+ }).passthrough()
1419
1419
  )
1420
- })
1420
+ }).passthrough()
1421
1421
  ).nullable()
1422
- }).nullable().optional(),
1422
+ }).passthrough().nullable().optional(),
1423
1423
  finish_reason: import_v46.z.string().optional().nullable()
1424
- })
1424
+ }).passthrough()
1425
1425
  )
1426
1426
  }),
1427
1427
  // Error response (HTTP 200 with error payload)
@@ -1447,8 +1447,8 @@ var OpenRouterStreamChatCompletionChunkSchema = import_v46.z.union([
1447
1447
  function: import_v46.z.object({
1448
1448
  name: import_v46.z.string().nullish(),
1449
1449
  arguments: import_v46.z.string().nullish()
1450
- })
1451
- })
1450
+ }).passthrough()
1451
+ }).passthrough()
1452
1452
  ).nullish(),
1453
1453
  annotations: import_v46.z.array(
1454
1454
  import_v46.z.union([
@@ -1461,16 +1461,16 @@ var OpenRouterStreamChatCompletionChunkSchema = import_v46.z.union([
1461
1461
  title: import_v46.z.string(),
1462
1462
  url: import_v46.z.string(),
1463
1463
  content: import_v46.z.string().optional()
1464
- })
1465
- }),
1464
+ }).passthrough()
1465
+ }).passthrough(),
1466
1466
  // File annotation from FileParserPlugin (old format)
1467
1467
  import_v46.z.object({
1468
1468
  type: import_v46.z.literal("file_annotation"),
1469
1469
  file_annotation: import_v46.z.object({
1470
1470
  file_id: import_v46.z.string(),
1471
1471
  quote: import_v46.z.string().optional()
1472
- })
1473
- }),
1472
+ }).passthrough()
1473
+ }).passthrough(),
1474
1474
  // File annotation from FileParserPlugin (new format)
1475
1475
  import_v46.z.object({
1476
1476
  type: import_v46.z.literal("file"),
@@ -1481,13 +1481,13 @@ var OpenRouterStreamChatCompletionChunkSchema = import_v46.z.union([
1481
1481
  import_v46.z.object({
1482
1482
  type: import_v46.z.string(),
1483
1483
  text: import_v46.z.string()
1484
- })
1484
+ }).passthrough()
1485
1485
  ).optional()
1486
- })
1487
- })
1486
+ }).passthrough()
1487
+ }).passthrough()
1488
1488
  ])
1489
1489
  ).nullish()
1490
- }).nullish(),
1490
+ }).passthrough().nullish(),
1491
1491
  logprobs: import_v46.z.object({
1492
1492
  content: import_v46.z.array(
1493
1493
  import_v46.z.object({
@@ -1497,14 +1497,14 @@ var OpenRouterStreamChatCompletionChunkSchema = import_v46.z.union([
1497
1497
  import_v46.z.object({
1498
1498
  token: import_v46.z.string(),
1499
1499
  logprob: import_v46.z.number()
1500
- })
1500
+ }).passthrough()
1501
1501
  )
1502
- })
1502
+ }).passthrough()
1503
1503
  ).nullable()
1504
- }).nullish(),
1504
+ }).passthrough().nullish(),
1505
1505
  finish_reason: import_v46.z.string().nullable().optional(),
1506
1506
  index: import_v46.z.number().nullish()
1507
- })
1507
+ }).passthrough()
1508
1508
  )
1509
1509
  }),
1510
1510
  OpenRouterErrorResponseSchema
@@ -1625,8 +1625,9 @@ var OpenRouterChatLanguageModel = class {
1625
1625
  fetch: this.config.fetch
1626
1626
  });
1627
1627
  if ("error" in responseValue) {
1628
+ const errorData = responseValue.error;
1628
1629
  throw new APICallError({
1629
- message: responseValue.error.message,
1630
+ message: errorData.message,
1630
1631
  url: this.config.url({
1631
1632
  path: "/chat/completions",
1632
1633
  modelId: this.modelId
@@ -1634,7 +1635,7 @@ var OpenRouterChatLanguageModel = class {
1634
1635
  requestBodyValues: args,
1635
1636
  statusCode: 200,
1636
1637
  responseHeaders,
1637
- data: responseValue.error
1638
+ data: errorData
1638
1639
  });
1639
1640
  }
1640
1641
  const response = responseValue;
@@ -2256,22 +2257,22 @@ var OpenRouterCompletionChunkSchema = import_v47.z.union([
2256
2257
  tokens: import_v47.z.array(import_v47.z.string()),
2257
2258
  token_logprobs: import_v47.z.array(import_v47.z.number()),
2258
2259
  top_logprobs: import_v47.z.array(import_v47.z.record(import_v47.z.string(), import_v47.z.number())).nullable()
2259
- }).nullable().optional()
2260
- })
2260
+ }).passthrough().nullable().optional()
2261
+ }).passthrough()
2261
2262
  ),
2262
2263
  usage: import_v47.z.object({
2263
2264
  prompt_tokens: import_v47.z.number(),
2264
2265
  prompt_tokens_details: import_v47.z.object({
2265
2266
  cached_tokens: import_v47.z.number()
2266
- }).nullish(),
2267
+ }).passthrough().nullish(),
2267
2268
  completion_tokens: import_v47.z.number(),
2268
2269
  completion_tokens_details: import_v47.z.object({
2269
2270
  reasoning_tokens: import_v47.z.number()
2270
- }).nullish(),
2271
+ }).passthrough().nullish(),
2271
2272
  total_tokens: import_v47.z.number(),
2272
2273
  cost: import_v47.z.number().optional()
2273
- }).nullish()
2274
- }),
2274
+ }).passthrough().nullish()
2275
+ }).passthrough(),
2275
2276
  OpenRouterErrorResponseSchema
2276
2277
  ]);
2277
2278
 
@@ -2367,8 +2368,9 @@ var OpenRouterCompletionLanguageModel = class {
2367
2368
  fetch: this.config.fetch
2368
2369
  });
2369
2370
  if ("error" in response) {
2371
+ const errorData = response.error;
2370
2372
  throw new APICallError({
2371
- message: response.error.message,
2373
+ message: errorData.message,
2372
2374
  url: this.config.url({
2373
2375
  path: "/completions",
2374
2376
  modelId: this.modelId
@@ -2376,7 +2378,7 @@ var OpenRouterCompletionLanguageModel = class {
2376
2378
  requestBodyValues: args,
2377
2379
  statusCode: 200,
2378
2380
  responseHeaders,
2379
- data: response.error
2381
+ data: errorData
2380
2382
  });
2381
2383
  }
2382
2384
  const choice = response.choices[0];
@@ -2570,7 +2572,7 @@ function withUserAgentSuffix(headers, ...userAgentSuffixParts) {
2570
2572
  }
2571
2573
 
2572
2574
  // src/version.ts
2573
- var VERSION = false ? "0.0.0-test" : "1.2.2";
2575
+ var VERSION = false ? "0.0.0-test" : "1.2.3";
2574
2576
 
2575
2577
  // src/provider.ts
2576
2578
  function createOpenRouter(options = {}) {