@openrouter/ai-sdk-provider 1.0.0-beta.6 → 1.0.0
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/README.md +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +37 -23
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +36 -22
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +1 -1
- package/dist/internal/index.d.ts +1 -1
- package/dist/internal/index.js +37 -23
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +36 -22
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +9 -10
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# OpenRouter Provider for Vercel AI SDK
|
|
2
2
|
|
|
3
|
-
The [OpenRouter](https://openrouter.ai/) provider for the [Vercel AI SDK](https://sdk.vercel.ai/docs) gives access to over 300 large language
|
|
3
|
+
The [OpenRouter](https://openrouter.ai/) provider for the [Vercel AI SDK](https://sdk.vercel.ai/docs) gives access to over 300 large language models on the OpenRouter chat and completion APIs.
|
|
4
4
|
|
|
5
5
|
## Setup
|
|
6
6
|
|
|
@@ -126,7 +126,7 @@ await streamText({
|
|
|
126
126
|
{
|
|
127
127
|
role: 'system',
|
|
128
128
|
content:
|
|
129
|
-
'You are a podcast summary assistant. You are detail
|
|
129
|
+
'You are a podcast summary assistant. You are detail-oriented and critical about the content.',
|
|
130
130
|
},
|
|
131
131
|
{
|
|
132
132
|
role: 'user',
|
package/dist/index.d.mts
CHANGED
|
@@ -21,7 +21,7 @@ type OpenRouterChatSettings = {
|
|
|
21
21
|
/**
|
|
22
22
|
Return the log probabilities of the tokens. Including logprobs will increase
|
|
23
23
|
the response size and can slow down response times. However, it can
|
|
24
|
-
be useful to better
|
|
24
|
+
be useful to understand better how the model is behaving.
|
|
25
25
|
|
|
26
26
|
Setting to true will return the log probabilities of the tokens that
|
|
27
27
|
were generated.
|
|
@@ -277,7 +277,7 @@ declare class OpenRouter {
|
|
|
277
277
|
*/
|
|
278
278
|
readonly baseURL: string;
|
|
279
279
|
/**
|
|
280
|
-
API key that is being
|
|
280
|
+
API key that is being sent using the `Authorization` header.
|
|
281
281
|
It defaults to the `OPENROUTER_API_KEY` environment variable.
|
|
282
282
|
*/
|
|
283
283
|
readonly apiKey?: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -21,7 +21,7 @@ type OpenRouterChatSettings = {
|
|
|
21
21
|
/**
|
|
22
22
|
Return the log probabilities of the tokens. Including logprobs will increase
|
|
23
23
|
the response size and can slow down response times. However, it can
|
|
24
|
-
be useful to better
|
|
24
|
+
be useful to understand better how the model is behaving.
|
|
25
25
|
|
|
26
26
|
Setting to true will return the log probabilities of the tokens that
|
|
27
27
|
were generated.
|
|
@@ -277,7 +277,7 @@ declare class OpenRouter {
|
|
|
277
277
|
*/
|
|
278
278
|
readonly baseURL: string;
|
|
279
279
|
/**
|
|
280
|
-
API key that is being
|
|
280
|
+
API key that is being sent using the `Authorization` header.
|
|
281
281
|
It defaults to the `OPENROUTER_API_KEY` environment variable.
|
|
282
282
|
*/
|
|
283
283
|
readonly apiKey?: string;
|
package/dist/index.js
CHANGED
|
@@ -53,7 +53,7 @@ __export(index_exports, {
|
|
|
53
53
|
});
|
|
54
54
|
module.exports = __toCommonJS(index_exports);
|
|
55
55
|
|
|
56
|
-
// node_modules/.pnpm/@ai-sdk+provider@2.0.0
|
|
56
|
+
// node_modules/.pnpm/@ai-sdk+provider@2.0.0/node_modules/@ai-sdk/provider/dist/index.mjs
|
|
57
57
|
var marker = "vercel.ai.error";
|
|
58
58
|
var symbol = Symbol.for(marker);
|
|
59
59
|
var _a;
|
|
@@ -447,28 +447,25 @@ var EventSourceParserStream = class extends TransformStream {
|
|
|
447
447
|
}
|
|
448
448
|
};
|
|
449
449
|
|
|
450
|
-
// node_modules/.pnpm/@ai-sdk+provider-utils@3.0.
|
|
450
|
+
// node_modules/.pnpm/@ai-sdk+provider-utils@3.0.1_zod@3.25.76/node_modules/@ai-sdk/provider-utils/dist/index.mjs
|
|
451
451
|
var z4 = __toESM(require("zod/v4"), 1);
|
|
452
452
|
|
|
453
|
-
// node_modules/.pnpm/zod-to-json-schema@3.24.
|
|
453
|
+
// node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/Options.js
|
|
454
454
|
var ignoreOverride = Symbol("Let zodToJsonSchema decide on which parser to use");
|
|
455
455
|
|
|
456
|
-
// node_modules/.pnpm/zod-to-json-schema@3.24.
|
|
457
|
-
var
|
|
456
|
+
// node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/selectParser.js
|
|
457
|
+
var import_zod3 = require("zod");
|
|
458
458
|
|
|
459
|
-
// node_modules/.pnpm/zod-to-json-schema@3.24.
|
|
459
|
+
// node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/array.js
|
|
460
460
|
var import_zod = require("zod");
|
|
461
461
|
|
|
462
|
-
// node_modules/.pnpm/zod-to-json-schema@3.24.
|
|
462
|
+
// node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/record.js
|
|
463
463
|
var import_zod2 = require("zod");
|
|
464
464
|
|
|
465
|
-
// node_modules/.pnpm/zod-to-json-schema@3.24.
|
|
465
|
+
// node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/string.js
|
|
466
466
|
var ALPHA_NUMERIC = new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");
|
|
467
467
|
|
|
468
|
-
// node_modules/.pnpm
|
|
469
|
-
var import_zod3 = require("zod");
|
|
470
|
-
|
|
471
|
-
// node_modules/.pnpm/@ai-sdk+provider-utils@3.0.0-beta.5_zod@3.25.76/node_modules/@ai-sdk/provider-utils/dist/index.mjs
|
|
468
|
+
// node_modules/.pnpm/@ai-sdk+provider-utils@3.0.1_zod@3.25.76/node_modules/@ai-sdk/provider-utils/dist/index.mjs
|
|
472
469
|
function combineHeaders(...headers) {
|
|
473
470
|
return headers.reduce(
|
|
474
471
|
(combinedHeaders, currentHeaders) => __spreadValues(__spreadValues({}, combinedHeaders), currentHeaders != null ? currentHeaders : {}),
|
|
@@ -505,7 +502,7 @@ var createIdGenerator = ({
|
|
|
505
502
|
};
|
|
506
503
|
var generateId = createIdGenerator();
|
|
507
504
|
function isAbortError(error) {
|
|
508
|
-
return error instanceof Error && (error.name === "AbortError" || error.name === "ResponseAborted" || // Next.js
|
|
505
|
+
return (error instanceof Error || error instanceof DOMException) && (error.name === "AbortError" || error.name === "ResponseAborted" || // Next.js
|
|
509
506
|
error.name === "TimeoutError");
|
|
510
507
|
}
|
|
511
508
|
var FETCH_FAILED_ERROR_MESSAGES = ["fetch failed", "failed to fetch"];
|
|
@@ -1355,6 +1352,7 @@ var OpenRouterChatLanguageModel = class {
|
|
|
1355
1352
|
tools,
|
|
1356
1353
|
toolChoice
|
|
1357
1354
|
}) {
|
|
1355
|
+
var _a15;
|
|
1358
1356
|
const baseArgs = __spreadValues(__spreadValues({
|
|
1359
1357
|
// model id:
|
|
1360
1358
|
model: this.modelId,
|
|
@@ -1382,9 +1380,18 @@ var OpenRouterChatLanguageModel = class {
|
|
|
1382
1380
|
reasoning: this.settings.reasoning,
|
|
1383
1381
|
usage: this.settings.usage
|
|
1384
1382
|
}, this.config.extraBody), this.settings.extraBody);
|
|
1385
|
-
if ((responseFormat == null ? void 0 : responseFormat.type) === "json") {
|
|
1383
|
+
if ((responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null) {
|
|
1386
1384
|
return __spreadProps(__spreadValues({}, baseArgs), {
|
|
1387
|
-
response_format: {
|
|
1385
|
+
response_format: {
|
|
1386
|
+
type: "json_schema",
|
|
1387
|
+
json_schema: __spreadValues({
|
|
1388
|
+
schema: responseFormat.schema,
|
|
1389
|
+
strict: true,
|
|
1390
|
+
name: (_a15 = responseFormat.name) != null ? _a15 : "response"
|
|
1391
|
+
}, responseFormat.description && {
|
|
1392
|
+
description: responseFormat.description
|
|
1393
|
+
})
|
|
1394
|
+
}
|
|
1388
1395
|
});
|
|
1389
1396
|
}
|
|
1390
1397
|
if (tools && tools.length > 0) {
|
|
@@ -1672,10 +1679,17 @@ var OpenRouterChatLanguageModel = class {
|
|
|
1672
1679
|
}
|
|
1673
1680
|
}
|
|
1674
1681
|
}
|
|
1675
|
-
} else if (delta.reasoning
|
|
1682
|
+
} else if (delta.reasoning) {
|
|
1676
1683
|
emitReasoningChunk(delta.reasoning);
|
|
1677
1684
|
}
|
|
1678
|
-
if (delta.content
|
|
1685
|
+
if (delta.content) {
|
|
1686
|
+
if (reasoningStarted && !textStarted) {
|
|
1687
|
+
controller.enqueue({
|
|
1688
|
+
type: "reasoning-end",
|
|
1689
|
+
id: reasoningId || generateId()
|
|
1690
|
+
});
|
|
1691
|
+
reasoningStarted = false;
|
|
1692
|
+
}
|
|
1679
1693
|
if (!textStarted) {
|
|
1680
1694
|
textId = openrouterResponseId || generateId();
|
|
1681
1695
|
controller.enqueue({
|
|
@@ -1800,18 +1814,18 @@ var OpenRouterChatLanguageModel = class {
|
|
|
1800
1814
|
}
|
|
1801
1815
|
}
|
|
1802
1816
|
}
|
|
1803
|
-
if (textStarted) {
|
|
1804
|
-
controller.enqueue({
|
|
1805
|
-
type: "text-end",
|
|
1806
|
-
id: textId || generateId()
|
|
1807
|
-
});
|
|
1808
|
-
}
|
|
1809
1817
|
if (reasoningStarted) {
|
|
1810
1818
|
controller.enqueue({
|
|
1811
1819
|
type: "reasoning-end",
|
|
1812
1820
|
id: reasoningId || generateId()
|
|
1813
1821
|
});
|
|
1814
1822
|
}
|
|
1823
|
+
if (textStarted) {
|
|
1824
|
+
controller.enqueue({
|
|
1825
|
+
type: "text-end",
|
|
1826
|
+
id: textId || generateId()
|
|
1827
|
+
});
|
|
1828
|
+
}
|
|
1815
1829
|
controller.enqueue({
|
|
1816
1830
|
type: "finish",
|
|
1817
1831
|
finishReason,
|