@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/internal/index.mjs
CHANGED
|
@@ -871,7 +871,7 @@ var CommonReasoningDetailSchema = z.object({
|
|
|
871
871
|
id: z.string().nullish(),
|
|
872
872
|
format: z.nativeEnum(ReasoningFormat).nullish(),
|
|
873
873
|
index: z.number().optional()
|
|
874
|
-
});
|
|
874
|
+
}).passthrough();
|
|
875
875
|
var ReasoningDetailSummarySchema = z.object({
|
|
876
876
|
type: z.literal("reasoning.summary" /* Summary */),
|
|
877
877
|
summary: z.string()
|
|
@@ -924,8 +924,8 @@ var OpenRouterErrorResponseSchema = z2.object({
|
|
|
924
924
|
message: z2.string(),
|
|
925
925
|
type: z2.string().nullable().optional().default(null),
|
|
926
926
|
param: z2.any().nullable().optional().default(null)
|
|
927
|
-
})
|
|
928
|
-
});
|
|
927
|
+
}).passthrough()
|
|
928
|
+
}).passthrough();
|
|
929
929
|
var openrouterFailedResponseHandler = createJsonErrorResponseHandler({
|
|
930
930
|
errorSchema: OpenRouterErrorResponseSchema,
|
|
931
931
|
errorToMessage: (data) => data.error.message
|
|
@@ -940,18 +940,18 @@ var OpenRouterProviderMetadataSchema = z3.object({
|
|
|
940
940
|
promptTokens: z3.number(),
|
|
941
941
|
promptTokensDetails: z3.object({
|
|
942
942
|
cachedTokens: z3.number()
|
|
943
|
-
}).optional(),
|
|
943
|
+
}).passthrough().optional(),
|
|
944
944
|
completionTokens: z3.number(),
|
|
945
945
|
completionTokensDetails: z3.object({
|
|
946
946
|
reasoningTokens: z3.number()
|
|
947
|
-
}).optional(),
|
|
947
|
+
}).passthrough().optional(),
|
|
948
948
|
totalTokens: z3.number(),
|
|
949
949
|
cost: z3.number().optional(),
|
|
950
950
|
costDetails: z3.object({
|
|
951
951
|
upstreamInferenceCost: z3.number()
|
|
952
|
-
})
|
|
953
|
-
})
|
|
954
|
-
});
|
|
952
|
+
}).passthrough()
|
|
953
|
+
}).passthrough()
|
|
954
|
+
}).passthrough();
|
|
955
955
|
var OpenRouterProviderOptionsSchema = z3.object({
|
|
956
956
|
openrouter: z3.object({
|
|
957
957
|
reasoning_details: z3.array(ReasoningDetailUnionSchema).optional()
|
|
@@ -1237,8 +1237,8 @@ var ImageResponseSchema = z6.object({
|
|
|
1237
1237
|
type: z6.literal("image_url"),
|
|
1238
1238
|
image_url: z6.object({
|
|
1239
1239
|
url: z6.string()
|
|
1240
|
-
})
|
|
1241
|
-
});
|
|
1240
|
+
}).passthrough()
|
|
1241
|
+
}).passthrough();
|
|
1242
1242
|
var ImageResponseWithUnknownSchema = z6.union([
|
|
1243
1243
|
ImageResponseSchema,
|
|
1244
1244
|
z6.unknown().transform(() => null)
|
|
@@ -1254,18 +1254,18 @@ var OpenRouterChatCompletionBaseResponseSchema = z7.object({
|
|
|
1254
1254
|
prompt_tokens: z7.number(),
|
|
1255
1255
|
prompt_tokens_details: z7.object({
|
|
1256
1256
|
cached_tokens: z7.number()
|
|
1257
|
-
}).nullish(),
|
|
1257
|
+
}).passthrough().nullish(),
|
|
1258
1258
|
completion_tokens: z7.number(),
|
|
1259
1259
|
completion_tokens_details: z7.object({
|
|
1260
1260
|
reasoning_tokens: z7.number()
|
|
1261
|
-
}).nullish(),
|
|
1261
|
+
}).passthrough().nullish(),
|
|
1262
1262
|
total_tokens: z7.number(),
|
|
1263
1263
|
cost: z7.number().optional(),
|
|
1264
1264
|
cost_details: z7.object({
|
|
1265
1265
|
upstream_inference_cost: z7.number().nullish()
|
|
1266
|
-
}).nullish()
|
|
1267
|
-
}).nullish()
|
|
1268
|
-
});
|
|
1266
|
+
}).passthrough().nullish()
|
|
1267
|
+
}).passthrough().nullish()
|
|
1268
|
+
}).passthrough();
|
|
1269
1269
|
var OpenRouterNonStreamChatCompletionResponseSchema = z7.union([
|
|
1270
1270
|
// Success response with choices
|
|
1271
1271
|
OpenRouterChatCompletionBaseResponseSchema.extend({
|
|
@@ -1284,8 +1284,8 @@ var OpenRouterNonStreamChatCompletionResponseSchema = z7.union([
|
|
|
1284
1284
|
function: z7.object({
|
|
1285
1285
|
name: z7.string(),
|
|
1286
1286
|
arguments: z7.string()
|
|
1287
|
-
})
|
|
1288
|
-
})
|
|
1287
|
+
}).passthrough()
|
|
1288
|
+
}).passthrough()
|
|
1289
1289
|
).optional(),
|
|
1290
1290
|
annotations: z7.array(
|
|
1291
1291
|
z7.union([
|
|
@@ -1298,16 +1298,16 @@ var OpenRouterNonStreamChatCompletionResponseSchema = z7.union([
|
|
|
1298
1298
|
title: z7.string(),
|
|
1299
1299
|
url: z7.string(),
|
|
1300
1300
|
content: z7.string().optional()
|
|
1301
|
-
})
|
|
1302
|
-
}),
|
|
1301
|
+
}).passthrough()
|
|
1302
|
+
}).passthrough(),
|
|
1303
1303
|
// File annotation from FileParserPlugin (old format)
|
|
1304
1304
|
z7.object({
|
|
1305
1305
|
type: z7.literal("file_annotation"),
|
|
1306
1306
|
file_annotation: z7.object({
|
|
1307
1307
|
file_id: z7.string(),
|
|
1308
1308
|
quote: z7.string().optional()
|
|
1309
|
-
})
|
|
1310
|
-
}),
|
|
1309
|
+
}).passthrough()
|
|
1310
|
+
}).passthrough(),
|
|
1311
1311
|
// File annotation from FileParserPlugin (new format)
|
|
1312
1312
|
z7.object({
|
|
1313
1313
|
type: z7.literal("file"),
|
|
@@ -1318,13 +1318,13 @@ var OpenRouterNonStreamChatCompletionResponseSchema = z7.union([
|
|
|
1318
1318
|
z7.object({
|
|
1319
1319
|
type: z7.string(),
|
|
1320
1320
|
text: z7.string()
|
|
1321
|
-
})
|
|
1321
|
+
}).passthrough()
|
|
1322
1322
|
).optional()
|
|
1323
|
-
})
|
|
1324
|
-
})
|
|
1323
|
+
}).passthrough()
|
|
1324
|
+
}).passthrough()
|
|
1325
1325
|
])
|
|
1326
1326
|
).nullish()
|
|
1327
|
-
}),
|
|
1327
|
+
}).passthrough(),
|
|
1328
1328
|
index: z7.number().nullish(),
|
|
1329
1329
|
logprobs: z7.object({
|
|
1330
1330
|
content: z7.array(
|
|
@@ -1335,13 +1335,13 @@ var OpenRouterNonStreamChatCompletionResponseSchema = z7.union([
|
|
|
1335
1335
|
z7.object({
|
|
1336
1336
|
token: z7.string(),
|
|
1337
1337
|
logprob: z7.number()
|
|
1338
|
-
})
|
|
1338
|
+
}).passthrough()
|
|
1339
1339
|
)
|
|
1340
|
-
})
|
|
1340
|
+
}).passthrough()
|
|
1341
1341
|
).nullable()
|
|
1342
|
-
}).nullable().optional(),
|
|
1342
|
+
}).passthrough().nullable().optional(),
|
|
1343
1343
|
finish_reason: z7.string().optional().nullable()
|
|
1344
|
-
})
|
|
1344
|
+
}).passthrough()
|
|
1345
1345
|
)
|
|
1346
1346
|
}),
|
|
1347
1347
|
// Error response (HTTP 200 with error payload)
|
|
@@ -1367,8 +1367,8 @@ var OpenRouterStreamChatCompletionChunkSchema = z7.union([
|
|
|
1367
1367
|
function: z7.object({
|
|
1368
1368
|
name: z7.string().nullish(),
|
|
1369
1369
|
arguments: z7.string().nullish()
|
|
1370
|
-
})
|
|
1371
|
-
})
|
|
1370
|
+
}).passthrough()
|
|
1371
|
+
}).passthrough()
|
|
1372
1372
|
).nullish(),
|
|
1373
1373
|
annotations: z7.array(
|
|
1374
1374
|
z7.union([
|
|
@@ -1381,16 +1381,16 @@ var OpenRouterStreamChatCompletionChunkSchema = z7.union([
|
|
|
1381
1381
|
title: z7.string(),
|
|
1382
1382
|
url: z7.string(),
|
|
1383
1383
|
content: z7.string().optional()
|
|
1384
|
-
})
|
|
1385
|
-
}),
|
|
1384
|
+
}).passthrough()
|
|
1385
|
+
}).passthrough(),
|
|
1386
1386
|
// File annotation from FileParserPlugin (old format)
|
|
1387
1387
|
z7.object({
|
|
1388
1388
|
type: z7.literal("file_annotation"),
|
|
1389
1389
|
file_annotation: z7.object({
|
|
1390
1390
|
file_id: z7.string(),
|
|
1391
1391
|
quote: z7.string().optional()
|
|
1392
|
-
})
|
|
1393
|
-
}),
|
|
1392
|
+
}).passthrough()
|
|
1393
|
+
}).passthrough(),
|
|
1394
1394
|
// File annotation from FileParserPlugin (new format)
|
|
1395
1395
|
z7.object({
|
|
1396
1396
|
type: z7.literal("file"),
|
|
@@ -1401,13 +1401,13 @@ var OpenRouterStreamChatCompletionChunkSchema = z7.union([
|
|
|
1401
1401
|
z7.object({
|
|
1402
1402
|
type: z7.string(),
|
|
1403
1403
|
text: z7.string()
|
|
1404
|
-
})
|
|
1404
|
+
}).passthrough()
|
|
1405
1405
|
).optional()
|
|
1406
|
-
})
|
|
1407
|
-
})
|
|
1406
|
+
}).passthrough()
|
|
1407
|
+
}).passthrough()
|
|
1408
1408
|
])
|
|
1409
1409
|
).nullish()
|
|
1410
|
-
}).nullish(),
|
|
1410
|
+
}).passthrough().nullish(),
|
|
1411
1411
|
logprobs: z7.object({
|
|
1412
1412
|
content: z7.array(
|
|
1413
1413
|
z7.object({
|
|
@@ -1417,14 +1417,14 @@ var OpenRouterStreamChatCompletionChunkSchema = z7.union([
|
|
|
1417
1417
|
z7.object({
|
|
1418
1418
|
token: z7.string(),
|
|
1419
1419
|
logprob: z7.number()
|
|
1420
|
-
})
|
|
1420
|
+
}).passthrough()
|
|
1421
1421
|
)
|
|
1422
|
-
})
|
|
1422
|
+
}).passthrough()
|
|
1423
1423
|
).nullable()
|
|
1424
|
-
}).nullish(),
|
|
1424
|
+
}).passthrough().nullish(),
|
|
1425
1425
|
finish_reason: z7.string().nullable().optional(),
|
|
1426
1426
|
index: z7.number().nullish()
|
|
1427
|
-
})
|
|
1427
|
+
}).passthrough()
|
|
1428
1428
|
)
|
|
1429
1429
|
}),
|
|
1430
1430
|
OpenRouterErrorResponseSchema
|
|
@@ -1545,8 +1545,9 @@ var OpenRouterChatLanguageModel = class {
|
|
|
1545
1545
|
fetch: this.config.fetch
|
|
1546
1546
|
});
|
|
1547
1547
|
if ("error" in responseValue) {
|
|
1548
|
+
const errorData = responseValue.error;
|
|
1548
1549
|
throw new APICallError({
|
|
1549
|
-
message:
|
|
1550
|
+
message: errorData.message,
|
|
1550
1551
|
url: this.config.url({
|
|
1551
1552
|
path: "/chat/completions",
|
|
1552
1553
|
modelId: this.modelId
|
|
@@ -1554,7 +1555,7 @@ var OpenRouterChatLanguageModel = class {
|
|
|
1554
1555
|
requestBodyValues: args,
|
|
1555
1556
|
statusCode: 200,
|
|
1556
1557
|
responseHeaders,
|
|
1557
|
-
data:
|
|
1558
|
+
data: errorData
|
|
1558
1559
|
});
|
|
1559
1560
|
}
|
|
1560
1561
|
const response = responseValue;
|
|
@@ -2176,22 +2177,22 @@ var OpenRouterCompletionChunkSchema = z8.union([
|
|
|
2176
2177
|
tokens: z8.array(z8.string()),
|
|
2177
2178
|
token_logprobs: z8.array(z8.number()),
|
|
2178
2179
|
top_logprobs: z8.array(z8.record(z8.string(), z8.number())).nullable()
|
|
2179
|
-
}).nullable().optional()
|
|
2180
|
-
})
|
|
2180
|
+
}).passthrough().nullable().optional()
|
|
2181
|
+
}).passthrough()
|
|
2181
2182
|
),
|
|
2182
2183
|
usage: z8.object({
|
|
2183
2184
|
prompt_tokens: z8.number(),
|
|
2184
2185
|
prompt_tokens_details: z8.object({
|
|
2185
2186
|
cached_tokens: z8.number()
|
|
2186
|
-
}).nullish(),
|
|
2187
|
+
}).passthrough().nullish(),
|
|
2187
2188
|
completion_tokens: z8.number(),
|
|
2188
2189
|
completion_tokens_details: z8.object({
|
|
2189
2190
|
reasoning_tokens: z8.number()
|
|
2190
|
-
}).nullish(),
|
|
2191
|
+
}).passthrough().nullish(),
|
|
2191
2192
|
total_tokens: z8.number(),
|
|
2192
2193
|
cost: z8.number().optional()
|
|
2193
|
-
}).nullish()
|
|
2194
|
-
}),
|
|
2194
|
+
}).passthrough().nullish()
|
|
2195
|
+
}).passthrough(),
|
|
2195
2196
|
OpenRouterErrorResponseSchema
|
|
2196
2197
|
]);
|
|
2197
2198
|
|
|
@@ -2287,8 +2288,9 @@ var OpenRouterCompletionLanguageModel = class {
|
|
|
2287
2288
|
fetch: this.config.fetch
|
|
2288
2289
|
});
|
|
2289
2290
|
if ("error" in response) {
|
|
2291
|
+
const errorData = response.error;
|
|
2290
2292
|
throw new APICallError({
|
|
2291
|
-
message:
|
|
2293
|
+
message: errorData.message,
|
|
2292
2294
|
url: this.config.url({
|
|
2293
2295
|
path: "/completions",
|
|
2294
2296
|
modelId: this.modelId
|
|
@@ -2296,7 +2298,7 @@ var OpenRouterCompletionLanguageModel = class {
|
|
|
2296
2298
|
requestBodyValues: args,
|
|
2297
2299
|
statusCode: 200,
|
|
2298
2300
|
responseHeaders,
|
|
2299
|
-
data:
|
|
2301
|
+
data: errorData
|
|
2300
2302
|
});
|
|
2301
2303
|
}
|
|
2302
2304
|
const choice = response.choices[0];
|