@aaronjmars/openroutercli 0.5.0 → 0.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/README.md +4 -2
- package/SKILL.md +7 -1
- package/package.json +1 -1
- package/src/commands/chat.js +57 -26
- package/src/commands/decisions.js +24 -0
- package/src/commands/guardrails.js +15 -3
- package/src/commands/messages.js +16 -1
- package/src/commands/models.js +14 -1
- package/src/commands/observability.js +7 -0
- package/src/commands/speech.js +6 -3
package/README.md
CHANGED
|
@@ -73,7 +73,7 @@ and run `openrouter login --management`.
|
|
|
73
73
|
| **OAuth PKCE login** | `openrouter login` opens the browser, catches the callback locally, exchanges the code, and stores the key - `0600` perms in `~/.config/openrouter/`. No paste-an-API-key dance. |
|
|
74
74
|
| **Two-slot key management** | User key + management/provisioning key live in separate slots. `keys`, `byok`, `guardrails`, `workspaces`, `observability`, `activity` auto-pick the management key; everything else uses the user key. `--key` always wins. |
|
|
75
75
|
| **Streaming + JSON modes** | Streams in a TTY, switches to JSON when piped or `--json` is set. No global flag plumbing - works on every command. |
|
|
76
|
-
| **Chat with everything** | Tool calls (`--tool @file.json --tool-choice required`), server tools (`--server-tool web_search`), deferred tool loading, structured output (`--schema schema.json`), JSON mode, multimodal images (`--image url\|path`), image output (`--modalities text,image`), reasoning effort, automatic prompt caching (`--cache --cache-ttl 1h`), alignment rules (`--rule`), provider routing, fallback models, service tiers, sessions and traces, full sampling controls. |
|
|
76
|
+
| **Chat with everything** | Tool calls (`--tool @file.json --tool-choice required`), server tools (`--server-tool web_search`), deferred tool loading, structured output (`--schema schema.json`), JSON mode, multimodal images (`--image url\|path`), image output (`--modalities text,image`), reasoning effort, automatic prompt caching (`--cache --cache-ttl 1h`), OpenAI explicit caching (`--cache-ttl 30m|12h`) and free repeat responses (`--response-cache`), alignment rules (`--rule`), provider routing, fallback models, service tiers, sessions and traces, full sampling controls. |
|
|
77
77
|
| **Interactive REPL** | `openrouter chat -i` - slash commands `/model <id>`, `/reset`, `/exit`. History preserved per session. |
|
|
78
78
|
| **Multi-format inference** | `chat` (OpenAI), `messages` (Anthropic), `responses` (OpenAI Responses) - same auth, same flags, same JSON contract. |
|
|
79
79
|
| **Batches** | `batches {create,list,get,wait,results,delete}` - send a JSONL file of chat / responses / messages / embeddings requests as one async job at about half price. |
|
|
@@ -81,7 +81,7 @@ and run `openrouter login --management`.
|
|
|
81
81
|
| **Model discovery with detail** | `models list` (filter, sort by price/context), `models show <id>` (full pricing breakdown - prompt, completion, cache r/w, reasoning, image, web search), `models endpoints <id> --sort throughput\|latency\|prompt\|completion\|uptime --best` for choosing the right provider variant. |
|
|
82
82
|
| **Benchmarks + rankings** | `benchmarks`, `classifications`, and `datasets {apps,daily,session-cost}` expose OpenRouter's current public benchmark and usage datasets. |
|
|
83
83
|
| **Management analytics** | `analytics meta` discovers fields; `analytics query` runs metrics/dimensions/time-range queries with a management key. |
|
|
84
|
-
| **Structured decisions** | `decisions` (alias `systemone`) calls System One for typed choice, score, and yes/no outputs, with optional image inputs. |
|
|
84
|
+
| **Structured decisions** | `decisions` (alias `systemone`) calls System One for typed choice, score, and yes/no outputs, with optional image inputs (`--image`) and named image assets (`--assets`). |
|
|
85
85
|
| **Server tools catalog** | `tools list` / `tools get <name>` - every OpenRouter-run tool (web search, fetch, datetime, ...) with params, engines and pricing. |
|
|
86
86
|
| **Hosted shell files** | `containers {list,get,download,promote}` retrieves and promotes files produced by OpenRouter's hosted shell tools. |
|
|
87
87
|
| **Spend + activity + generations** | `credits` for balance, `whoami` for daily/weekly/monthly usage + rate limit, `keys get <hash>` for per-key spend, `activity --api-key-hash <hash>` for daily aggregates, `generation <id> [--content]` for full per-request metadata + input/output. |
|
|
@@ -138,6 +138,7 @@ openrouter batches wait <id> && openrouter batches results <id> -o out.jsonl
|
|
|
138
138
|
# Discovery
|
|
139
139
|
openrouter models --filter claude --sort prompt
|
|
140
140
|
openrouter models user --order newest
|
|
141
|
+
openrouter models user --client codex # only models a coding harness offers
|
|
141
142
|
openrouter models show anthropic/claude-sonnet-4.5
|
|
142
143
|
openrouter models endpoints anthropic/claude-sonnet-4.5 --sort throughput --best
|
|
143
144
|
openrouter providers
|
|
@@ -150,6 +151,7 @@ openrouter activity --date 2026-04-28 --api-key-hash <hash>
|
|
|
150
151
|
# Management (provisioning key required)
|
|
151
152
|
openrouter keys create "agent-key" --limit 25 --limit-reset monthly
|
|
152
153
|
openrouter guardrails create "no-paid-models" --allowed-providers "" --enforce-zdr
|
|
154
|
+
openrouter guardrails update <id> --harness-models # harness clients see only first-party models
|
|
153
155
|
openrouter workspaces create "staging" --slug staging --default-text-model openai/gpt-4o-mini
|
|
154
156
|
openrouter workspaces budgets set staging monthly --limit 100
|
|
155
157
|
openrouter observability create "langfuse" --type langfuse --config @langfuse.json
|
package/SKILL.md
CHANGED
|
@@ -163,6 +163,9 @@ openrouter chat "summarize this" -m google/gemini-2.5-flash --file ./report.pdf
|
|
|
163
163
|
# Prompt caching: automatic (top-level cache_control, optional 1h TTL) or explicit breakpoints
|
|
164
164
|
openrouter chat "answer from the doc" -m anthropic/claude-sonnet-4.5 -s "$(cat big-context.txt)" --cache --cache-ttl 1h
|
|
165
165
|
openrouter chat "answer from the doc" -m anthropic/claude-sonnet-4.5 -s "$(cat big-context.txt)" --cache-system
|
|
166
|
+
# OpenAI explicit caching (GPT-5.6+): 30m or 12h TTL, marks the system prompt (else the prompt);
|
|
167
|
+
# works on chat and responses, 12h writes bill at a higher rate
|
|
168
|
+
openrouter chat "answer from the doc" -m openai/gpt-5.6 -s "$(cat big-context.txt)" --cache-ttl 12h
|
|
166
169
|
|
|
167
170
|
# Tracing, sessions, priority: works on chat / messages / responses
|
|
168
171
|
openrouter chat "..." -m openai/gpt-4o-mini --session-id run-42 --user u_123 \
|
|
@@ -203,7 +206,7 @@ openrouter embed -m openai/text-embedding-3-small "hello" "world"
|
|
|
203
206
|
openrouter embed -m <multimodal-embed-model> "a cat" --image ./cat.png
|
|
204
207
|
openrouter rerank -m cohere/rerank-v3.5 --query "italian food" -d pizza -d sushi -d pasta
|
|
205
208
|
|
|
206
|
-
# Text to speech (mp3 by default
|
|
209
|
+
# Text to speech (mp3 by default, pcm for HeyGen Voice + Gemini TTS which only return pcm): tone, multi-speaker, voice cloning
|
|
207
210
|
openrouter speech "Hello there" -m elevenlabs/eleven-v4 --voice <voice> -o out.mp3
|
|
208
211
|
openrouter speech "Welcome back" -m openai/gpt-4o-mini-tts --voice alloy --instructions "warm, slow"
|
|
209
212
|
openrouter speech -m google/gemini-2.5-flash-preview-tts --turns @dialogue.json # [{text, voice}]
|
|
@@ -236,6 +239,7 @@ openrouter models --free # only :free models
|
|
|
236
239
|
openrouter models --input-modalities image # image-INPUT (vision) models
|
|
237
240
|
openrouter models --output-modalities image # image-OUTPUT models
|
|
238
241
|
openrouter models user --order newest # account-filtered models, server-side sort
|
|
242
|
+
openrouter models user --client codex # models the named harness offers (claude_code|claude_desktop|codex); honors --harness-models guardrails
|
|
239
243
|
openrouter models --supported tools # filter by capability
|
|
240
244
|
# Full detail for one model: pricing breakdown, architecture, supported params,
|
|
241
245
|
# reasoning config, supported voices
|
|
@@ -254,6 +258,7 @@ openrouter datasets daily --period week --category programming
|
|
|
254
258
|
openrouter analytics meta
|
|
255
259
|
openrouter decisions --model typesafe/jev-1.13 --state '...' --questions @questions.json # alias: systemone
|
|
256
260
|
openrouter decisions --model <vision-decider> --state '...' --image ./chart.png --questions @q.json
|
|
261
|
+
openrouter decisions --model typesafe/jev-1.14 --state '... image: logo' --assets '{"logo":"./logo.png"}' --questions @q.json
|
|
257
262
|
openrouter containers list <container-id>
|
|
258
263
|
|
|
259
264
|
# Supporting metadata
|
|
@@ -312,6 +317,7 @@ openrouter guardrails create "no-paid-models" --allowed-providers "" --enforce-z
|
|
|
312
317
|
openrouter guardrails update <id> --limit-usd 10 --reset-interval daily --include-byok
|
|
313
318
|
openrouter guardrails update <id> --regions europe --builtin-filters email:redact,secrets:block --no-paid-training
|
|
314
319
|
openrouter guardrails update <id> --allow-safety-retention-google --no-allow-safety-retention-other
|
|
320
|
+
openrouter guardrails update <id> --harness-models # codex/claude harnesses only see their vendor's models
|
|
315
321
|
openrouter guardrails assign-key <id> <key-hash> # up to 500 hashes per call
|
|
316
322
|
|
|
317
323
|
openrouter workspaces list
|
package/package.json
CHANGED
package/src/commands/chat.js
CHANGED
|
@@ -42,7 +42,9 @@ export const SERVER_TOOL_HELP = ` --server-tool <name>[=<json|@file>] Open
|
|
|
42
42
|
`;
|
|
43
43
|
|
|
44
44
|
export const CACHE_HELP = ` --cache Automatic prompt caching (top-level cache_control)
|
|
45
|
-
--cache-ttl <ttl> 5m | 1h (implies --cache)
|
|
45
|
+
--cache-ttl <ttl> 5m | 1h (implies --cache). chat/responses also take
|
|
46
|
+
30m | 12h: OpenAI explicit prompt_cache_options
|
|
47
|
+
(GPT-5.6+; 12h writes bill higher)
|
|
46
48
|
`;
|
|
47
49
|
|
|
48
50
|
export const ALIGNMENT_HELP = ` --rule <text> Alignment plugin rule (repeatable, max 128, <=200 chars,
|
|
@@ -80,11 +82,25 @@ export async function applyToolExtras(body, values) {
|
|
|
80
82
|
}
|
|
81
83
|
}
|
|
82
84
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
+
const EXPLICIT_CACHE_TTLS = ["30m", "12h"];
|
|
86
|
+
|
|
87
|
+
// 5m | 1h: top-level cache_control (Anthropic style). 30m | 12h: OpenAI
|
|
88
|
+
// explicit prompt_cache_options, which only caches blocks marked with
|
|
89
|
+
// prompt_cache_breakpoint, so the caller must mark one. Returns true for the
|
|
90
|
+
// explicit form. `explicit` = the endpoint accepts it (chat, responses).
|
|
91
|
+
export function applyCache(body, values, { explicit = false } = {}) {
|
|
92
|
+
if (!values.cache && !values["cache-ttl"]) return false;
|
|
85
93
|
const ttl = values["cache-ttl"];
|
|
86
|
-
if (ttl
|
|
94
|
+
if (EXPLICIT_CACHE_TTLS.includes(ttl)) {
|
|
95
|
+
if (!explicit) throw new Error("--cache-ttl 30m|12h works with chat and responses only");
|
|
96
|
+
body.prompt_cache_options = { mode: "explicit", ttl };
|
|
97
|
+
return true;
|
|
98
|
+
}
|
|
99
|
+
if (ttl && ttl !== "5m" && ttl !== "1h") {
|
|
100
|
+
throw new Error(`--cache-ttl must be ${explicit ? "5m, 1h, 30m or 12h" : "5m or 1h"}`);
|
|
101
|
+
}
|
|
87
102
|
body.cache_control = { type: "ephemeral", ...(ttl ? { ttl } : {}) };
|
|
103
|
+
return false;
|
|
88
104
|
}
|
|
89
105
|
|
|
90
106
|
// Adds the alignment plugin from --rule/--alignment-*. An alignment entry
|
|
@@ -193,11 +209,14 @@ ${SERVER_TOOL_HELP} --reasoning <effort> none|minimal|low|medium|high|xhigh
|
|
|
193
209
|
--reasoning-max-tokens <n> Reasoning token budget (Anthropic-style)
|
|
194
210
|
--reasoning-exclude Reason internally but omit reasoning from the output
|
|
195
211
|
--provider <json|@file> Provider routing (order, only, sort, ...;
|
|
196
|
-
options: per-provider passthrough keyed by slug)
|
|
212
|
+
options: per-provider passthrough keyed by slug).
|
|
213
|
+
Default routing weighs quality-per-cost; sort:price or
|
|
214
|
+
a :floor model suffix keeps the cheapest-first order
|
|
197
215
|
--modalities <csv> Output modalities: text,image,audio
|
|
198
216
|
--image-config <json|@file> Image output options, e.g. {"aspect_ratio":"16:9"}
|
|
199
217
|
--prediction <text|@file> Predicted output (prediction.content) to cut latency
|
|
200
|
-
--
|
|
218
|
+
--response-cache X-OpenRouter-Cache: free repeat responses for
|
|
219
|
+
identical requests (separate from --cache prompt caching)
|
|
201
220
|
--metadata <json|@file> String key/value pairs (max 16)
|
|
202
221
|
${CACHE_HELP} --cache-system Mark the system prompt as a cache breakpoint
|
|
203
222
|
--cache-user Mark the user prompt as a cache breakpoint
|
|
@@ -355,15 +374,18 @@ async function buildPlugins(values) {
|
|
|
355
374
|
return addAlignmentPlugin(list, values);
|
|
356
375
|
}
|
|
357
376
|
|
|
358
|
-
// Wrap a string into a single text content part so a
|
|
359
|
-
//
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
377
|
+
// Wrap a string into a single text content part so a cache breakpoint can be
|
|
378
|
+
// attached; content already in part form gets it on its last part. Explicit
|
|
379
|
+
// mode uses prompt_cache_breakpoint, which only text parts accept.
|
|
380
|
+
function markCache(content, explicit) {
|
|
381
|
+
const mark = explicit
|
|
382
|
+
? { prompt_cache_breakpoint: { mode: "explicit" } }
|
|
383
|
+
: { cache_control: { type: "ephemeral" } };
|
|
384
|
+
if (typeof content === "string") return [{ type: "text", text: content, ...mark }];
|
|
364
385
|
if (Array.isArray(content) && content.length) {
|
|
365
386
|
const parts = content.map((p) => ({ ...p }));
|
|
366
|
-
parts
|
|
387
|
+
const i = explicit ? parts.findLastIndex((p) => p.type === "text") : parts.length - 1;
|
|
388
|
+
if (i !== -1) Object.assign(parts[i], mark);
|
|
367
389
|
return parts;
|
|
368
390
|
}
|
|
369
391
|
return content;
|
|
@@ -427,22 +449,23 @@ async function applyRequestOptions(body, values) {
|
|
|
427
449
|
}
|
|
428
450
|
if (values["prompt-cache-key"]) body.prompt_cache_key = values["prompt-cache-key"];
|
|
429
451
|
if (values.metadata) body.metadata = await loadJsonOrFile(values.metadata, "--metadata");
|
|
430
|
-
applyCache(body, values);
|
|
452
|
+
const explicit = applyCache(body, values, { explicit: true });
|
|
431
453
|
await applyRequestFields(body, values);
|
|
432
454
|
|
|
433
455
|
const plugins = await buildPlugins(values);
|
|
434
456
|
if (plugins.length) body.plugins = plugins;
|
|
435
457
|
|
|
436
|
-
//
|
|
437
|
-
//
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
if (
|
|
458
|
+
// Cache breakpoints are attached to message content, so this must run after
|
|
459
|
+
// the messages are assembled. Explicit mode caches nothing unmarked, so with
|
|
460
|
+
// no --cache-system/--cache-user it marks the system prompt, else the prompt.
|
|
461
|
+
const sys = body.messages.find((m) => m.role === "system");
|
|
462
|
+
const markSystem = values["cache-system"] || (explicit && !values["cache-user"] && sys);
|
|
463
|
+
const markUser = values["cache-user"] || (explicit && !values["cache-system"] && !sys);
|
|
464
|
+
if (markSystem && sys) sys.content = markCache(sys.content, explicit);
|
|
465
|
+
if (markUser) {
|
|
443
466
|
for (let i = body.messages.length - 1; i >= 0; i--) {
|
|
444
467
|
if (body.messages[i].role === "user") {
|
|
445
|
-
body.messages[i].content = markCache(body.messages[i].content);
|
|
468
|
+
body.messages[i].content = markCache(body.messages[i].content, explicit);
|
|
446
469
|
break;
|
|
447
470
|
}
|
|
448
471
|
}
|
|
@@ -475,13 +498,13 @@ function printUsage(model, usage) {
|
|
|
475
498
|
);
|
|
476
499
|
}
|
|
477
500
|
|
|
478
|
-
async function streamResponse(body, auth) {
|
|
501
|
+
async function streamResponse(body, auth, extraHeaders) {
|
|
479
502
|
const res = await withAlignmentErrors(
|
|
480
503
|
api("POST", "/chat/completions", {
|
|
481
504
|
auth,
|
|
482
505
|
body: { ...body, stream: true },
|
|
483
506
|
raw: true,
|
|
484
|
-
headers: { Accept: "text/event-stream" },
|
|
507
|
+
headers: { Accept: "text/event-stream", ...extraHeaders },
|
|
485
508
|
}),
|
|
486
509
|
);
|
|
487
510
|
let usage = null;
|
|
@@ -574,6 +597,7 @@ export async function chatCommand(argv) {
|
|
|
574
597
|
"image-config": { type: "string" },
|
|
575
598
|
prediction: { type: "string" },
|
|
576
599
|
"prompt-cache-key": { type: "string" },
|
|
600
|
+
"response-cache": { type: "boolean" },
|
|
577
601
|
metadata: { type: "string" },
|
|
578
602
|
image: { type: "string", multiple: true },
|
|
579
603
|
file: { type: "string", multiple: true },
|
|
@@ -623,7 +647,10 @@ export async function chatCommand(argv) {
|
|
|
623
647
|
const body = await buildBody(values, prompt);
|
|
624
648
|
|
|
625
649
|
if (!shouldStream(values)) {
|
|
626
|
-
const
|
|
650
|
+
const rcHeaders = values["response-cache"] ? { "X-OpenRouter-Cache": "true" } : undefined;
|
|
651
|
+
const data = await withAlignmentErrors(
|
|
652
|
+
api("POST", "/chat/completions", { auth, body, headers: rcHeaders }),
|
|
653
|
+
);
|
|
627
654
|
if (isJsonMode() || values.raw) {
|
|
628
655
|
printJSON(data);
|
|
629
656
|
} else {
|
|
@@ -651,7 +678,11 @@ export async function chatCommand(argv) {
|
|
|
651
678
|
return 0;
|
|
652
679
|
}
|
|
653
680
|
|
|
654
|
-
const meta = await streamResponse(
|
|
681
|
+
const meta = await streamResponse(
|
|
682
|
+
body,
|
|
683
|
+
auth,
|
|
684
|
+
values["response-cache"] ? { "X-OpenRouter-Cache": "true" } : undefined,
|
|
685
|
+
);
|
|
655
686
|
if (values.usage && meta.usage) printUsage(meta.model, meta.usage);
|
|
656
687
|
if (ERROR_FINISH_REASONS.includes(meta.finishReason)) {
|
|
657
688
|
process.stderr.write(`error: generation stopped (${meta.finishReason})\n`);
|
|
@@ -16,6 +16,9 @@ Options:
|
|
|
16
16
|
--questions <json> Questions object or @questions.json
|
|
17
17
|
--image <url|path> Add an image to the state (repeatable). Local files
|
|
18
18
|
are sent as data URLs. For multimodal models.
|
|
19
|
+
--assets <json|@file> Named images referenced from state/instructions/
|
|
20
|
+
criteria: {"ref-name": "<local path>"} (png/jpg/jpeg;
|
|
21
|
+
uploaded as data_base64). Every name must be referenced.
|
|
19
22
|
--body <json|@file> Fully-formed request body
|
|
20
23
|
--extra <json> Extra fields merged into the request
|
|
21
24
|
--alpha Use the older /api/alpha/decisions route
|
|
@@ -57,6 +60,7 @@ export async function decisionsCommand(argv) {
|
|
|
57
60
|
state: { type: "string" },
|
|
58
61
|
questions: { type: "string" },
|
|
59
62
|
image: { type: "string", multiple: true },
|
|
63
|
+
assets: { type: "string" },
|
|
60
64
|
body: { type: "string" },
|
|
61
65
|
extra: { type: "string" },
|
|
62
66
|
alpha: { type: "boolean" },
|
|
@@ -81,6 +85,26 @@ export async function decisionsCommand(argv) {
|
|
|
81
85
|
const parts = await Promise.all(images.map(imagePart));
|
|
82
86
|
body.state = withImages(body.state, parts);
|
|
83
87
|
}
|
|
88
|
+
if (values.assets !== undefined) {
|
|
89
|
+
const assets = await loadJson(values.assets, "--assets");
|
|
90
|
+
if (!assets || typeof assets !== "object" || Array.isArray(assets)) {
|
|
91
|
+
throw new Error('--assets must be a JSON object like {"ref": "<path>"}');
|
|
92
|
+
}
|
|
93
|
+
body.assets = {};
|
|
94
|
+
for (const [name, src] of Object.entries(assets)) {
|
|
95
|
+
const url = await mediaUrl(src);
|
|
96
|
+
if (!url.startsWith("data:")) {
|
|
97
|
+
throw new Error(
|
|
98
|
+
`--assets "${name}": the Decisions API only accepts uploaded images. Give a local file (png/jpg/jpeg), not a URL.`,
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
const [mime, b64] = url.slice(5).split(";base64,");
|
|
102
|
+
const format = { "image/png": "png", "image/jpeg": "jpeg" }[mime];
|
|
103
|
+
if (!format)
|
|
104
|
+
throw new Error(`--assets "${name}": expected a png/jpg/jpeg image, got ${mime}`);
|
|
105
|
+
body.assets[name] = { type: "image", format, data_base64: b64 };
|
|
106
|
+
}
|
|
107
|
+
}
|
|
84
108
|
if (values.extra) Object.assign(body, await loadJson(values.extra, "--extra"));
|
|
85
109
|
const data = values.alpha
|
|
86
110
|
? await api("POST", "/decisions", {
|
|
@@ -57,6 +57,10 @@ create / update options:
|
|
|
57
57
|
Allow ZDR requests to google/* to use endpoints that retain for safety
|
|
58
58
|
--allow-safety-retention-other / --no-allow-safety-retention-other
|
|
59
59
|
Allow ZDR requests to other models to use endpoints that retain for safety
|
|
60
|
+
--harness-models / --no-harness-models
|
|
61
|
+
enforce_first_party_harness_models: when a coding
|
|
62
|
+
harness (claude_code, claude_desktop, codex) lists
|
|
63
|
+
models, show only the harness vendor's own
|
|
60
64
|
--include-byok / --no-include-byok Count BYOK spend toward the budget
|
|
61
65
|
--workspace <uuid> (create only)
|
|
62
66
|
--extra <json|@file> Extra body fields, merged last (e.g. enforce_zdr_xai:false)
|
|
@@ -64,7 +68,7 @@ create / update options:
|
|
|
64
68
|
|
|
65
69
|
const ZDR_PROVIDERS = ["anthropic", "openai", "google", "xai", "other"];
|
|
66
70
|
const REGIONS = ["global", "europe", "us"];
|
|
67
|
-
const
|
|
71
|
+
const MAX_BULK_IDS = 500;
|
|
68
72
|
|
|
69
73
|
function toggle(values, on, off) {
|
|
70
74
|
if (values[on] && values[off]) throw new Error(`Pass only one of --${on} or --${off}.`);
|
|
@@ -151,6 +155,7 @@ async function buildBody(values) {
|
|
|
151
155
|
["enable_paid_model_training", "paid-training"],
|
|
152
156
|
["allow_safety_retention_google", "allow-safety-retention-google"],
|
|
153
157
|
["allow_safety_retention_other", "allow-safety-retention-other"],
|
|
158
|
+
["enforce_first_party_harness_models", "harness-models"],
|
|
154
159
|
];
|
|
155
160
|
for (const [field, flag] of toggles) {
|
|
156
161
|
const v = toggle(values, flag, `no-${flag}`);
|
|
@@ -192,6 +197,8 @@ const COMMON_FIELDS = {
|
|
|
192
197
|
"no-allow-safety-retention-google": { type: "boolean" },
|
|
193
198
|
"allow-safety-retention-other": { type: "boolean" },
|
|
194
199
|
"no-allow-safety-retention-other": { type: "boolean" },
|
|
200
|
+
"harness-models": { type: "boolean" },
|
|
201
|
+
"no-harness-models": { type: "boolean" },
|
|
195
202
|
extra: { type: "string" },
|
|
196
203
|
};
|
|
197
204
|
|
|
@@ -339,9 +346,9 @@ export async function guardrailsCommand(argv) {
|
|
|
339
346
|
if (positionals.length < 2) throw new Error("Usage: <id> <hash>...");
|
|
340
347
|
const id = positionals[0];
|
|
341
348
|
const hashes = positionals.slice(1);
|
|
342
|
-
if (hashes.length >
|
|
349
|
+
if (hashes.length > MAX_BULK_IDS) {
|
|
343
350
|
throw new Error(
|
|
344
|
-
`Too many key hashes (${hashes.length}); the API takes at most ${
|
|
351
|
+
`Too many key hashes (${hashes.length}); the API takes at most ${MAX_BULK_IDS} per call. Split into batches.`,
|
|
345
352
|
);
|
|
346
353
|
}
|
|
347
354
|
const path =
|
|
@@ -362,6 +369,11 @@ export async function guardrailsCommand(argv) {
|
|
|
362
369
|
if (positionals.length < 2) throw new Error("Usage: <id> <user_id>...");
|
|
363
370
|
const id = positionals[0];
|
|
364
371
|
const userIds = positionals.slice(1);
|
|
372
|
+
if (userIds.length > MAX_BULK_IDS) {
|
|
373
|
+
throw new Error(
|
|
374
|
+
`Too many user ids (${userIds.length}); the API takes at most ${MAX_BULK_IDS} per call. Split into batches.`,
|
|
375
|
+
);
|
|
376
|
+
}
|
|
365
377
|
const path =
|
|
366
378
|
sub === "assign-member"
|
|
367
379
|
? `/guardrails/${encodeURIComponent(id)}/assignments/members`
|
package/src/commands/messages.js
CHANGED
|
@@ -374,7 +374,22 @@ export async function responsesCommand(argv) {
|
|
|
374
374
|
if (values.background) body.background = true;
|
|
375
375
|
if (values["prompt-cache-key"]) body.prompt_cache_key = values["prompt-cache-key"];
|
|
376
376
|
if (values["safety-identifier"]) body.safety_identifier = values["safety-identifier"];
|
|
377
|
-
|
|
377
|
+
// Explicit mode caches only marked blocks: mark the prompt, which caches
|
|
378
|
+
// the instructions before it too.
|
|
379
|
+
if (applyCache(body, values, { explicit: true }) && typeof body.input === "string") {
|
|
380
|
+
body.input = [
|
|
381
|
+
{
|
|
382
|
+
role: "user",
|
|
383
|
+
content: [
|
|
384
|
+
{
|
|
385
|
+
type: "input_text",
|
|
386
|
+
text: body.input,
|
|
387
|
+
prompt_cache_breakpoint: { mode: "explicit" },
|
|
388
|
+
},
|
|
389
|
+
],
|
|
390
|
+
},
|
|
391
|
+
];
|
|
392
|
+
}
|
|
378
393
|
await applyRequestFields(body, values);
|
|
379
394
|
if (values.extra) Object.assign(body, await loadJson(values.extra, "--extra"));
|
|
380
395
|
}
|
package/src/commands/models.js
CHANGED
|
@@ -426,13 +426,14 @@ export async function modelsCommand(argv) {
|
|
|
426
426
|
"output-modalities": { type: "string" },
|
|
427
427
|
order: { type: "string" },
|
|
428
428
|
sort: { type: "string" },
|
|
429
|
+
client: { type: "string" },
|
|
429
430
|
});
|
|
430
431
|
} catch (err) {
|
|
431
432
|
// `models user` used to forward every list filter; the endpoint only
|
|
432
433
|
// takes these, so say so instead of a bare "Unknown option".
|
|
433
434
|
if (err.code === "ERR_PARSE_ARGS_UNKNOWN_OPTION") {
|
|
434
435
|
throw new Error(
|
|
435
|
-
`${err.message.split(".")[0]}. models user only supports --output-modalities, --order/--sort, --limit and --offset; use \`openrouter models list\` for search filters.`,
|
|
436
|
+
`${err.message.split(".")[0]}. models user only supports --output-modalities, --order/--sort, --client, --limit and --offset; use \`openrouter models list\` for search filters.`,
|
|
436
437
|
);
|
|
437
438
|
}
|
|
438
439
|
throw err;
|
|
@@ -447,6 +448,10 @@ export async function modelsCommand(argv) {
|
|
|
447
448
|
"Options:\n" +
|
|
448
449
|
" --output-modalities <csv> text,image,embeddings,audio,video,rerank,decisions,\n" +
|
|
449
450
|
' speech,transcription (or "all"). Default: text\n' +
|
|
451
|
+
" --client <harness> Only models the named coding harness offers:\n" +
|
|
452
|
+
" claude_code | claude_desktop | codex. When a\n" +
|
|
453
|
+
" guardrail sets enforce_first_party_harness_models,\n" +
|
|
454
|
+
" only the harness vendor's own models.\n" +
|
|
450
455
|
" --order <sort> Server-side sort: most-popular|newest|top-weekly|\n" +
|
|
451
456
|
" pricing-low-to-high|pricing-high-to-low|\n" +
|
|
452
457
|
" context-high-to-low|throughput-high-to-low|\n" +
|
|
@@ -462,6 +467,14 @@ export async function modelsCommand(argv) {
|
|
|
462
467
|
const query = paginationQuery(values);
|
|
463
468
|
if (values["output-modalities"]) query.output_modalities = values["output-modalities"];
|
|
464
469
|
if (values.order || values.sort) query.sort = values.order || values.sort;
|
|
470
|
+
if (values.client) {
|
|
471
|
+
if (!["claude_code", "claude_desktop", "codex"].includes(values.client)) {
|
|
472
|
+
throw new Error(
|
|
473
|
+
`Unknown --client "${values.client}". Expected: claude_code, claude_desktop, codex`,
|
|
474
|
+
);
|
|
475
|
+
}
|
|
476
|
+
query.client = values.client;
|
|
477
|
+
}
|
|
465
478
|
const data = await api("GET", "/models/user", {
|
|
466
479
|
auth: authFromValues(values),
|
|
467
480
|
query,
|
|
@@ -35,6 +35,13 @@ create / update options:
|
|
|
35
35
|
{"publicKey":"pk-lf-...","secretKey":"sk-lf-...",
|
|
36
36
|
"baseUrl":"https://cloud.langfuse.com"}. Clickhouse and
|
|
37
37
|
Snowflake accept "shouldIncludeCacheWriteTokens": true.
|
|
38
|
+
For s3, key auth: {"accessKeyId":"...",
|
|
39
|
+
"secretAccessKey":"...",...} or IAM role auth:
|
|
40
|
+
{"authMode":"iam_role","provider":"aws",
|
|
41
|
+
"roleArn":"arn:aws:iam::<acct>:role/<name>",
|
|
42
|
+
"region":"<region>","externalId":"<id>"} (GovCloud and
|
|
43
|
+
China ARNs rejected; trust policy must require the
|
|
44
|
+
external id).
|
|
38
45
|
On update, masked values are ignored and unset fields
|
|
39
46
|
keep their value.
|
|
40
47
|
--name <name> (update only)
|
package/src/commands/speech.js
CHANGED
|
@@ -26,7 +26,8 @@ Options:
|
|
|
26
26
|
or one image (.png/.jpg/.webp) for voice design.
|
|
27
27
|
Local files are sent as data URLs.
|
|
28
28
|
--ref-text <t> Transcript of a --ref clip (repeatable, in --ref order)
|
|
29
|
-
--format <fmt> mp3 | pcm (default: mp3
|
|
29
|
+
--format <fmt> mp3 | pcm (default: mp3, or pcm for HeyGen Voice and
|
|
30
|
+
Gemini TTS, which only return pcm; pcm is raw 16-bit audio)
|
|
30
31
|
--speed <n> Speech speed (e.g. 1.0)
|
|
31
32
|
-o, --out <file> Output audio file (default: out.mp3 / out.pcm, or stdout if -)
|
|
32
33
|
--provider <json|@file> Routing and provider options, e.g.
|
|
@@ -86,8 +87,10 @@ export async function speechCommand(argv) {
|
|
|
86
87
|
input = text;
|
|
87
88
|
}
|
|
88
89
|
|
|
89
|
-
// The API defaults to raw PCM; ask for mp3 so the default out.mp3 plays
|
|
90
|
-
|
|
90
|
+
// The API defaults to raw PCM; ask for mp3 so the default out.mp3 plays,
|
|
91
|
+
// except on HeyGen Voice and Gemini TTS, which return only pcm (400 on mp3).
|
|
92
|
+
const pcmOnly = /^heygen\//.test(values.model) || /^google\/.*-tts\b/.test(values.model);
|
|
93
|
+
const format = values.format || (pcmOnly ? "pcm" : "mp3");
|
|
91
94
|
const body = { model: values.model, input, response_format: format };
|
|
92
95
|
if (values.voice) body.voice = values.voice;
|
|
93
96
|
if (values.instructions) body.instructions = values.instructions;
|