@openrouter/ai-sdk-provider 2.6.0 → 2.7.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 +34 -0
- package/dist/index.d.ts +34 -0
- package/dist/index.js +31 -28
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +31 -28
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +34 -0
- package/dist/internal/index.d.ts +34 -0
- package/dist/internal/index.js +30 -27
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +30 -27
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -3352,7 +3352,7 @@ var OpenRouterChatLanguageModel = class {
|
|
|
3352
3352
|
tools,
|
|
3353
3353
|
toolChoice
|
|
3354
3354
|
}) {
|
|
3355
|
-
var _a16;
|
|
3355
|
+
var _a16, _b16;
|
|
3356
3356
|
const baseArgs = __spreadValues(__spreadValues({
|
|
3357
3357
|
// model id:
|
|
3358
3358
|
model: this.modelId,
|
|
@@ -3363,12 +3363,12 @@ var OpenRouterChatLanguageModel = class {
|
|
|
3363
3363
|
top_logprobs: typeof this.settings.logprobs === "number" ? this.settings.logprobs : typeof this.settings.logprobs === "boolean" ? this.settings.logprobs ? 0 : void 0 : void 0,
|
|
3364
3364
|
user: this.settings.user,
|
|
3365
3365
|
parallel_tool_calls: this.settings.parallelToolCalls,
|
|
3366
|
-
// standardized settings:
|
|
3367
|
-
max_tokens: maxOutputTokens,
|
|
3368
|
-
temperature,
|
|
3369
|
-
top_p: topP,
|
|
3370
|
-
frequency_penalty: frequencyPenalty,
|
|
3371
|
-
presence_penalty: presencePenalty,
|
|
3366
|
+
// standardized settings (call-level options override model-level settings):
|
|
3367
|
+
max_tokens: maxOutputTokens != null ? maxOutputTokens : this.settings.maxTokens,
|
|
3368
|
+
temperature: temperature != null ? temperature : this.settings.temperature,
|
|
3369
|
+
top_p: topP != null ? topP : this.settings.topP,
|
|
3370
|
+
frequency_penalty: frequencyPenalty != null ? frequencyPenalty : this.settings.frequencyPenalty,
|
|
3371
|
+
presence_penalty: presencePenalty != null ? presencePenalty : this.settings.presencePenalty,
|
|
3372
3372
|
seed,
|
|
3373
3373
|
stop: stopSequences,
|
|
3374
3374
|
response_format: (responseFormat == null ? void 0 : responseFormat.type) === "json" ? responseFormat.schema != null ? {
|
|
@@ -3381,7 +3381,7 @@ var OpenRouterChatLanguageModel = class {
|
|
|
3381
3381
|
description: responseFormat.description
|
|
3382
3382
|
})
|
|
3383
3383
|
} : { type: "json_object" } : void 0,
|
|
3384
|
-
top_k: topK,
|
|
3384
|
+
top_k: topK != null ? topK : this.settings.topK,
|
|
3385
3385
|
// messages:
|
|
3386
3386
|
messages: convertToOpenRouterChatMessages(prompt),
|
|
3387
3387
|
// OpenRouter specific settings:
|
|
@@ -3402,14 +3402,18 @@ var OpenRouterChatLanguageModel = class {
|
|
|
3402
3402
|
const mappedTools = [];
|
|
3403
3403
|
for (const tool2 of tools) {
|
|
3404
3404
|
if (tool2.type === "function") {
|
|
3405
|
-
|
|
3405
|
+
const openrouterOptions = (_b16 = tool2.providerOptions) == null ? void 0 : _b16.openrouter;
|
|
3406
|
+
const eagerInputStreaming = openrouterOptions == null ? void 0 : openrouterOptions.eager_input_streaming;
|
|
3407
|
+
mappedTools.push(__spreadValues({
|
|
3406
3408
|
type: "function",
|
|
3407
3409
|
function: {
|
|
3408
3410
|
name: tool2.name,
|
|
3409
3411
|
description: tool2.description,
|
|
3410
3412
|
parameters: tool2.inputSchema
|
|
3411
3413
|
}
|
|
3412
|
-
}
|
|
3414
|
+
}, eagerInputStreaming != null && {
|
|
3415
|
+
eager_input_streaming: eagerInputStreaming
|
|
3416
|
+
}));
|
|
3413
3417
|
} else if (tool2.type === "provider") {
|
|
3414
3418
|
mappedTools.push(mapProviderTool(tool2));
|
|
3415
3419
|
}
|
|
@@ -3747,18 +3751,16 @@ var OpenRouterChatLanguageModel = class {
|
|
|
3747
3751
|
return;
|
|
3748
3752
|
}
|
|
3749
3753
|
const delta = choice.delta;
|
|
3750
|
-
const emitReasoningChunk = (chunkText
|
|
3754
|
+
const emitReasoningChunk = (chunkText) => {
|
|
3751
3755
|
if (!reasoningStarted) {
|
|
3752
3756
|
reasoningId = generateId();
|
|
3753
3757
|
controller.enqueue({
|
|
3754
|
-
providerMetadata,
|
|
3755
3758
|
type: "reasoning-start",
|
|
3756
3759
|
id: reasoningId
|
|
3757
3760
|
});
|
|
3758
3761
|
reasoningStarted = true;
|
|
3759
3762
|
}
|
|
3760
3763
|
controller.enqueue({
|
|
3761
|
-
providerMetadata,
|
|
3762
3764
|
type: "reasoning-delta",
|
|
3763
3765
|
delta: chunkText,
|
|
3764
3766
|
id: reasoningId || generateId()
|
|
@@ -3780,15 +3782,10 @@ var OpenRouterChatLanguageModel = class {
|
|
|
3780
3782
|
}
|
|
3781
3783
|
}
|
|
3782
3784
|
if (!textStarted) {
|
|
3783
|
-
const reasoningMetadata = {
|
|
3784
|
-
openrouter: {
|
|
3785
|
-
reasoning_details: accumulatedReasoningDetails.map((d) => __spreadValues({}, d))
|
|
3786
|
-
}
|
|
3787
|
-
};
|
|
3788
3785
|
for (const detail of delta.reasoning_details) {
|
|
3789
3786
|
switch (detail.type) {
|
|
3790
3787
|
case "reasoning.text" /* Text */: {
|
|
3791
|
-
emitReasoningChunk(detail.text || ""
|
|
3788
|
+
emitReasoningChunk(detail.text || "");
|
|
3792
3789
|
break;
|
|
3793
3790
|
}
|
|
3794
3791
|
case "reasoning.encrypted" /* Encrypted */: {
|
|
@@ -3796,7 +3793,7 @@ var OpenRouterChatLanguageModel = class {
|
|
|
3796
3793
|
}
|
|
3797
3794
|
case "reasoning.summary" /* Summary */: {
|
|
3798
3795
|
if (detail.summary) {
|
|
3799
|
-
emitReasoningChunk(detail.summary
|
|
3796
|
+
emitReasoningChunk(detail.summary);
|
|
3800
3797
|
}
|
|
3801
3798
|
break;
|
|
3802
3799
|
}
|
|
@@ -4085,6 +4082,12 @@ var OpenRouterChatLanguageModel = class {
|
|
|
4085
4082
|
if (accumulatedFileAnnotations.length > 0) {
|
|
4086
4083
|
openrouterMetadata.annotations = accumulatedFileAnnotations;
|
|
4087
4084
|
}
|
|
4085
|
+
if (usage.inputTokens.total === void 0 && openrouterUsage.promptTokens !== void 0) {
|
|
4086
|
+
usage.inputTokens.total = openrouterUsage.promptTokens;
|
|
4087
|
+
}
|
|
4088
|
+
if (usage.outputTokens.total === void 0 && openrouterUsage.completionTokens !== void 0) {
|
|
4089
|
+
usage.outputTokens.total = openrouterUsage.completionTokens;
|
|
4090
|
+
}
|
|
4088
4091
|
usage.raw = rawUsage;
|
|
4089
4092
|
controller.enqueue({
|
|
4090
4093
|
type: "finish",
|
|
@@ -4320,16 +4323,16 @@ var OpenRouterCompletionLanguageModel = class {
|
|
|
4320
4323
|
logprobs: typeof this.settings.logprobs === "number" ? this.settings.logprobs : typeof this.settings.logprobs === "boolean" ? this.settings.logprobs ? 0 : void 0 : void 0,
|
|
4321
4324
|
suffix: this.settings.suffix,
|
|
4322
4325
|
user: this.settings.user,
|
|
4323
|
-
// standardized settings:
|
|
4324
|
-
max_tokens: maxOutputTokens,
|
|
4325
|
-
temperature,
|
|
4326
|
-
top_p: topP,
|
|
4327
|
-
frequency_penalty: frequencyPenalty,
|
|
4328
|
-
presence_penalty: presencePenalty,
|
|
4326
|
+
// standardized settings (call-level options override model-level settings):
|
|
4327
|
+
max_tokens: maxOutputTokens != null ? maxOutputTokens : this.settings.maxTokens,
|
|
4328
|
+
temperature: temperature != null ? temperature : this.settings.temperature,
|
|
4329
|
+
top_p: topP != null ? topP : this.settings.topP,
|
|
4330
|
+
frequency_penalty: frequencyPenalty != null ? frequencyPenalty : this.settings.frequencyPenalty,
|
|
4331
|
+
presence_penalty: presencePenalty != null ? presencePenalty : this.settings.presencePenalty,
|
|
4329
4332
|
seed,
|
|
4330
4333
|
stop: stopSequences,
|
|
4331
4334
|
response_format: responseFormat,
|
|
4332
|
-
top_k: topK,
|
|
4335
|
+
top_k: topK != null ? topK : this.settings.topK,
|
|
4333
4336
|
// prompt:
|
|
4334
4337
|
prompt: completionPrompt,
|
|
4335
4338
|
// OpenRouter specific settings:
|
|
@@ -4899,7 +4902,7 @@ function withUserAgentSuffix2(headers, ...userAgentSuffixParts) {
|
|
|
4899
4902
|
}
|
|
4900
4903
|
|
|
4901
4904
|
// src/version.ts
|
|
4902
|
-
var VERSION2 = false ? "0.0.0-test" : "2.
|
|
4905
|
+
var VERSION2 = false ? "0.0.0-test" : "2.7.0";
|
|
4903
4906
|
|
|
4904
4907
|
// src/provider.ts
|
|
4905
4908
|
function createOpenRouter(options = {}) {
|