@openrouter/ai-sdk-provider 2.8.0 → 2.9.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/dist/index.d.mts +19 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +25 -24
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +25 -24
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +19 -0
- package/dist/internal/index.d.ts +19 -0
- package/dist/internal/index.js +24 -23
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +24 -23
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -3020,9 +3020,9 @@ function convertToOpenRouterChatMessages(prompt) {
|
|
|
3020
3020
|
const parsedProviderOptions = OpenRouterProviderOptionsSchema.safeParse(providerOptions);
|
|
3021
3021
|
const messageReasoningDetails = parsedProviderOptions.success ? (_e = (_d = parsedProviderOptions.data) == null ? void 0 : _d.openrouter) == null ? void 0 : _e.reasoning_details : void 0;
|
|
3022
3022
|
const messageAnnotations = parsedProviderOptions.success ? (_g = (_f = parsedProviderOptions.data) == null ? void 0 : _f.openrouter) == null ? void 0 : _g.annotations : void 0;
|
|
3023
|
-
const candidateReasoningDetails = messageReasoningDetails && Array.isArray(messageReasoningDetails)
|
|
3023
|
+
const candidateReasoningDetails = messageReasoningDetails && Array.isArray(messageReasoningDetails) ? messageReasoningDetails : findFirstReasoningDetails(content);
|
|
3024
3024
|
let finalReasoningDetails;
|
|
3025
|
-
if (candidateReasoningDetails
|
|
3025
|
+
if (candidateReasoningDetails) {
|
|
3026
3026
|
const validDetails = candidateReasoningDetails.filter((detail) => {
|
|
3027
3027
|
var _a17;
|
|
3028
3028
|
if (detail.type !== "reasoning.text" /* Text */) {
|
|
@@ -3048,9 +3048,9 @@ function convertToOpenRouterChatMessages(prompt) {
|
|
|
3048
3048
|
uniqueDetails.push(detail);
|
|
3049
3049
|
}
|
|
3050
3050
|
}
|
|
3051
|
-
finalReasoningDetails = uniqueDetails
|
|
3051
|
+
finalReasoningDetails = uniqueDetails;
|
|
3052
3052
|
}
|
|
3053
|
-
const effectiveReasoning = reasoning && finalReasoningDetails ? reasoning : void 0;
|
|
3053
|
+
const effectiveReasoning = reasoning && finalReasoningDetails && finalReasoningDetails.length > 0 ? reasoning : void 0;
|
|
3054
3054
|
messages.push({
|
|
3055
3055
|
role: "assistant",
|
|
3056
3056
|
content: text,
|
|
@@ -3494,7 +3494,7 @@ var OpenRouterChatLanguageModel = class {
|
|
|
3494
3494
|
this.supportedUrls = {
|
|
3495
3495
|
"image/*": [
|
|
3496
3496
|
/^data:image\/[a-zA-Z]+;base64,/,
|
|
3497
|
-
/^https?:\/\/.+\.(jpg|jpeg|png|gif|webp)
|
|
3497
|
+
/^https?:\/\/.+\.(jpg|jpeg|png|gif|webp)(?:[?#].*)?$/i
|
|
3498
3498
|
],
|
|
3499
3499
|
// 'text/*': [/^data:text\//, /^https?:\/\/.+$/],
|
|
3500
3500
|
"application/*": [/^data:application\//, /^https?:\/\/.+$/]
|
|
@@ -3517,7 +3517,7 @@ var OpenRouterChatLanguageModel = class {
|
|
|
3517
3517
|
tools,
|
|
3518
3518
|
toolChoice
|
|
3519
3519
|
}) {
|
|
3520
|
-
var _a16, _b16;
|
|
3520
|
+
var _a16, _b16, _c, _d;
|
|
3521
3521
|
const baseArgs = __spreadValues(__spreadValues({
|
|
3522
3522
|
// model id:
|
|
3523
3523
|
model: this.modelId,
|
|
@@ -3540,8 +3540,8 @@ var OpenRouterChatLanguageModel = class {
|
|
|
3540
3540
|
type: "json_schema",
|
|
3541
3541
|
json_schema: __spreadValues({
|
|
3542
3542
|
schema: responseFormat.schema,
|
|
3543
|
-
strict: true,
|
|
3544
|
-
name: (
|
|
3543
|
+
strict: (_b16 = (_a16 = this.settings.structuredOutputs) == null ? void 0 : _a16.strict) != null ? _b16 : true,
|
|
3544
|
+
name: (_c = responseFormat.name) != null ? _c : "response"
|
|
3545
3545
|
}, responseFormat.description && {
|
|
3546
3546
|
description: responseFormat.description
|
|
3547
3547
|
})
|
|
@@ -3567,7 +3567,7 @@ var OpenRouterChatLanguageModel = class {
|
|
|
3567
3567
|
const mappedTools = [];
|
|
3568
3568
|
for (const tool2 of tools) {
|
|
3569
3569
|
if (tool2.type === "function") {
|
|
3570
|
-
const openrouterOptions = (
|
|
3570
|
+
const openrouterOptions = (_d = tool2.providerOptions) == null ? void 0 : _d.openrouter;
|
|
3571
3571
|
const eagerInputStreaming = openrouterOptions == null ? void 0 : openrouterOptions.eager_input_streaming;
|
|
3572
3572
|
mappedTools.push(__spreadValues({
|
|
3573
3573
|
type: "function",
|
|
@@ -3977,15 +3977,17 @@ var OpenRouterChatLanguageModel = class {
|
|
|
3977
3977
|
controller.enqueue({
|
|
3978
3978
|
type: "reasoning-end",
|
|
3979
3979
|
id: reasoningId || generateId(),
|
|
3980
|
-
//
|
|
3981
|
-
// the reasoning part's providerMetadata with the correct
|
|
3982
|
-
// The signature typically arrives in the last
|
|
3980
|
+
// Always include accumulated reasoning_details so the AI SDK can
|
|
3981
|
+
// update the reasoning part's providerMetadata with the correct
|
|
3982
|
+
// signature. The signature typically arrives in the last delta,
|
|
3983
3983
|
// but reasoning-start only carries the first delta's metadata.
|
|
3984
|
-
|
|
3984
|
+
// An empty array is intentional — it signals the provider produced
|
|
3985
|
+
// no reasoning tokens this turn (e.g. DeepSeek V4).
|
|
3986
|
+
providerMetadata: {
|
|
3985
3987
|
openrouter: {
|
|
3986
3988
|
reasoning_details: accumulatedReasoningDetails
|
|
3987
3989
|
}
|
|
3988
|
-
}
|
|
3990
|
+
}
|
|
3989
3991
|
});
|
|
3990
3992
|
reasoningStarted = false;
|
|
3991
3993
|
}
|
|
@@ -4134,7 +4136,7 @@ var OpenRouterChatLanguageModel = class {
|
|
|
4134
4136
|
id: toolCall.id,
|
|
4135
4137
|
delta: (_s = toolCallDelta.function.arguments) != null ? _s : ""
|
|
4136
4138
|
});
|
|
4137
|
-
if (((_t = toolCall.function) == null ? void 0 : _t.name) != null && ((_u = toolCall.function) == null ? void 0 : _u.arguments) != null && isParsableJson(toolCall.function.arguments)) {
|
|
4139
|
+
if (!toolCall.sent && ((_t = toolCall.function) == null ? void 0 : _t.name) != null && ((_u = toolCall.function) == null ? void 0 : _u.arguments) != null && isParsableJson(toolCall.function.arguments)) {
|
|
4138
4140
|
controller.enqueue({
|
|
4139
4141
|
type: "tool-input-end",
|
|
4140
4142
|
id: toolCall.id
|
|
@@ -4220,13 +4222,14 @@ var OpenRouterChatLanguageModel = class {
|
|
|
4220
4222
|
controller.enqueue({
|
|
4221
4223
|
type: "reasoning-end",
|
|
4222
4224
|
id: reasoningId || generateId(),
|
|
4223
|
-
//
|
|
4224
|
-
// the reasoning part's providerMetadata
|
|
4225
|
-
|
|
4225
|
+
// Always include accumulated reasoning_details so the AI SDK can
|
|
4226
|
+
// update the reasoning part's providerMetadata. An empty array is
|
|
4227
|
+
// intentional — it signals the provider produced no reasoning tokens.
|
|
4228
|
+
providerMetadata: {
|
|
4226
4229
|
openrouter: {
|
|
4227
4230
|
reasoning_details: accumulatedReasoningDetails
|
|
4228
4231
|
}
|
|
4229
|
-
}
|
|
4232
|
+
}
|
|
4230
4233
|
});
|
|
4231
4234
|
}
|
|
4232
4235
|
if (textStarted) {
|
|
@@ -4241,9 +4244,7 @@ var OpenRouterChatLanguageModel = class {
|
|
|
4241
4244
|
if (provider !== void 0) {
|
|
4242
4245
|
openrouterMetadata.provider = provider;
|
|
4243
4246
|
}
|
|
4244
|
-
|
|
4245
|
-
openrouterMetadata.reasoning_details = accumulatedReasoningDetails;
|
|
4246
|
-
}
|
|
4247
|
+
openrouterMetadata.reasoning_details = accumulatedReasoningDetails;
|
|
4247
4248
|
if (accumulatedFileAnnotations.length > 0) {
|
|
4248
4249
|
openrouterMetadata.annotations = accumulatedFileAnnotations;
|
|
4249
4250
|
}
|
|
@@ -4441,7 +4442,7 @@ var OpenRouterCompletionLanguageModel = class {
|
|
|
4441
4442
|
this.supportedUrls = {
|
|
4442
4443
|
"image/*": [
|
|
4443
4444
|
/^data:image\/[a-zA-Z]+;base64,/,
|
|
4444
|
-
/^https?:\/\/.+\.(jpg|jpeg|png|gif|webp)
|
|
4445
|
+
/^https?:\/\/.+\.(jpg|jpeg|png|gif|webp)(?:[?#].*)?$/i
|
|
4445
4446
|
],
|
|
4446
4447
|
"text/*": [/^data:text\//, /^https?:\/\/.+$/],
|
|
4447
4448
|
"application/*": [/^data:application\//, /^https?:\/\/.+$/]
|
|
@@ -5067,7 +5068,7 @@ function withUserAgentSuffix2(headers, ...userAgentSuffixParts) {
|
|
|
5067
5068
|
}
|
|
5068
5069
|
|
|
5069
5070
|
// src/version.ts
|
|
5070
|
-
var VERSION2 = false ? "0.0.0-test" : "2.
|
|
5071
|
+
var VERSION2 = false ? "0.0.0-test" : "2.9.0";
|
|
5071
5072
|
|
|
5072
5073
|
// src/video/schemas.ts
|
|
5073
5074
|
import { z as z12 } from "zod/v4";
|