@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
|
@@ -537,6 +537,40 @@ type OpenRouterSharedSettings = OpenRouterProviderOptions & {
|
|
|
537
537
|
*/
|
|
538
538
|
include: boolean;
|
|
539
539
|
};
|
|
540
|
+
/**
|
|
541
|
+
* Default temperature for model calls. Controls randomness in the output.
|
|
542
|
+
* Can be overridden at call time via generateText/streamText options.
|
|
543
|
+
* Range: 0 to 2, where 0 is deterministic and higher values are more random.
|
|
544
|
+
*/
|
|
545
|
+
temperature?: number;
|
|
546
|
+
/**
|
|
547
|
+
* Default top-p (nucleus sampling) for model calls.
|
|
548
|
+
* Can be overridden at call time via generateText/streamText options.
|
|
549
|
+
* Range: 0 to 1.
|
|
550
|
+
*/
|
|
551
|
+
topP?: number;
|
|
552
|
+
/**
|
|
553
|
+
* Default top-k sampling for model calls.
|
|
554
|
+
* Can be overridden at call time via generateText/streamText options.
|
|
555
|
+
*/
|
|
556
|
+
topK?: number;
|
|
557
|
+
/**
|
|
558
|
+
* Default frequency penalty for model calls.
|
|
559
|
+
* Can be overridden at call time via generateText/streamText options.
|
|
560
|
+
* Range: -2 to 2.
|
|
561
|
+
*/
|
|
562
|
+
frequencyPenalty?: number;
|
|
563
|
+
/**
|
|
564
|
+
* Default presence penalty for model calls.
|
|
565
|
+
* Can be overridden at call time via generateText/streamText options.
|
|
566
|
+
* Range: -2 to 2.
|
|
567
|
+
*/
|
|
568
|
+
presencePenalty?: number;
|
|
569
|
+
/**
|
|
570
|
+
* Default maximum number of tokens to generate.
|
|
571
|
+
* Can be overridden at call time via generateText/streamText options.
|
|
572
|
+
*/
|
|
573
|
+
maxTokens?: number;
|
|
540
574
|
};
|
|
541
575
|
/**
|
|
542
576
|
* Usage accounting response
|
package/dist/internal/index.d.ts
CHANGED
|
@@ -537,6 +537,40 @@ type OpenRouterSharedSettings = OpenRouterProviderOptions & {
|
|
|
537
537
|
*/
|
|
538
538
|
include: boolean;
|
|
539
539
|
};
|
|
540
|
+
/**
|
|
541
|
+
* Default temperature for model calls. Controls randomness in the output.
|
|
542
|
+
* Can be overridden at call time via generateText/streamText options.
|
|
543
|
+
* Range: 0 to 2, where 0 is deterministic and higher values are more random.
|
|
544
|
+
*/
|
|
545
|
+
temperature?: number;
|
|
546
|
+
/**
|
|
547
|
+
* Default top-p (nucleus sampling) for model calls.
|
|
548
|
+
* Can be overridden at call time via generateText/streamText options.
|
|
549
|
+
* Range: 0 to 1.
|
|
550
|
+
*/
|
|
551
|
+
topP?: number;
|
|
552
|
+
/**
|
|
553
|
+
* Default top-k sampling for model calls.
|
|
554
|
+
* Can be overridden at call time via generateText/streamText options.
|
|
555
|
+
*/
|
|
556
|
+
topK?: number;
|
|
557
|
+
/**
|
|
558
|
+
* Default frequency penalty for model calls.
|
|
559
|
+
* Can be overridden at call time via generateText/streamText options.
|
|
560
|
+
* Range: -2 to 2.
|
|
561
|
+
*/
|
|
562
|
+
frequencyPenalty?: number;
|
|
563
|
+
/**
|
|
564
|
+
* Default presence penalty for model calls.
|
|
565
|
+
* Can be overridden at call time via generateText/streamText options.
|
|
566
|
+
* Range: -2 to 2.
|
|
567
|
+
*/
|
|
568
|
+
presencePenalty?: number;
|
|
569
|
+
/**
|
|
570
|
+
* Default maximum number of tokens to generate.
|
|
571
|
+
* Can be overridden at call time via generateText/streamText options.
|
|
572
|
+
*/
|
|
573
|
+
maxTokens?: number;
|
|
540
574
|
};
|
|
541
575
|
/**
|
|
542
576
|
* Usage accounting response
|
package/dist/internal/index.js
CHANGED
|
@@ -3311,7 +3311,7 @@ var OpenRouterChatLanguageModel = class {
|
|
|
3311
3311
|
tools,
|
|
3312
3312
|
toolChoice
|
|
3313
3313
|
}) {
|
|
3314
|
-
var _a16;
|
|
3314
|
+
var _a16, _b16;
|
|
3315
3315
|
const baseArgs = __spreadValues(__spreadValues({
|
|
3316
3316
|
// model id:
|
|
3317
3317
|
model: this.modelId,
|
|
@@ -3322,12 +3322,12 @@ var OpenRouterChatLanguageModel = class {
|
|
|
3322
3322
|
top_logprobs: typeof this.settings.logprobs === "number" ? this.settings.logprobs : typeof this.settings.logprobs === "boolean" ? this.settings.logprobs ? 0 : void 0 : void 0,
|
|
3323
3323
|
user: this.settings.user,
|
|
3324
3324
|
parallel_tool_calls: this.settings.parallelToolCalls,
|
|
3325
|
-
// standardized settings:
|
|
3326
|
-
max_tokens: maxOutputTokens,
|
|
3327
|
-
temperature,
|
|
3328
|
-
top_p: topP,
|
|
3329
|
-
frequency_penalty: frequencyPenalty,
|
|
3330
|
-
presence_penalty: presencePenalty,
|
|
3325
|
+
// standardized settings (call-level options override model-level settings):
|
|
3326
|
+
max_tokens: maxOutputTokens != null ? maxOutputTokens : this.settings.maxTokens,
|
|
3327
|
+
temperature: temperature != null ? temperature : this.settings.temperature,
|
|
3328
|
+
top_p: topP != null ? topP : this.settings.topP,
|
|
3329
|
+
frequency_penalty: frequencyPenalty != null ? frequencyPenalty : this.settings.frequencyPenalty,
|
|
3330
|
+
presence_penalty: presencePenalty != null ? presencePenalty : this.settings.presencePenalty,
|
|
3331
3331
|
seed,
|
|
3332
3332
|
stop: stopSequences,
|
|
3333
3333
|
response_format: (responseFormat == null ? void 0 : responseFormat.type) === "json" ? responseFormat.schema != null ? {
|
|
@@ -3340,7 +3340,7 @@ var OpenRouterChatLanguageModel = class {
|
|
|
3340
3340
|
description: responseFormat.description
|
|
3341
3341
|
})
|
|
3342
3342
|
} : { type: "json_object" } : void 0,
|
|
3343
|
-
top_k: topK,
|
|
3343
|
+
top_k: topK != null ? topK : this.settings.topK,
|
|
3344
3344
|
// messages:
|
|
3345
3345
|
messages: convertToOpenRouterChatMessages(prompt),
|
|
3346
3346
|
// OpenRouter specific settings:
|
|
@@ -3361,14 +3361,18 @@ var OpenRouterChatLanguageModel = class {
|
|
|
3361
3361
|
const mappedTools = [];
|
|
3362
3362
|
for (const tool of tools) {
|
|
3363
3363
|
if (tool.type === "function") {
|
|
3364
|
-
|
|
3364
|
+
const openrouterOptions = (_b16 = tool.providerOptions) == null ? void 0 : _b16.openrouter;
|
|
3365
|
+
const eagerInputStreaming = openrouterOptions == null ? void 0 : openrouterOptions.eager_input_streaming;
|
|
3366
|
+
mappedTools.push(__spreadValues({
|
|
3365
3367
|
type: "function",
|
|
3366
3368
|
function: {
|
|
3367
3369
|
name: tool.name,
|
|
3368
3370
|
description: tool.description,
|
|
3369
3371
|
parameters: tool.inputSchema
|
|
3370
3372
|
}
|
|
3371
|
-
}
|
|
3373
|
+
}, eagerInputStreaming != null && {
|
|
3374
|
+
eager_input_streaming: eagerInputStreaming
|
|
3375
|
+
}));
|
|
3372
3376
|
} else if (tool.type === "provider") {
|
|
3373
3377
|
mappedTools.push(mapProviderTool(tool));
|
|
3374
3378
|
}
|
|
@@ -3706,18 +3710,16 @@ var OpenRouterChatLanguageModel = class {
|
|
|
3706
3710
|
return;
|
|
3707
3711
|
}
|
|
3708
3712
|
const delta = choice.delta;
|
|
3709
|
-
const emitReasoningChunk = (chunkText
|
|
3713
|
+
const emitReasoningChunk = (chunkText) => {
|
|
3710
3714
|
if (!reasoningStarted) {
|
|
3711
3715
|
reasoningId = generateId();
|
|
3712
3716
|
controller.enqueue({
|
|
3713
|
-
providerMetadata,
|
|
3714
3717
|
type: "reasoning-start",
|
|
3715
3718
|
id: reasoningId
|
|
3716
3719
|
});
|
|
3717
3720
|
reasoningStarted = true;
|
|
3718
3721
|
}
|
|
3719
3722
|
controller.enqueue({
|
|
3720
|
-
providerMetadata,
|
|
3721
3723
|
type: "reasoning-delta",
|
|
3722
3724
|
delta: chunkText,
|
|
3723
3725
|
id: reasoningId || generateId()
|
|
@@ -3739,15 +3741,10 @@ var OpenRouterChatLanguageModel = class {
|
|
|
3739
3741
|
}
|
|
3740
3742
|
}
|
|
3741
3743
|
if (!textStarted) {
|
|
3742
|
-
const reasoningMetadata = {
|
|
3743
|
-
openrouter: {
|
|
3744
|
-
reasoning_details: accumulatedReasoningDetails.map((d) => __spreadValues({}, d))
|
|
3745
|
-
}
|
|
3746
|
-
};
|
|
3747
3744
|
for (const detail of delta.reasoning_details) {
|
|
3748
3745
|
switch (detail.type) {
|
|
3749
3746
|
case "reasoning.text" /* Text */: {
|
|
3750
|
-
emitReasoningChunk(detail.text || ""
|
|
3747
|
+
emitReasoningChunk(detail.text || "");
|
|
3751
3748
|
break;
|
|
3752
3749
|
}
|
|
3753
3750
|
case "reasoning.encrypted" /* Encrypted */: {
|
|
@@ -3755,7 +3752,7 @@ var OpenRouterChatLanguageModel = class {
|
|
|
3755
3752
|
}
|
|
3756
3753
|
case "reasoning.summary" /* Summary */: {
|
|
3757
3754
|
if (detail.summary) {
|
|
3758
|
-
emitReasoningChunk(detail.summary
|
|
3755
|
+
emitReasoningChunk(detail.summary);
|
|
3759
3756
|
}
|
|
3760
3757
|
break;
|
|
3761
3758
|
}
|
|
@@ -4044,6 +4041,12 @@ var OpenRouterChatLanguageModel = class {
|
|
|
4044
4041
|
if (accumulatedFileAnnotations.length > 0) {
|
|
4045
4042
|
openrouterMetadata.annotations = accumulatedFileAnnotations;
|
|
4046
4043
|
}
|
|
4044
|
+
if (usage.inputTokens.total === void 0 && openrouterUsage.promptTokens !== void 0) {
|
|
4045
|
+
usage.inputTokens.total = openrouterUsage.promptTokens;
|
|
4046
|
+
}
|
|
4047
|
+
if (usage.outputTokens.total === void 0 && openrouterUsage.completionTokens !== void 0) {
|
|
4048
|
+
usage.outputTokens.total = openrouterUsage.completionTokens;
|
|
4049
|
+
}
|
|
4047
4050
|
usage.raw = rawUsage;
|
|
4048
4051
|
controller.enqueue({
|
|
4049
4052
|
type: "finish",
|
|
@@ -4279,16 +4282,16 @@ var OpenRouterCompletionLanguageModel = class {
|
|
|
4279
4282
|
logprobs: typeof this.settings.logprobs === "number" ? this.settings.logprobs : typeof this.settings.logprobs === "boolean" ? this.settings.logprobs ? 0 : void 0 : void 0,
|
|
4280
4283
|
suffix: this.settings.suffix,
|
|
4281
4284
|
user: this.settings.user,
|
|
4282
|
-
// standardized settings:
|
|
4283
|
-
max_tokens: maxOutputTokens,
|
|
4284
|
-
temperature,
|
|
4285
|
-
top_p: topP,
|
|
4286
|
-
frequency_penalty: frequencyPenalty,
|
|
4287
|
-
presence_penalty: presencePenalty,
|
|
4285
|
+
// standardized settings (call-level options override model-level settings):
|
|
4286
|
+
max_tokens: maxOutputTokens != null ? maxOutputTokens : this.settings.maxTokens,
|
|
4287
|
+
temperature: temperature != null ? temperature : this.settings.temperature,
|
|
4288
|
+
top_p: topP != null ? topP : this.settings.topP,
|
|
4289
|
+
frequency_penalty: frequencyPenalty != null ? frequencyPenalty : this.settings.frequencyPenalty,
|
|
4290
|
+
presence_penalty: presencePenalty != null ? presencePenalty : this.settings.presencePenalty,
|
|
4288
4291
|
seed,
|
|
4289
4292
|
stop: stopSequences,
|
|
4290
4293
|
response_format: responseFormat,
|
|
4291
|
-
top_k: topK,
|
|
4294
|
+
top_k: topK != null ? topK : this.settings.topK,
|
|
4292
4295
|
// prompt:
|
|
4293
4296
|
prompt: completionPrompt,
|
|
4294
4297
|
// OpenRouter specific settings:
|