llmist 16.2.5 → 17.2.1
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.cjs +144 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +20 -2
- package/dist/index.d.ts +20 -2
- package/dist/index.js +144 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -9950,7 +9950,7 @@ var init_openai_compatible_provider = __esm({
|
|
|
9950
9950
|
inputTokens: chunk.usage.prompt_tokens,
|
|
9951
9951
|
outputTokens: chunk.usage.completion_tokens,
|
|
9952
9952
|
totalTokens: chunk.usage.total_tokens,
|
|
9953
|
-
cachedInputTokens: 0,
|
|
9953
|
+
cachedInputTokens: usageDetails?.prompt_tokens_details?.cached_tokens ?? 0,
|
|
9954
9954
|
reasoningTokens: usageDetails?.completion_tokens_details?.reasoning_tokens
|
|
9955
9955
|
} : void 0;
|
|
9956
9956
|
if (finishReason || usage) {
|
|
@@ -11509,6 +11509,103 @@ var init_openrouter_models = __esm({
|
|
|
11509
11509
|
}
|
|
11510
11510
|
},
|
|
11511
11511
|
// ============================================================
|
|
11512
|
+
// Google Gemini 3.1 Models (via OpenRouter)
|
|
11513
|
+
// ============================================================
|
|
11514
|
+
{
|
|
11515
|
+
provider: "openrouter",
|
|
11516
|
+
modelId: "google/gemini-3.1-pro-preview",
|
|
11517
|
+
displayName: "Gemini 3.1 Pro Preview (OpenRouter)",
|
|
11518
|
+
contextWindow: 1048576,
|
|
11519
|
+
maxOutputTokens: 65536,
|
|
11520
|
+
pricing: {
|
|
11521
|
+
input: 2,
|
|
11522
|
+
output: 12
|
|
11523
|
+
},
|
|
11524
|
+
knowledgeCutoff: "2025-01",
|
|
11525
|
+
features: {
|
|
11526
|
+
streaming: true,
|
|
11527
|
+
functionCalling: true,
|
|
11528
|
+
vision: true,
|
|
11529
|
+
reasoning: true,
|
|
11530
|
+
structuredOutputs: true
|
|
11531
|
+
},
|
|
11532
|
+
metadata: {
|
|
11533
|
+
family: "Gemini 3.1",
|
|
11534
|
+
releaseDate: "2026-03",
|
|
11535
|
+
notes: "Gemini 3.1 Pro Preview via OpenRouter. Frontier reasoning with enhanced software engineering performance."
|
|
11536
|
+
}
|
|
11537
|
+
},
|
|
11538
|
+
{
|
|
11539
|
+
provider: "openrouter",
|
|
11540
|
+
modelId: "google/gemini-3.1-pro-preview-customtools",
|
|
11541
|
+
displayName: "Gemini 3.1 Pro Preview Custom Tools (OpenRouter)",
|
|
11542
|
+
contextWindow: 1048576,
|
|
11543
|
+
maxOutputTokens: 65536,
|
|
11544
|
+
pricing: {
|
|
11545
|
+
input: 2,
|
|
11546
|
+
output: 12
|
|
11547
|
+
},
|
|
11548
|
+
knowledgeCutoff: "2025-01",
|
|
11549
|
+
features: {
|
|
11550
|
+
streaming: true,
|
|
11551
|
+
functionCalling: true,
|
|
11552
|
+
vision: true,
|
|
11553
|
+
reasoning: true,
|
|
11554
|
+
structuredOutputs: true
|
|
11555
|
+
},
|
|
11556
|
+
metadata: {
|
|
11557
|
+
family: "Gemini 3.1",
|
|
11558
|
+
releaseDate: "2026-03",
|
|
11559
|
+
notes: "Gemini 3.1 Pro Preview Custom Tools via OpenRouter. Improved tool selection to prevent overuse of general tools in agent workflows."
|
|
11560
|
+
}
|
|
11561
|
+
},
|
|
11562
|
+
{
|
|
11563
|
+
provider: "openrouter",
|
|
11564
|
+
modelId: "google/gemini-3.1-flash-lite-preview",
|
|
11565
|
+
displayName: "Gemini 3.1 Flash Lite Preview (OpenRouter)",
|
|
11566
|
+
contextWindow: 1048576,
|
|
11567
|
+
maxOutputTokens: 65536,
|
|
11568
|
+
pricing: {
|
|
11569
|
+
input: 0.25,
|
|
11570
|
+
output: 1.5
|
|
11571
|
+
},
|
|
11572
|
+
knowledgeCutoff: "2025-01",
|
|
11573
|
+
features: {
|
|
11574
|
+
streaming: true,
|
|
11575
|
+
functionCalling: true,
|
|
11576
|
+
vision: true,
|
|
11577
|
+
reasoning: true,
|
|
11578
|
+
structuredOutputs: true
|
|
11579
|
+
},
|
|
11580
|
+
metadata: {
|
|
11581
|
+
family: "Gemini 3.1",
|
|
11582
|
+
releaseDate: "2026-03",
|
|
11583
|
+
notes: "Gemini 3.1 Flash Lite Preview via OpenRouter. High-efficiency model with full thinking levels for cost/performance trade-offs."
|
|
11584
|
+
}
|
|
11585
|
+
},
|
|
11586
|
+
{
|
|
11587
|
+
provider: "openrouter",
|
|
11588
|
+
modelId: "google/gemini-3.1-flash-image-preview",
|
|
11589
|
+
displayName: "Gemini 3.1 Flash Image Preview (OpenRouter)",
|
|
11590
|
+
contextWindow: 65536,
|
|
11591
|
+
maxOutputTokens: 65536,
|
|
11592
|
+
pricing: {
|
|
11593
|
+
input: 0.5,
|
|
11594
|
+
output: 3
|
|
11595
|
+
},
|
|
11596
|
+
knowledgeCutoff: "2025-01",
|
|
11597
|
+
features: {
|
|
11598
|
+
streaming: true,
|
|
11599
|
+
functionCalling: false,
|
|
11600
|
+
vision: true
|
|
11601
|
+
},
|
|
11602
|
+
metadata: {
|
|
11603
|
+
family: "Gemini 3.1",
|
|
11604
|
+
releaseDate: "2026-03",
|
|
11605
|
+
notes: "Gemini 3.1 Flash Image Preview via OpenRouter. Pro-level image generation and editing at Flash speed."
|
|
11606
|
+
}
|
|
11607
|
+
},
|
|
11608
|
+
// ============================================================
|
|
11512
11609
|
// Meta Llama Models (via OpenRouter)
|
|
11513
11610
|
// ============================================================
|
|
11514
11611
|
{
|
|
@@ -11834,7 +11931,7 @@ var init_openrouter = __esm({
|
|
|
11834
11931
|
high: "high",
|
|
11835
11932
|
maximum: "xhigh"
|
|
11836
11933
|
};
|
|
11837
|
-
OpenRouterProvider = class extends OpenAICompatibleProvider {
|
|
11934
|
+
OpenRouterProvider = class _OpenRouterProvider extends OpenAICompatibleProvider {
|
|
11838
11935
|
providerId = "openrouter";
|
|
11839
11936
|
providerAlias = "or";
|
|
11840
11937
|
constructor(client, config = {}) {
|
|
@@ -11844,8 +11941,10 @@ var init_openrouter = __esm({
|
|
|
11844
11941
|
return OPENROUTER_MODELS;
|
|
11845
11942
|
}
|
|
11846
11943
|
/**
|
|
11847
|
-
* Override buildApiRequest to inject reasoning parameters.
|
|
11848
|
-
* OpenRouter normalizes reasoning into the standard OpenAI format
|
|
11944
|
+
* Override buildApiRequest to inject reasoning parameters and cache_control breakpoints.
|
|
11945
|
+
* OpenRouter normalizes reasoning into the standard OpenAI format,
|
|
11946
|
+
* and supports cache_control on message content blocks for both
|
|
11947
|
+
* Anthropic Claude and Google Gemini models.
|
|
11849
11948
|
*/
|
|
11850
11949
|
buildApiRequest(options, descriptor, spec, messages) {
|
|
11851
11950
|
const request = super.buildApiRequest(options, descriptor, spec, messages);
|
|
@@ -11855,8 +11954,49 @@ var init_openrouter = __esm({
|
|
|
11855
11954
|
effort: OPENROUTER_EFFORT_MAP[options.reasoning.effort ?? "medium"]
|
|
11856
11955
|
};
|
|
11857
11956
|
}
|
|
11957
|
+
const cachingEnabled = options.caching?.enabled !== false;
|
|
11958
|
+
if (cachingEnabled) {
|
|
11959
|
+
this.injectCacheBreakpoints(request);
|
|
11960
|
+
}
|
|
11858
11961
|
return request;
|
|
11859
11962
|
}
|
|
11963
|
+
/** Minimal shape for messages in the already-built OpenAI-compatible request. */
|
|
11964
|
+
static CACHE_CONTROL = { type: "ephemeral" };
|
|
11965
|
+
/**
|
|
11966
|
+
* Add cache_control breakpoints to the last system message and last user message.
|
|
11967
|
+
* This enables OpenRouter's prompt caching for supported providers (Anthropic, Gemini).
|
|
11968
|
+
*
|
|
11969
|
+
* Operates on the already-built request object. We cast through `unknown` because
|
|
11970
|
+
* OpenAI's `ChatCompletionMessageParam` union is too narrow to assign content arrays
|
|
11971
|
+
* with the non-standard `cache_control` property.
|
|
11972
|
+
*/
|
|
11973
|
+
injectCacheBreakpoints(request) {
|
|
11974
|
+
const msgs = request.messages;
|
|
11975
|
+
let lastSystemIdx = -1;
|
|
11976
|
+
let lastUserIdx = -1;
|
|
11977
|
+
for (let i = 0; i < msgs.length; i++) {
|
|
11978
|
+
if (msgs[i].role === "system") lastSystemIdx = i;
|
|
11979
|
+
if (msgs[i].role === "user") lastUserIdx = i;
|
|
11980
|
+
}
|
|
11981
|
+
if (lastSystemIdx >= 0) {
|
|
11982
|
+
msgs[lastSystemIdx].content = this.withCacheControl(msgs[lastSystemIdx].content);
|
|
11983
|
+
}
|
|
11984
|
+
if (lastUserIdx >= 0) {
|
|
11985
|
+
msgs[lastUserIdx].content = this.withCacheControl(msgs[lastUserIdx].content);
|
|
11986
|
+
}
|
|
11987
|
+
}
|
|
11988
|
+
/**
|
|
11989
|
+
* Return a new content array with cache_control on the last block.
|
|
11990
|
+
* String content is promoted to a single-element text block array.
|
|
11991
|
+
*/
|
|
11992
|
+
withCacheControl(content) {
|
|
11993
|
+
if (typeof content === "string") {
|
|
11994
|
+
return [{ type: "text", text: content, cache_control: _OpenRouterProvider.CACHE_CONTROL }];
|
|
11995
|
+
}
|
|
11996
|
+
return content.map(
|
|
11997
|
+
(block, i) => i === content.length - 1 ? { ...block, cache_control: _OpenRouterProvider.CACHE_CONTROL } : block
|
|
11998
|
+
);
|
|
11999
|
+
}
|
|
11860
12000
|
/**
|
|
11861
12001
|
* Get custom headers for OpenRouter analytics.
|
|
11862
12002
|
*/
|