@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 +56 -54
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +56 -54
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +55 -53
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +55 -53
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -916,7 +916,7 @@ var CommonReasoningDetailSchema = z.object({
|
|
|
916
916
|
id: z.string().nullish(),
|
|
917
917
|
format: z.nativeEnum(ReasoningFormat).nullish(),
|
|
918
918
|
index: z.number().optional()
|
|
919
|
-
});
|
|
919
|
+
}).passthrough();
|
|
920
920
|
var ReasoningDetailSummarySchema = z.object({
|
|
921
921
|
type: z.literal("reasoning.summary" /* Summary */),
|
|
922
922
|
summary: z.string()
|
|
@@ -969,8 +969,8 @@ var OpenRouterErrorResponseSchema = z2.object({
|
|
|
969
969
|
message: z2.string(),
|
|
970
970
|
type: z2.string().nullable().optional().default(null),
|
|
971
971
|
param: z2.any().nullable().optional().default(null)
|
|
972
|
-
})
|
|
973
|
-
});
|
|
972
|
+
}).passthrough()
|
|
973
|
+
}).passthrough();
|
|
974
974
|
var openrouterFailedResponseHandler = createJsonErrorResponseHandler({
|
|
975
975
|
errorSchema: OpenRouterErrorResponseSchema,
|
|
976
976
|
errorToMessage: (data) => data.error.message
|
|
@@ -985,18 +985,18 @@ var OpenRouterProviderMetadataSchema = z3.object({
|
|
|
985
985
|
promptTokens: z3.number(),
|
|
986
986
|
promptTokensDetails: z3.object({
|
|
987
987
|
cachedTokens: z3.number()
|
|
988
|
-
}).optional(),
|
|
988
|
+
}).passthrough().optional(),
|
|
989
989
|
completionTokens: z3.number(),
|
|
990
990
|
completionTokensDetails: z3.object({
|
|
991
991
|
reasoningTokens: z3.number()
|
|
992
|
-
}).optional(),
|
|
992
|
+
}).passthrough().optional(),
|
|
993
993
|
totalTokens: z3.number(),
|
|
994
994
|
cost: z3.number().optional(),
|
|
995
995
|
costDetails: z3.object({
|
|
996
996
|
upstreamInferenceCost: z3.number()
|
|
997
|
-
})
|
|
998
|
-
})
|
|
999
|
-
});
|
|
997
|
+
}).passthrough()
|
|
998
|
+
}).passthrough()
|
|
999
|
+
}).passthrough();
|
|
1000
1000
|
var OpenRouterProviderOptionsSchema = z3.object({
|
|
1001
1001
|
openrouter: z3.object({
|
|
1002
1002
|
reasoning_details: z3.array(ReasoningDetailUnionSchema).optional()
|
|
@@ -1282,8 +1282,8 @@ var ImageResponseSchema = z6.object({
|
|
|
1282
1282
|
type: z6.literal("image_url"),
|
|
1283
1283
|
image_url: z6.object({
|
|
1284
1284
|
url: z6.string()
|
|
1285
|
-
})
|
|
1286
|
-
});
|
|
1285
|
+
}).passthrough()
|
|
1286
|
+
}).passthrough();
|
|
1287
1287
|
var ImageResponseWithUnknownSchema = z6.union([
|
|
1288
1288
|
ImageResponseSchema,
|
|
1289
1289
|
z6.unknown().transform(() => null)
|
|
@@ -1299,18 +1299,18 @@ var OpenRouterChatCompletionBaseResponseSchema = z7.object({
|
|
|
1299
1299
|
prompt_tokens: z7.number(),
|
|
1300
1300
|
prompt_tokens_details: z7.object({
|
|
1301
1301
|
cached_tokens: z7.number()
|
|
1302
|
-
}).nullish(),
|
|
1302
|
+
}).passthrough().nullish(),
|
|
1303
1303
|
completion_tokens: z7.number(),
|
|
1304
1304
|
completion_tokens_details: z7.object({
|
|
1305
1305
|
reasoning_tokens: z7.number()
|
|
1306
|
-
}).nullish(),
|
|
1306
|
+
}).passthrough().nullish(),
|
|
1307
1307
|
total_tokens: z7.number(),
|
|
1308
1308
|
cost: z7.number().optional(),
|
|
1309
1309
|
cost_details: z7.object({
|
|
1310
1310
|
upstream_inference_cost: z7.number().nullish()
|
|
1311
|
-
}).nullish()
|
|
1312
|
-
}).nullish()
|
|
1313
|
-
});
|
|
1311
|
+
}).passthrough().nullish()
|
|
1312
|
+
}).passthrough().nullish()
|
|
1313
|
+
}).passthrough();
|
|
1314
1314
|
var OpenRouterNonStreamChatCompletionResponseSchema = z7.union([
|
|
1315
1315
|
// Success response with choices
|
|
1316
1316
|
OpenRouterChatCompletionBaseResponseSchema.extend({
|
|
@@ -1329,8 +1329,8 @@ var OpenRouterNonStreamChatCompletionResponseSchema = z7.union([
|
|
|
1329
1329
|
function: z7.object({
|
|
1330
1330
|
name: z7.string(),
|
|
1331
1331
|
arguments: z7.string()
|
|
1332
|
-
})
|
|
1333
|
-
})
|
|
1332
|
+
}).passthrough()
|
|
1333
|
+
}).passthrough()
|
|
1334
1334
|
).optional(),
|
|
1335
1335
|
annotations: z7.array(
|
|
1336
1336
|
z7.union([
|
|
@@ -1343,16 +1343,16 @@ var OpenRouterNonStreamChatCompletionResponseSchema = z7.union([
|
|
|
1343
1343
|
title: z7.string(),
|
|
1344
1344
|
url: z7.string(),
|
|
1345
1345
|
content: z7.string().optional()
|
|
1346
|
-
})
|
|
1347
|
-
}),
|
|
1346
|
+
}).passthrough()
|
|
1347
|
+
}).passthrough(),
|
|
1348
1348
|
// File annotation from FileParserPlugin (old format)
|
|
1349
1349
|
z7.object({
|
|
1350
1350
|
type: z7.literal("file_annotation"),
|
|
1351
1351
|
file_annotation: z7.object({
|
|
1352
1352
|
file_id: z7.string(),
|
|
1353
1353
|
quote: z7.string().optional()
|
|
1354
|
-
})
|
|
1355
|
-
}),
|
|
1354
|
+
}).passthrough()
|
|
1355
|
+
}).passthrough(),
|
|
1356
1356
|
// File annotation from FileParserPlugin (new format)
|
|
1357
1357
|
z7.object({
|
|
1358
1358
|
type: z7.literal("file"),
|
|
@@ -1363,13 +1363,13 @@ var OpenRouterNonStreamChatCompletionResponseSchema = z7.union([
|
|
|
1363
1363
|
z7.object({
|
|
1364
1364
|
type: z7.string(),
|
|
1365
1365
|
text: z7.string()
|
|
1366
|
-
})
|
|
1366
|
+
}).passthrough()
|
|
1367
1367
|
).optional()
|
|
1368
|
-
})
|
|
1369
|
-
})
|
|
1368
|
+
}).passthrough()
|
|
1369
|
+
}).passthrough()
|
|
1370
1370
|
])
|
|
1371
1371
|
).nullish()
|
|
1372
|
-
}),
|
|
1372
|
+
}).passthrough(),
|
|
1373
1373
|
index: z7.number().nullish(),
|
|
1374
1374
|
logprobs: z7.object({
|
|
1375
1375
|
content: z7.array(
|
|
@@ -1380,13 +1380,13 @@ var OpenRouterNonStreamChatCompletionResponseSchema = z7.union([
|
|
|
1380
1380
|
z7.object({
|
|
1381
1381
|
token: z7.string(),
|
|
1382
1382
|
logprob: z7.number()
|
|
1383
|
-
})
|
|
1383
|
+
}).passthrough()
|
|
1384
1384
|
)
|
|
1385
|
-
})
|
|
1385
|
+
}).passthrough()
|
|
1386
1386
|
).nullable()
|
|
1387
|
-
}).nullable().optional(),
|
|
1387
|
+
}).passthrough().nullable().optional(),
|
|
1388
1388
|
finish_reason: z7.string().optional().nullable()
|
|
1389
|
-
})
|
|
1389
|
+
}).passthrough()
|
|
1390
1390
|
)
|
|
1391
1391
|
}),
|
|
1392
1392
|
// Error response (HTTP 200 with error payload)
|
|
@@ -1412,8 +1412,8 @@ var OpenRouterStreamChatCompletionChunkSchema = z7.union([
|
|
|
1412
1412
|
function: z7.object({
|
|
1413
1413
|
name: z7.string().nullish(),
|
|
1414
1414
|
arguments: z7.string().nullish()
|
|
1415
|
-
})
|
|
1416
|
-
})
|
|
1415
|
+
}).passthrough()
|
|
1416
|
+
}).passthrough()
|
|
1417
1417
|
).nullish(),
|
|
1418
1418
|
annotations: z7.array(
|
|
1419
1419
|
z7.union([
|
|
@@ -1426,16 +1426,16 @@ var OpenRouterStreamChatCompletionChunkSchema = z7.union([
|
|
|
1426
1426
|
title: z7.string(),
|
|
1427
1427
|
url: z7.string(),
|
|
1428
1428
|
content: z7.string().optional()
|
|
1429
|
-
})
|
|
1430
|
-
}),
|
|
1429
|
+
}).passthrough()
|
|
1430
|
+
}).passthrough(),
|
|
1431
1431
|
// File annotation from FileParserPlugin (old format)
|
|
1432
1432
|
z7.object({
|
|
1433
1433
|
type: z7.literal("file_annotation"),
|
|
1434
1434
|
file_annotation: z7.object({
|
|
1435
1435
|
file_id: z7.string(),
|
|
1436
1436
|
quote: z7.string().optional()
|
|
1437
|
-
})
|
|
1438
|
-
}),
|
|
1437
|
+
}).passthrough()
|
|
1438
|
+
}).passthrough(),
|
|
1439
1439
|
// File annotation from FileParserPlugin (new format)
|
|
1440
1440
|
z7.object({
|
|
1441
1441
|
type: z7.literal("file"),
|
|
@@ -1446,13 +1446,13 @@ var OpenRouterStreamChatCompletionChunkSchema = z7.union([
|
|
|
1446
1446
|
z7.object({
|
|
1447
1447
|
type: z7.string(),
|
|
1448
1448
|
text: z7.string()
|
|
1449
|
-
})
|
|
1449
|
+
}).passthrough()
|
|
1450
1450
|
).optional()
|
|
1451
|
-
})
|
|
1452
|
-
})
|
|
1451
|
+
}).passthrough()
|
|
1452
|
+
}).passthrough()
|
|
1453
1453
|
])
|
|
1454
1454
|
).nullish()
|
|
1455
|
-
}).nullish(),
|
|
1455
|
+
}).passthrough().nullish(),
|
|
1456
1456
|
logprobs: z7.object({
|
|
1457
1457
|
content: z7.array(
|
|
1458
1458
|
z7.object({
|
|
@@ -1462,14 +1462,14 @@ var OpenRouterStreamChatCompletionChunkSchema = z7.union([
|
|
|
1462
1462
|
z7.object({
|
|
1463
1463
|
token: z7.string(),
|
|
1464
1464
|
logprob: z7.number()
|
|
1465
|
-
})
|
|
1465
|
+
}).passthrough()
|
|
1466
1466
|
)
|
|
1467
|
-
})
|
|
1467
|
+
}).passthrough()
|
|
1468
1468
|
).nullable()
|
|
1469
|
-
}).nullish(),
|
|
1469
|
+
}).passthrough().nullish(),
|
|
1470
1470
|
finish_reason: z7.string().nullable().optional(),
|
|
1471
1471
|
index: z7.number().nullish()
|
|
1472
|
-
})
|
|
1472
|
+
}).passthrough()
|
|
1473
1473
|
)
|
|
1474
1474
|
}),
|
|
1475
1475
|
OpenRouterErrorResponseSchema
|
|
@@ -1590,8 +1590,9 @@ var OpenRouterChatLanguageModel = class {
|
|
|
1590
1590
|
fetch: this.config.fetch
|
|
1591
1591
|
});
|
|
1592
1592
|
if ("error" in responseValue) {
|
|
1593
|
+
const errorData = responseValue.error;
|
|
1593
1594
|
throw new APICallError({
|
|
1594
|
-
message:
|
|
1595
|
+
message: errorData.message,
|
|
1595
1596
|
url: this.config.url({
|
|
1596
1597
|
path: "/chat/completions",
|
|
1597
1598
|
modelId: this.modelId
|
|
@@ -1599,7 +1600,7 @@ var OpenRouterChatLanguageModel = class {
|
|
|
1599
1600
|
requestBodyValues: args,
|
|
1600
1601
|
statusCode: 200,
|
|
1601
1602
|
responseHeaders,
|
|
1602
|
-
data:
|
|
1603
|
+
data: errorData
|
|
1603
1604
|
});
|
|
1604
1605
|
}
|
|
1605
1606
|
const response = responseValue;
|
|
@@ -2221,22 +2222,22 @@ var OpenRouterCompletionChunkSchema = z8.union([
|
|
|
2221
2222
|
tokens: z8.array(z8.string()),
|
|
2222
2223
|
token_logprobs: z8.array(z8.number()),
|
|
2223
2224
|
top_logprobs: z8.array(z8.record(z8.string(), z8.number())).nullable()
|
|
2224
|
-
}).nullable().optional()
|
|
2225
|
-
})
|
|
2225
|
+
}).passthrough().nullable().optional()
|
|
2226
|
+
}).passthrough()
|
|
2226
2227
|
),
|
|
2227
2228
|
usage: z8.object({
|
|
2228
2229
|
prompt_tokens: z8.number(),
|
|
2229
2230
|
prompt_tokens_details: z8.object({
|
|
2230
2231
|
cached_tokens: z8.number()
|
|
2231
|
-
}).nullish(),
|
|
2232
|
+
}).passthrough().nullish(),
|
|
2232
2233
|
completion_tokens: z8.number(),
|
|
2233
2234
|
completion_tokens_details: z8.object({
|
|
2234
2235
|
reasoning_tokens: z8.number()
|
|
2235
|
-
}).nullish(),
|
|
2236
|
+
}).passthrough().nullish(),
|
|
2236
2237
|
total_tokens: z8.number(),
|
|
2237
2238
|
cost: z8.number().optional()
|
|
2238
|
-
}).nullish()
|
|
2239
|
-
}),
|
|
2239
|
+
}).passthrough().nullish()
|
|
2240
|
+
}).passthrough(),
|
|
2240
2241
|
OpenRouterErrorResponseSchema
|
|
2241
2242
|
]);
|
|
2242
2243
|
|
|
@@ -2332,8 +2333,9 @@ var OpenRouterCompletionLanguageModel = class {
|
|
|
2332
2333
|
fetch: this.config.fetch
|
|
2333
2334
|
});
|
|
2334
2335
|
if ("error" in response) {
|
|
2336
|
+
const errorData = response.error;
|
|
2335
2337
|
throw new APICallError({
|
|
2336
|
-
message:
|
|
2338
|
+
message: errorData.message,
|
|
2337
2339
|
url: this.config.url({
|
|
2338
2340
|
path: "/completions",
|
|
2339
2341
|
modelId: this.modelId
|
|
@@ -2341,7 +2343,7 @@ var OpenRouterCompletionLanguageModel = class {
|
|
|
2341
2343
|
requestBodyValues: args,
|
|
2342
2344
|
statusCode: 200,
|
|
2343
2345
|
responseHeaders,
|
|
2344
|
-
data:
|
|
2346
|
+
data: errorData
|
|
2345
2347
|
});
|
|
2346
2348
|
}
|
|
2347
2349
|
const choice = response.choices[0];
|
|
@@ -2535,7 +2537,7 @@ function withUserAgentSuffix(headers, ...userAgentSuffixParts) {
|
|
|
2535
2537
|
}
|
|
2536
2538
|
|
|
2537
2539
|
// src/version.ts
|
|
2538
|
-
var VERSION = false ? "0.0.0-test" : "1.2.
|
|
2540
|
+
var VERSION = false ? "0.0.0-test" : "1.2.3";
|
|
2539
2541
|
|
|
2540
2542
|
// src/provider.ts
|
|
2541
2543
|
function createOpenRouter(options = {}) {
|