@openrouter/ai-sdk-provider 1.2.2 → 1.2.4
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.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +114 -63
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +114 -63
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +2 -1
- package/dist/internal/index.d.ts +2 -1
- package/dist/internal/index.js +113 -62
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +113 -62
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -7,7 +7,8 @@ declare enum ReasoningFormat {
|
|
|
7
7
|
Unknown = "unknown",
|
|
8
8
|
OpenAIResponsesV1 = "openai-responses-v1",
|
|
9
9
|
XAIResponsesV1 = "xai-responses-v1",
|
|
10
|
-
AnthropicClaudeV1 = "anthropic-claude-v1"
|
|
10
|
+
AnthropicClaudeV1 = "anthropic-claude-v1",
|
|
11
|
+
GoogleGeminiV1 = "google-gemini-v1"
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
declare enum ReasoningDetailType {
|
package/dist/internal/index.d.ts
CHANGED
|
@@ -7,7 +7,8 @@ declare enum ReasoningFormat {
|
|
|
7
7
|
Unknown = "unknown",
|
|
8
8
|
OpenAIResponsesV1 = "openai-responses-v1",
|
|
9
9
|
XAIResponsesV1 = "xai-responses-v1",
|
|
10
|
-
AnthropicClaudeV1 = "anthropic-claude-v1"
|
|
10
|
+
AnthropicClaudeV1 = "anthropic-claude-v1",
|
|
11
|
+
GoogleGeminiV1 = "google-gemini-v1"
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
declare enum ReasoningDetailType {
|
package/dist/internal/index.js
CHANGED
|
@@ -897,6 +897,7 @@ var ReasoningFormat = /* @__PURE__ */ ((ReasoningFormat2) => {
|
|
|
897
897
|
ReasoningFormat2["OpenAIResponsesV1"] = "openai-responses-v1";
|
|
898
898
|
ReasoningFormat2["XAIResponsesV1"] = "xai-responses-v1";
|
|
899
899
|
ReasoningFormat2["AnthropicClaudeV1"] = "anthropic-claude-v1";
|
|
900
|
+
ReasoningFormat2["GoogleGeminiV1"] = "google-gemini-v1";
|
|
900
901
|
return ReasoningFormat2;
|
|
901
902
|
})(ReasoningFormat || {});
|
|
902
903
|
|
|
@@ -905,7 +906,7 @@ var CommonReasoningDetailSchema = import_v4.z.object({
|
|
|
905
906
|
id: import_v4.z.string().nullish(),
|
|
906
907
|
format: import_v4.z.nativeEnum(ReasoningFormat).nullish(),
|
|
907
908
|
index: import_v4.z.number().optional()
|
|
908
|
-
});
|
|
909
|
+
}).passthrough();
|
|
909
910
|
var ReasoningDetailSummarySchema = import_v4.z.object({
|
|
910
911
|
type: import_v4.z.literal("reasoning.summary" /* Summary */),
|
|
911
912
|
summary: import_v4.z.string()
|
|
@@ -958,8 +959,8 @@ var OpenRouterErrorResponseSchema = import_v42.z.object({
|
|
|
958
959
|
message: import_v42.z.string(),
|
|
959
960
|
type: import_v42.z.string().nullable().optional().default(null),
|
|
960
961
|
param: import_v42.z.any().nullable().optional().default(null)
|
|
961
|
-
})
|
|
962
|
-
});
|
|
962
|
+
}).passthrough()
|
|
963
|
+
}).passthrough();
|
|
963
964
|
var openrouterFailedResponseHandler = createJsonErrorResponseHandler({
|
|
964
965
|
errorSchema: OpenRouterErrorResponseSchema,
|
|
965
966
|
errorToMessage: (data) => data.error.message
|
|
@@ -974,18 +975,18 @@ var OpenRouterProviderMetadataSchema = import_v43.z.object({
|
|
|
974
975
|
promptTokens: import_v43.z.number(),
|
|
975
976
|
promptTokensDetails: import_v43.z.object({
|
|
976
977
|
cachedTokens: import_v43.z.number()
|
|
977
|
-
}).optional(),
|
|
978
|
+
}).passthrough().optional(),
|
|
978
979
|
completionTokens: import_v43.z.number(),
|
|
979
980
|
completionTokensDetails: import_v43.z.object({
|
|
980
981
|
reasoningTokens: import_v43.z.number()
|
|
981
|
-
}).optional(),
|
|
982
|
+
}).passthrough().optional(),
|
|
982
983
|
totalTokens: import_v43.z.number(),
|
|
983
984
|
cost: import_v43.z.number().optional(),
|
|
984
985
|
costDetails: import_v43.z.object({
|
|
985
986
|
upstreamInferenceCost: import_v43.z.number()
|
|
986
|
-
})
|
|
987
|
-
})
|
|
988
|
-
});
|
|
987
|
+
}).passthrough()
|
|
988
|
+
}).passthrough()
|
|
989
|
+
}).passthrough();
|
|
989
990
|
var OpenRouterProviderOptionsSchema = import_v43.z.object({
|
|
990
991
|
openrouter: import_v43.z.object({
|
|
991
992
|
reasoning_details: import_v43.z.array(ReasoningDetailUnionSchema).optional()
|
|
@@ -1271,8 +1272,8 @@ var ImageResponseSchema = import_v45.z.object({
|
|
|
1271
1272
|
type: import_v45.z.literal("image_url"),
|
|
1272
1273
|
image_url: import_v45.z.object({
|
|
1273
1274
|
url: import_v45.z.string()
|
|
1274
|
-
})
|
|
1275
|
-
});
|
|
1275
|
+
}).passthrough()
|
|
1276
|
+
}).passthrough();
|
|
1276
1277
|
var ImageResponseWithUnknownSchema = import_v45.z.union([
|
|
1277
1278
|
ImageResponseSchema,
|
|
1278
1279
|
import_v45.z.unknown().transform(() => null)
|
|
@@ -1288,18 +1289,18 @@ var OpenRouterChatCompletionBaseResponseSchema = import_v46.z.object({
|
|
|
1288
1289
|
prompt_tokens: import_v46.z.number(),
|
|
1289
1290
|
prompt_tokens_details: import_v46.z.object({
|
|
1290
1291
|
cached_tokens: import_v46.z.number()
|
|
1291
|
-
}).nullish(),
|
|
1292
|
+
}).passthrough().nullish(),
|
|
1292
1293
|
completion_tokens: import_v46.z.number(),
|
|
1293
1294
|
completion_tokens_details: import_v46.z.object({
|
|
1294
1295
|
reasoning_tokens: import_v46.z.number()
|
|
1295
|
-
}).nullish(),
|
|
1296
|
+
}).passthrough().nullish(),
|
|
1296
1297
|
total_tokens: import_v46.z.number(),
|
|
1297
1298
|
cost: import_v46.z.number().optional(),
|
|
1298
1299
|
cost_details: import_v46.z.object({
|
|
1299
1300
|
upstream_inference_cost: import_v46.z.number().nullish()
|
|
1300
|
-
}).nullish()
|
|
1301
|
-
}).nullish()
|
|
1302
|
-
});
|
|
1301
|
+
}).passthrough().nullish()
|
|
1302
|
+
}).passthrough().nullish()
|
|
1303
|
+
}).passthrough();
|
|
1303
1304
|
var OpenRouterNonStreamChatCompletionResponseSchema = import_v46.z.union([
|
|
1304
1305
|
// Success response with choices
|
|
1305
1306
|
OpenRouterChatCompletionBaseResponseSchema.extend({
|
|
@@ -1318,8 +1319,8 @@ var OpenRouterNonStreamChatCompletionResponseSchema = import_v46.z.union([
|
|
|
1318
1319
|
function: import_v46.z.object({
|
|
1319
1320
|
name: import_v46.z.string(),
|
|
1320
1321
|
arguments: import_v46.z.string()
|
|
1321
|
-
})
|
|
1322
|
-
})
|
|
1322
|
+
}).passthrough()
|
|
1323
|
+
}).passthrough()
|
|
1323
1324
|
).optional(),
|
|
1324
1325
|
annotations: import_v46.z.array(
|
|
1325
1326
|
import_v46.z.union([
|
|
@@ -1332,16 +1333,16 @@ var OpenRouterNonStreamChatCompletionResponseSchema = import_v46.z.union([
|
|
|
1332
1333
|
title: import_v46.z.string(),
|
|
1333
1334
|
url: import_v46.z.string(),
|
|
1334
1335
|
content: import_v46.z.string().optional()
|
|
1335
|
-
})
|
|
1336
|
-
}),
|
|
1336
|
+
}).passthrough()
|
|
1337
|
+
}).passthrough(),
|
|
1337
1338
|
// File annotation from FileParserPlugin (old format)
|
|
1338
1339
|
import_v46.z.object({
|
|
1339
1340
|
type: import_v46.z.literal("file_annotation"),
|
|
1340
1341
|
file_annotation: import_v46.z.object({
|
|
1341
1342
|
file_id: import_v46.z.string(),
|
|
1342
1343
|
quote: import_v46.z.string().optional()
|
|
1343
|
-
})
|
|
1344
|
-
}),
|
|
1344
|
+
}).passthrough()
|
|
1345
|
+
}).passthrough(),
|
|
1345
1346
|
// File annotation from FileParserPlugin (new format)
|
|
1346
1347
|
import_v46.z.object({
|
|
1347
1348
|
type: import_v46.z.literal("file"),
|
|
@@ -1352,13 +1353,13 @@ var OpenRouterNonStreamChatCompletionResponseSchema = import_v46.z.union([
|
|
|
1352
1353
|
import_v46.z.object({
|
|
1353
1354
|
type: import_v46.z.string(),
|
|
1354
1355
|
text: import_v46.z.string()
|
|
1355
|
-
})
|
|
1356
|
+
}).passthrough()
|
|
1356
1357
|
).optional()
|
|
1357
|
-
})
|
|
1358
|
-
})
|
|
1358
|
+
}).passthrough()
|
|
1359
|
+
}).passthrough()
|
|
1359
1360
|
])
|
|
1360
1361
|
).nullish()
|
|
1361
|
-
}),
|
|
1362
|
+
}).passthrough(),
|
|
1362
1363
|
index: import_v46.z.number().nullish(),
|
|
1363
1364
|
logprobs: import_v46.z.object({
|
|
1364
1365
|
content: import_v46.z.array(
|
|
@@ -1369,13 +1370,13 @@ var OpenRouterNonStreamChatCompletionResponseSchema = import_v46.z.union([
|
|
|
1369
1370
|
import_v46.z.object({
|
|
1370
1371
|
token: import_v46.z.string(),
|
|
1371
1372
|
logprob: import_v46.z.number()
|
|
1372
|
-
})
|
|
1373
|
+
}).passthrough()
|
|
1373
1374
|
)
|
|
1374
|
-
})
|
|
1375
|
+
}).passthrough()
|
|
1375
1376
|
).nullable()
|
|
1376
|
-
}).nullable().optional(),
|
|
1377
|
+
}).passthrough().nullable().optional(),
|
|
1377
1378
|
finish_reason: import_v46.z.string().optional().nullable()
|
|
1378
|
-
})
|
|
1379
|
+
}).passthrough()
|
|
1379
1380
|
)
|
|
1380
1381
|
}),
|
|
1381
1382
|
// Error response (HTTP 200 with error payload)
|
|
@@ -1401,8 +1402,8 @@ var OpenRouterStreamChatCompletionChunkSchema = import_v46.z.union([
|
|
|
1401
1402
|
function: import_v46.z.object({
|
|
1402
1403
|
name: import_v46.z.string().nullish(),
|
|
1403
1404
|
arguments: import_v46.z.string().nullish()
|
|
1404
|
-
})
|
|
1405
|
-
})
|
|
1405
|
+
}).passthrough()
|
|
1406
|
+
}).passthrough()
|
|
1406
1407
|
).nullish(),
|
|
1407
1408
|
annotations: import_v46.z.array(
|
|
1408
1409
|
import_v46.z.union([
|
|
@@ -1415,16 +1416,16 @@ var OpenRouterStreamChatCompletionChunkSchema = import_v46.z.union([
|
|
|
1415
1416
|
title: import_v46.z.string(),
|
|
1416
1417
|
url: import_v46.z.string(),
|
|
1417
1418
|
content: import_v46.z.string().optional()
|
|
1418
|
-
})
|
|
1419
|
-
}),
|
|
1419
|
+
}).passthrough()
|
|
1420
|
+
}).passthrough(),
|
|
1420
1421
|
// File annotation from FileParserPlugin (old format)
|
|
1421
1422
|
import_v46.z.object({
|
|
1422
1423
|
type: import_v46.z.literal("file_annotation"),
|
|
1423
1424
|
file_annotation: import_v46.z.object({
|
|
1424
1425
|
file_id: import_v46.z.string(),
|
|
1425
1426
|
quote: import_v46.z.string().optional()
|
|
1426
|
-
})
|
|
1427
|
-
}),
|
|
1427
|
+
}).passthrough()
|
|
1428
|
+
}).passthrough(),
|
|
1428
1429
|
// File annotation from FileParserPlugin (new format)
|
|
1429
1430
|
import_v46.z.object({
|
|
1430
1431
|
type: import_v46.z.literal("file"),
|
|
@@ -1435,13 +1436,13 @@ var OpenRouterStreamChatCompletionChunkSchema = import_v46.z.union([
|
|
|
1435
1436
|
import_v46.z.object({
|
|
1436
1437
|
type: import_v46.z.string(),
|
|
1437
1438
|
text: import_v46.z.string()
|
|
1438
|
-
})
|
|
1439
|
+
}).passthrough()
|
|
1439
1440
|
).optional()
|
|
1440
|
-
})
|
|
1441
|
-
})
|
|
1441
|
+
}).passthrough()
|
|
1442
|
+
}).passthrough()
|
|
1442
1443
|
])
|
|
1443
1444
|
).nullish()
|
|
1444
|
-
}).nullish(),
|
|
1445
|
+
}).passthrough().nullish(),
|
|
1445
1446
|
logprobs: import_v46.z.object({
|
|
1446
1447
|
content: import_v46.z.array(
|
|
1447
1448
|
import_v46.z.object({
|
|
@@ -1451,14 +1452,14 @@ var OpenRouterStreamChatCompletionChunkSchema = import_v46.z.union([
|
|
|
1451
1452
|
import_v46.z.object({
|
|
1452
1453
|
token: import_v46.z.string(),
|
|
1453
1454
|
logprob: import_v46.z.number()
|
|
1454
|
-
})
|
|
1455
|
+
}).passthrough()
|
|
1455
1456
|
)
|
|
1456
|
-
})
|
|
1457
|
+
}).passthrough()
|
|
1457
1458
|
).nullable()
|
|
1458
|
-
}).nullish(),
|
|
1459
|
+
}).passthrough().nullish(),
|
|
1459
1460
|
finish_reason: import_v46.z.string().nullable().optional(),
|
|
1460
1461
|
index: import_v46.z.number().nullish()
|
|
1461
|
-
})
|
|
1462
|
+
}).passthrough()
|
|
1462
1463
|
)
|
|
1463
1464
|
}),
|
|
1464
1465
|
OpenRouterErrorResponseSchema
|
|
@@ -1544,7 +1545,9 @@ var OpenRouterChatLanguageModel = class {
|
|
|
1544
1545
|
});
|
|
1545
1546
|
}
|
|
1546
1547
|
if (tools && tools.length > 0) {
|
|
1547
|
-
const mappedTools = tools.filter(
|
|
1548
|
+
const mappedTools = tools.filter(
|
|
1549
|
+
(tool) => tool.type === "function"
|
|
1550
|
+
).map((tool) => ({
|
|
1548
1551
|
type: "function",
|
|
1549
1552
|
function: {
|
|
1550
1553
|
name: tool.name,
|
|
@@ -1579,8 +1582,9 @@ var OpenRouterChatLanguageModel = class {
|
|
|
1579
1582
|
fetch: this.config.fetch
|
|
1580
1583
|
});
|
|
1581
1584
|
if ("error" in responseValue) {
|
|
1585
|
+
const errorData = responseValue.error;
|
|
1582
1586
|
throw new APICallError({
|
|
1583
|
-
message:
|
|
1587
|
+
message: errorData.message,
|
|
1584
1588
|
url: this.config.url({
|
|
1585
1589
|
path: "/chat/completions",
|
|
1586
1590
|
modelId: this.modelId
|
|
@@ -1588,7 +1592,7 @@ var OpenRouterChatLanguageModel = class {
|
|
|
1588
1592
|
requestBodyValues: args,
|
|
1589
1593
|
statusCode: 200,
|
|
1590
1594
|
responseHeaders,
|
|
1591
|
-
data:
|
|
1595
|
+
data: errorData
|
|
1592
1596
|
});
|
|
1593
1597
|
}
|
|
1594
1598
|
const response = responseValue;
|
|
@@ -1618,7 +1622,12 @@ var OpenRouterChatLanguageModel = class {
|
|
|
1618
1622
|
if (detail.text) {
|
|
1619
1623
|
return {
|
|
1620
1624
|
type: "reasoning",
|
|
1621
|
-
text: detail.text
|
|
1625
|
+
text: detail.text,
|
|
1626
|
+
providerMetadata: {
|
|
1627
|
+
openrouter: {
|
|
1628
|
+
reasoning_details: [detail]
|
|
1629
|
+
}
|
|
1630
|
+
}
|
|
1622
1631
|
};
|
|
1623
1632
|
}
|
|
1624
1633
|
break;
|
|
@@ -1627,7 +1636,12 @@ var OpenRouterChatLanguageModel = class {
|
|
|
1627
1636
|
if (detail.summary) {
|
|
1628
1637
|
return {
|
|
1629
1638
|
type: "reasoning",
|
|
1630
|
-
text: detail.summary
|
|
1639
|
+
text: detail.summary,
|
|
1640
|
+
providerMetadata: {
|
|
1641
|
+
openrouter: {
|
|
1642
|
+
reasoning_details: [detail]
|
|
1643
|
+
}
|
|
1644
|
+
}
|
|
1631
1645
|
};
|
|
1632
1646
|
}
|
|
1633
1647
|
break;
|
|
@@ -1636,7 +1650,12 @@ var OpenRouterChatLanguageModel = class {
|
|
|
1636
1650
|
if (detail.data) {
|
|
1637
1651
|
return {
|
|
1638
1652
|
type: "reasoning",
|
|
1639
|
-
text: "[REDACTED]"
|
|
1653
|
+
text: "[REDACTED]",
|
|
1654
|
+
providerMetadata: {
|
|
1655
|
+
openrouter: {
|
|
1656
|
+
reasoning_details: [detail]
|
|
1657
|
+
}
|
|
1658
|
+
}
|
|
1640
1659
|
};
|
|
1641
1660
|
}
|
|
1642
1661
|
break;
|
|
@@ -1666,7 +1685,12 @@ var OpenRouterChatLanguageModel = class {
|
|
|
1666
1685
|
type: "tool-call",
|
|
1667
1686
|
toolCallId: (_j = toolCall.id) != null ? _j : generateId(),
|
|
1668
1687
|
toolName: toolCall.function.name,
|
|
1669
|
-
input: toolCall.function.arguments
|
|
1688
|
+
input: toolCall.function.arguments,
|
|
1689
|
+
providerMetadata: {
|
|
1690
|
+
openrouter: {
|
|
1691
|
+
reasoning_details: reasoningDetails
|
|
1692
|
+
}
|
|
1693
|
+
}
|
|
1670
1694
|
});
|
|
1671
1695
|
}
|
|
1672
1696
|
}
|
|
@@ -1852,7 +1876,18 @@ var OpenRouterChatLanguageModel = class {
|
|
|
1852
1876
|
});
|
|
1853
1877
|
};
|
|
1854
1878
|
if (delta.reasoning_details && delta.reasoning_details.length > 0) {
|
|
1855
|
-
|
|
1879
|
+
for (const detail of delta.reasoning_details) {
|
|
1880
|
+
if (detail.type === "reasoning.text" /* Text */) {
|
|
1881
|
+
const lastDetail = accumulatedReasoningDetails[accumulatedReasoningDetails.length - 1];
|
|
1882
|
+
if ((lastDetail == null ? void 0 : lastDetail.type) === "reasoning.text" /* Text */) {
|
|
1883
|
+
lastDetail.text = (lastDetail.text || "") + (detail.text || "");
|
|
1884
|
+
} else {
|
|
1885
|
+
accumulatedReasoningDetails.push(__spreadValues({}, detail));
|
|
1886
|
+
}
|
|
1887
|
+
} else {
|
|
1888
|
+
accumulatedReasoningDetails.push(detail);
|
|
1889
|
+
}
|
|
1890
|
+
}
|
|
1856
1891
|
for (const detail of delta.reasoning_details) {
|
|
1857
1892
|
switch (detail.type) {
|
|
1858
1893
|
case "reasoning.text" /* Text */: {
|
|
@@ -1981,7 +2016,12 @@ var OpenRouterChatLanguageModel = class {
|
|
|
1981
2016
|
type: "tool-call",
|
|
1982
2017
|
toolCallId: toolCall2.id,
|
|
1983
2018
|
toolName: toolCall2.function.name,
|
|
1984
|
-
input: toolCall2.function.arguments
|
|
2019
|
+
input: toolCall2.function.arguments,
|
|
2020
|
+
providerMetadata: {
|
|
2021
|
+
openrouter: {
|
|
2022
|
+
reasoning_details: accumulatedReasoningDetails
|
|
2023
|
+
}
|
|
2024
|
+
}
|
|
1985
2025
|
});
|
|
1986
2026
|
toolCall2.sent = true;
|
|
1987
2027
|
}
|
|
@@ -2019,7 +2059,12 @@ var OpenRouterChatLanguageModel = class {
|
|
|
2019
2059
|
type: "tool-call",
|
|
2020
2060
|
toolCallId: (_n = toolCall.id) != null ? _n : generateId(),
|
|
2021
2061
|
toolName: toolCall.function.name,
|
|
2022
|
-
input: toolCall.function.arguments
|
|
2062
|
+
input: toolCall.function.arguments,
|
|
2063
|
+
providerMetadata: {
|
|
2064
|
+
openrouter: {
|
|
2065
|
+
reasoning_details: accumulatedReasoningDetails
|
|
2066
|
+
}
|
|
2067
|
+
}
|
|
2023
2068
|
});
|
|
2024
2069
|
toolCall.sent = true;
|
|
2025
2070
|
}
|
|
@@ -2045,7 +2090,12 @@ var OpenRouterChatLanguageModel = class {
|
|
|
2045
2090
|
toolCallId: (_a16 = toolCall.id) != null ? _a16 : generateId(),
|
|
2046
2091
|
toolName: toolCall.function.name,
|
|
2047
2092
|
// Coerce invalid arguments to an empty JSON object
|
|
2048
|
-
input: isParsableJson(toolCall.function.arguments) ? toolCall.function.arguments : "{}"
|
|
2093
|
+
input: isParsableJson(toolCall.function.arguments) ? toolCall.function.arguments : "{}",
|
|
2094
|
+
providerMetadata: {
|
|
2095
|
+
openrouter: {
|
|
2096
|
+
reasoning_details: accumulatedReasoningDetails
|
|
2097
|
+
}
|
|
2098
|
+
}
|
|
2049
2099
|
});
|
|
2050
2100
|
toolCall.sent = true;
|
|
2051
2101
|
}
|
|
@@ -2210,22 +2260,22 @@ var OpenRouterCompletionChunkSchema = import_v47.z.union([
|
|
|
2210
2260
|
tokens: import_v47.z.array(import_v47.z.string()),
|
|
2211
2261
|
token_logprobs: import_v47.z.array(import_v47.z.number()),
|
|
2212
2262
|
top_logprobs: import_v47.z.array(import_v47.z.record(import_v47.z.string(), import_v47.z.number())).nullable()
|
|
2213
|
-
}).nullable().optional()
|
|
2214
|
-
})
|
|
2263
|
+
}).passthrough().nullable().optional()
|
|
2264
|
+
}).passthrough()
|
|
2215
2265
|
),
|
|
2216
2266
|
usage: import_v47.z.object({
|
|
2217
2267
|
prompt_tokens: import_v47.z.number(),
|
|
2218
2268
|
prompt_tokens_details: import_v47.z.object({
|
|
2219
2269
|
cached_tokens: import_v47.z.number()
|
|
2220
|
-
}).nullish(),
|
|
2270
|
+
}).passthrough().nullish(),
|
|
2221
2271
|
completion_tokens: import_v47.z.number(),
|
|
2222
2272
|
completion_tokens_details: import_v47.z.object({
|
|
2223
2273
|
reasoning_tokens: import_v47.z.number()
|
|
2224
|
-
}).nullish(),
|
|
2274
|
+
}).passthrough().nullish(),
|
|
2225
2275
|
total_tokens: import_v47.z.number(),
|
|
2226
2276
|
cost: import_v47.z.number().optional()
|
|
2227
|
-
}).nullish()
|
|
2228
|
-
}),
|
|
2277
|
+
}).passthrough().nullish()
|
|
2278
|
+
}).passthrough(),
|
|
2229
2279
|
OpenRouterErrorResponseSchema
|
|
2230
2280
|
]);
|
|
2231
2281
|
|
|
@@ -2321,8 +2371,9 @@ var OpenRouterCompletionLanguageModel = class {
|
|
|
2321
2371
|
fetch: this.config.fetch
|
|
2322
2372
|
});
|
|
2323
2373
|
if ("error" in response) {
|
|
2374
|
+
const errorData = response.error;
|
|
2324
2375
|
throw new APICallError({
|
|
2325
|
-
message:
|
|
2376
|
+
message: errorData.message,
|
|
2326
2377
|
url: this.config.url({
|
|
2327
2378
|
path: "/completions",
|
|
2328
2379
|
modelId: this.modelId
|
|
@@ -2330,7 +2381,7 @@ var OpenRouterCompletionLanguageModel = class {
|
|
|
2330
2381
|
requestBodyValues: args,
|
|
2331
2382
|
statusCode: 200,
|
|
2332
2383
|
responseHeaders,
|
|
2333
|
-
data:
|
|
2384
|
+
data: errorData
|
|
2334
2385
|
});
|
|
2335
2386
|
}
|
|
2336
2387
|
const choice = response.choices[0];
|