@aaronjmars/openroutercli 0.13.0 → 0.15.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 -3
- package/SKILL.md +5 -1
- package/package.json +2 -1
- package/src/api.js +24 -1
- package/src/args.js +12 -3
- package/src/commands/batches.js +42 -10
- package/src/commands/chat.js +8 -5
- package/src/commands/login.js +2 -4
- package/src/commands/messages.js +8 -4
- package/src/commands/models.js +33 -12
- package/src/commands/observability.js +2 -0
- package/src/commands/request.js +2 -9
- package/src/commands/rerank.js +2 -3
- package/src/commands/transcribe.js +4 -0
package/README.md
CHANGED
|
@@ -77,8 +77,8 @@ and run `openrouter login --management`.
|
|
|
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,cancel,delete}` - send a JSONL file of chat / responses / messages / embeddings requests as one async job at about half price. |
|
|
80
|
-
| **Embeddings + rerank + speech + video** | `embed` (text or images), `rerank`, `speech` (tone instructions, multi-speaker turns, voice references), `transcribe` (URL input, speaker labels, key terms, word timestamps), `video {create,wait,download}` (resolution, first/last frame, references, audio, extend) - async video jobs poll-until-done with `video wait <jobId>`. |
|
|
81
|
-
| **Model discovery with detail** | `models list` (filter, sort by price/context, `--endpoints` by API path served), `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. |
|
|
80
|
+
| **Embeddings + rerank + speech + video** | `embed` (text or images), `rerank`, `speech` (tone instructions, multi-speaker turns, voice references), `transcribe` (URL input, speaker labels, key terms, context prompt, word timestamps), `video {create,wait,download}` (resolution, first/last frame, references, audio, extend) - async video jobs poll-until-done with `video wait <jobId>`. |
|
|
81
|
+
| **Model discovery with detail** | `models list` (filter, sort by price/context, `--endpoints` by API path served, `--min-<name>-index`/`--max-<name>-index` Artificial Analysis score bounds), `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
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`). `extract` (alias `extractions`, alpha) pulls typed fields (text, number, date, list, estimate, forecast...) out of text or attached image/PDF assets. |
|
|
@@ -138,7 +138,8 @@ openrouter image "put a hat here" -m openai/gpt-image-2.6-flare --image ./cat.pn
|
|
|
138
138
|
# Batches at about half price
|
|
139
139
|
openrouter batches create --endpoint chat -m openai/gpt-4o-mini --file reqs.jsonl --callback-url https://example.com/webhook
|
|
140
140
|
openrouter batches wait <id> && openrouter batches results <id> -o out.jsonl
|
|
141
|
-
openrouter batches
|
|
141
|
+
openrouter batches create --endpoint chat -m google/gemini-3.8-flash --input gs://bucket/reqs.jsonl # input in your own storage (allowlisted Vertex BYOK only)
|
|
142
|
+
openrouter batches cancel <id> # stop a running batch (cancellation is enabled per org; OpenRouter dropped the route in Nov 2026, so it may 404)
|
|
142
143
|
|
|
143
144
|
# Discovery
|
|
144
145
|
openrouter models --filter claude --sort prompt
|
package/SKILL.md
CHANGED
|
@@ -202,7 +202,8 @@ openrouter responses "..." -m openai/gpt-5-mini --verbosity low --truncation aut
|
|
|
202
202
|
# Batches: async jobs at ~half price (chat, responses, messages, embeddings)
|
|
203
203
|
openrouter batches create --endpoint chat -m openai/gpt-4o-mini --file reqs.jsonl --callback-url https://example.com/webhook # {custom_id, body} per line
|
|
204
204
|
openrouter batches wait <id> && openrouter batches results <id> -o out.jsonl
|
|
205
|
-
openrouter batches
|
|
205
|
+
openrouter batches create --endpoint chat -m google/gemini-3.8-flash --input gs://bucket/reqs.jsonl # input already in your storage (gs:// or bq://), allowlisted Vertex BYOK only
|
|
206
|
+
openrouter batches cancel <id> # stop a running batch; 403 = cancel not enabled for the org, 409 = already ended, 404 = route dropped upstream (Nov 2026)
|
|
206
207
|
|
|
207
208
|
# Embeddings (text or images), rerank
|
|
208
209
|
openrouter embed -m openai/text-embedding-3-small "hello" "world"
|
|
@@ -219,6 +220,7 @@ openrouter speech "Hi" -m <cloning-model> --ref ./sample.wav --ref-text "words i
|
|
|
219
220
|
openrouter transcribe ./clip.wav -m openai/gpt-4o-transcribe # alias: stt
|
|
220
221
|
openrouter transcribe --url https://example.com/call.mp3 -m elevenlabs/scribe-v2 --diarize
|
|
221
222
|
openrouter transcribe ./talk.mp3 -m elevenlabs/scribe-v2 --keyterms OpenRouter,BYOK --timestamps word
|
|
223
|
+
openrouter transcribe ./standup.m4a -m openai/gpt-4o-transcribe --prompt "Team standup about BYOK routing"
|
|
222
224
|
|
|
223
225
|
# Image generation (writes image-0.png, ...): tier or exact size, reference images
|
|
224
226
|
openrouter image "a red bike on a beach" -m google/gemini-2.5-flash-image -o bike.png
|
|
@@ -241,6 +243,8 @@ openrouter video create "keep going" -m <video-model> --extend <jobId>
|
|
|
241
243
|
openrouter models # all (~430)
|
|
242
244
|
openrouter models --filter sonnet --sort prompt # local sort, cheapest first
|
|
243
245
|
openrouter models --order intelligence-high-to-low # server-side ranking
|
|
246
|
+
openrouter models --min-cyber-index 50 --max-price 2 # Artificial Analysis index bounds (0-100):
|
|
247
|
+
# intelligence, coding, agentic, cyber, decision, legal, ...
|
|
244
248
|
openrouter models --free # only :free models
|
|
245
249
|
openrouter models --input-modalities image # image-INPUT (vision) models
|
|
246
250
|
openrouter models --output-modalities image # image-OUTPUT models
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aaronjmars/openroutercli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
4
4
|
"description": "Command-line interface for the OpenRouter API. Built for humans and LLM agents.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -51,6 +51,7 @@
|
|
|
51
51
|
},
|
|
52
52
|
"scripts": {
|
|
53
53
|
"start": "node bin/openrouter.js",
|
|
54
|
+
"test": "node --test",
|
|
54
55
|
"format": "biome format --write .",
|
|
55
56
|
"format:check": "biome ci ."
|
|
56
57
|
},
|
package/src/api.js
CHANGED
|
@@ -124,11 +124,34 @@ export async function api(method, path, opts = {}) {
|
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
+
// A failed body with no error object: name the status and id, and keep the
|
|
128
|
+
// body short instead of dumping the whole response.
|
|
129
|
+
function failureSummary(data) {
|
|
130
|
+
const body = JSON.stringify(data);
|
|
131
|
+
const short = body.length > 200 ? `${body.slice(0, 200)}...` : body;
|
|
132
|
+
return `${data.status ?? data.type}${data.id ? ` (${data.id})` : ""}: ${short}`;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// Returns data, so it chains: api(...).then(assertNoResponseError).
|
|
136
|
+
export function assertNoResponseError(data) {
|
|
137
|
+
if (!data || typeof data !== "object") return data;
|
|
138
|
+
const err = data.error ?? (data.type === "error" || data.status === "failed" ? data : null);
|
|
139
|
+
if (!err) return data;
|
|
140
|
+
const message =
|
|
141
|
+
typeof err === "string"
|
|
142
|
+
? err
|
|
143
|
+
: err.message || (err === data ? failureSummary(data) : JSON.stringify(err));
|
|
144
|
+
throw new APIError(`response error: ${message}`, { body: data });
|
|
145
|
+
}
|
|
146
|
+
|
|
127
147
|
// Streaming endpoints report failures as an in-band event rather than a
|
|
128
148
|
// non-2xx status, so nothing above this catches them.
|
|
129
149
|
export function assertNoStreamError(evt) {
|
|
130
150
|
if (!evt) return;
|
|
131
|
-
const err =
|
|
151
|
+
const err =
|
|
152
|
+
evt.error ??
|
|
153
|
+
(evt.type === "error" ? evt : null) ??
|
|
154
|
+
(evt.type === "response.failed" ? (evt.response?.error ?? evt.response ?? evt) : null);
|
|
132
155
|
if (!err) return;
|
|
133
156
|
const message = (typeof err === "string" ? err : err.message) || JSON.stringify(err);
|
|
134
157
|
throw new APIError(`stream error: ${message}`);
|
package/src/args.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { parseArgs as nodeParseArgs } from "node:util";
|
|
2
2
|
import { stdin } from "node:process";
|
|
3
|
+
import { StringDecoder } from "node:string_decoder";
|
|
3
4
|
import { isJsonMode } from "./output.js";
|
|
4
5
|
|
|
5
6
|
const GLOBAL_OPTIONS = {
|
|
@@ -57,11 +58,19 @@ export function authFromValues(values) {
|
|
|
57
58
|
return out;
|
|
58
59
|
}
|
|
59
60
|
|
|
61
|
+
export async function readStdinText() {
|
|
62
|
+
const decoder = new StringDecoder("utf8");
|
|
63
|
+
let data = "";
|
|
64
|
+
for await (const chunk of stdin) {
|
|
65
|
+
data += typeof chunk === "string" ? chunk : decoder.write(chunk);
|
|
66
|
+
}
|
|
67
|
+
// Windows editors often prefix a BOM, which JSON.parse rejects.
|
|
68
|
+
return (data + decoder.end()).replace(/^\uFEFF/, "");
|
|
69
|
+
}
|
|
70
|
+
|
|
60
71
|
export async function readStdinIfPiped() {
|
|
61
72
|
if (stdin.isTTY) return null;
|
|
62
|
-
|
|
63
|
-
for await (const chunk of stdin) data += chunk;
|
|
64
|
-
return data.trim() || null;
|
|
73
|
+
return (await readStdinText()).trim() || null;
|
|
65
74
|
}
|
|
66
75
|
|
|
67
76
|
export function shouldStream(values) {
|
package/src/commands/batches.js
CHANGED
|
@@ -13,7 +13,8 @@ Subcommands:
|
|
|
13
13
|
get <id> Status, request counts and usage
|
|
14
14
|
wait <id> [options] Poll until the batch reaches a final status
|
|
15
15
|
results <id> [-o out.jsonl] Write the per-request results as JSONL
|
|
16
|
-
cancel <id> Ask the provider to stop a running batch
|
|
16
|
+
cancel <id> Ask the provider to stop a running batch (route dropped
|
|
17
|
+
from the OpenRouter API in Nov 2026: may 404)
|
|
17
18
|
delete <id> Delete a finished batch and its stored data
|
|
18
19
|
|
|
19
20
|
list options:
|
|
@@ -30,6 +31,10 @@ create options:
|
|
|
30
31
|
--file <path> JSONL, one request per line: {"custom_id": "...", "body": {...}}
|
|
31
32
|
(a line without "body" is used as the body itself and
|
|
32
33
|
gets custom_id req-<n>). Reads stdin when omitted.
|
|
34
|
+
--input <uri> Input in your own storage instead of --file:
|
|
35
|
+
gs://bucket/object.jsonl or bq://project.dataset.table,
|
|
36
|
+
already in provider batch format (allowlisted
|
|
37
|
+
Google Vertex BYOK only)
|
|
33
38
|
--completion-window <w> Default: 24h
|
|
34
39
|
--callback-url <url> Webhook URL called on terminal status events
|
|
35
40
|
--provider <json|@file> Routing: {"only": [...], "allow_fallbacks": false}
|
|
@@ -165,10 +170,11 @@ function printBatch(b) {
|
|
|
165
170
|
}
|
|
166
171
|
|
|
167
172
|
// 410 and 402 carry a useful meaning the generic API message hides.
|
|
168
|
-
async function getBatch(id, values) {
|
|
173
|
+
async function getBatch(id, values, signal) {
|
|
169
174
|
try {
|
|
170
175
|
return await api("GET", `/batches/${encodeURIComponent(id)}`, {
|
|
171
176
|
auth: authFromValues(values),
|
|
177
|
+
signal,
|
|
172
178
|
});
|
|
173
179
|
} catch (err) {
|
|
174
180
|
if (err instanceof APIError && err.status === 410) {
|
|
@@ -238,24 +244,26 @@ export async function batchesCommand(argv) {
|
|
|
238
244
|
file: { type: "string" },
|
|
239
245
|
"completion-window": { type: "string" },
|
|
240
246
|
"callback-url": { type: "string" },
|
|
247
|
+
input: { type: "string" },
|
|
241
248
|
provider: { type: "string" },
|
|
242
249
|
only: { type: "string" },
|
|
243
250
|
"no-fallbacks": { type: "boolean" },
|
|
244
251
|
});
|
|
245
252
|
if (positionals.length) throw new Error(`Unexpected argument: ${positionals[0]}`);
|
|
246
253
|
if (!values.model) throw new Error("--model is required");
|
|
254
|
+
if (values.input && values.file) throw new Error("Pass --input or --file, not both");
|
|
247
255
|
let text;
|
|
248
256
|
let source;
|
|
249
|
-
if (values.file && values.file !== "-") {
|
|
257
|
+
if (!values.input && values.file && values.file !== "-") {
|
|
250
258
|
const { readFile } = await import("node:fs/promises");
|
|
251
259
|
text = await readFile(values.file, "utf8");
|
|
252
260
|
source = values.file;
|
|
253
|
-
} else {
|
|
261
|
+
} else if (!values.input) {
|
|
254
262
|
text = await readStdinIfPiped();
|
|
255
263
|
source = "stdin";
|
|
256
264
|
if (!text) throw new Error("No requests: pass --file reqs.jsonl or pipe JSONL on stdin");
|
|
257
265
|
}
|
|
258
|
-
const requests = parseRequests(text, source);
|
|
266
|
+
const requests = values.input ? null : parseRequests(text, source);
|
|
259
267
|
|
|
260
268
|
let provider = values.provider ? await loadJson(values.provider, "--provider") : undefined;
|
|
261
269
|
if (values.only || values["no-fallbacks"]) provider = { ...(provider || {}) };
|
|
@@ -268,10 +276,12 @@ export async function batchesCommand(argv) {
|
|
|
268
276
|
if (provider) body.provider = provider;
|
|
269
277
|
if (values["completion-window"]) body.completion_window = values["completion-window"];
|
|
270
278
|
if (values["callback-url"]) body.callback_url = values["callback-url"];
|
|
271
|
-
body.
|
|
279
|
+
if (values.input) body.input = { uri: values.input };
|
|
280
|
+
else body.requests = requests;
|
|
272
281
|
const data = await api("POST", "/batches", { auth: authFromValues(values), body });
|
|
273
282
|
printBatch(data);
|
|
274
|
-
|
|
283
|
+
const what = requests ? `${requests.length} request(s)` : values.input;
|
|
284
|
+
info(`Submitted ${what}. Next: openrouter batches wait ${data.id}`);
|
|
275
285
|
return 0;
|
|
276
286
|
}
|
|
277
287
|
|
|
@@ -295,7 +305,24 @@ export async function batchesCommand(argv) {
|
|
|
295
305
|
const start = Date.now();
|
|
296
306
|
let last;
|
|
297
307
|
while (true) {
|
|
298
|
-
const
|
|
308
|
+
const left = timeout - (Date.now() - start);
|
|
309
|
+
if (left <= 0) throw new Error("timeout waiting for batch");
|
|
310
|
+
let data;
|
|
311
|
+
// A plain timer, not AbortSignal.timeout: that one does not keep the
|
|
312
|
+
// event loop alive, so a hung poll could exit before the deadline fires.
|
|
313
|
+
const controller = new AbortController();
|
|
314
|
+
const timer = setTimeout(
|
|
315
|
+
() => controller.abort(new DOMException("deadline reached", "TimeoutError")),
|
|
316
|
+
left,
|
|
317
|
+
);
|
|
318
|
+
try {
|
|
319
|
+
data = await getBatch(positionals[0], values, controller.signal);
|
|
320
|
+
} catch (err) {
|
|
321
|
+
if (err && err.name === "TimeoutError") throw new Error("timeout waiting for batch");
|
|
322
|
+
throw err;
|
|
323
|
+
} finally {
|
|
324
|
+
clearTimeout(timer);
|
|
325
|
+
}
|
|
299
326
|
const status = data.status;
|
|
300
327
|
const line = `status: ${status} (${counts(data)} completed/failed/total)`;
|
|
301
328
|
if (line !== last) info(line);
|
|
@@ -304,8 +331,7 @@ export async function batchesCommand(argv) {
|
|
|
304
331
|
printBatch(data);
|
|
305
332
|
return FAILED_STATUSES.includes(status) ? 4 : 0;
|
|
306
333
|
}
|
|
307
|
-
|
|
308
|
-
await sleep(interval);
|
|
334
|
+
await sleep(Math.min(interval, timeout - (Date.now() - start)));
|
|
309
335
|
}
|
|
310
336
|
}
|
|
311
337
|
|
|
@@ -355,6 +381,12 @@ export async function batchesCommand(argv) {
|
|
|
355
381
|
err,
|
|
356
382
|
);
|
|
357
383
|
}
|
|
384
|
+
if (err instanceof APIError && err.status === 404) {
|
|
385
|
+
throw new APIError(
|
|
386
|
+
`${err.message}\nEither the batch id is wrong (check: openrouter batches get ${id}) or the route is gone: OpenRouter dropped POST /batches/{id}/cancel from its API in Nov 2026. Let the batch finish, then: openrouter batches delete ${id}`,
|
|
387
|
+
err,
|
|
388
|
+
);
|
|
389
|
+
}
|
|
358
390
|
if (err instanceof APIError && err.status === 409) {
|
|
359
391
|
throw new APIError(
|
|
360
392
|
`${err.message}\nThe batch already ended, has not reached the provider yet, or runs on a provider without a cancel call. Check it: openrouter batches get ${id}`,
|
package/src/commands/chat.js
CHANGED
|
@@ -5,12 +5,13 @@ import {
|
|
|
5
5
|
authFromValues,
|
|
6
6
|
numberOption,
|
|
7
7
|
shouldStream,
|
|
8
|
+
readStdinText,
|
|
8
9
|
loadJson,
|
|
9
10
|
REQUEST_FIELD_OPTIONS,
|
|
10
11
|
REQUEST_FIELD_HELP,
|
|
11
12
|
applyRequestFields,
|
|
12
13
|
} from "../args.js";
|
|
13
|
-
import { api, assertNoStreamError, sseStream } from "../api.js";
|
|
14
|
+
import { api, assertNoResponseError, assertNoStreamError, sseStream } from "../api.js";
|
|
14
15
|
import { c, info, isJsonMode, out, outln, printJSON } from "../output.js";
|
|
15
16
|
|
|
16
17
|
const DEFAULT_MODEL = "openrouter/auto";
|
|
@@ -251,9 +252,7 @@ ${REQUEST_FIELD_HELP} --extra <json|@file> Extra fields merged into the req
|
|
|
251
252
|
|
|
252
253
|
async function readStdinIfPiped() {
|
|
253
254
|
if (stdin.isTTY) return null;
|
|
254
|
-
|
|
255
|
-
for await (const chunk of stdin) data += chunk;
|
|
256
|
-
return data.trimEnd() || null;
|
|
255
|
+
return (await readStdinText()).trimEnd() || null;
|
|
257
256
|
}
|
|
258
257
|
|
|
259
258
|
// loadJson plus chat's older convenience: a bare value that names a file is
|
|
@@ -648,8 +647,12 @@ export async function chatCommand(argv) {
|
|
|
648
647
|
|
|
649
648
|
if (!shouldStream(values)) {
|
|
650
649
|
const rcHeaders = values["response-cache"] ? { "X-OpenRouter-Cache": "true" } : undefined;
|
|
650
|
+
// Checked inside withAlignmentErrors so an HTTP 200 alignment block
|
|
651
|
+
// still gets the alignment hint.
|
|
651
652
|
const data = await withAlignmentErrors(
|
|
652
|
-
api("POST", "/chat/completions", { auth, body, headers: rcHeaders })
|
|
653
|
+
api("POST", "/chat/completions", { auth, body, headers: rcHeaders }).then(
|
|
654
|
+
assertNoResponseError,
|
|
655
|
+
),
|
|
653
656
|
);
|
|
654
657
|
if (isJsonMode() || values.raw) {
|
|
655
658
|
printJSON(data);
|
package/src/commands/login.js
CHANGED
|
@@ -3,7 +3,7 @@ import crypto from "node:crypto";
|
|
|
3
3
|
import { spawn } from "node:child_process";
|
|
4
4
|
import readline from "node:readline/promises";
|
|
5
5
|
import { stdin, stdout } from "node:process";
|
|
6
|
-
import { parseArgs, numberOption } from "../args.js";
|
|
6
|
+
import { parseArgs, numberOption, readStdinText } from "../args.js";
|
|
7
7
|
import {
|
|
8
8
|
loadConfig,
|
|
9
9
|
saveConfig,
|
|
@@ -67,9 +67,7 @@ function openBrowser(url) {
|
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
async function readFromStdin() {
|
|
70
|
-
|
|
71
|
-
for await (const chunk of stdin) data += chunk;
|
|
72
|
-
return data.trim();
|
|
70
|
+
return (await readStdinText()).trim();
|
|
73
71
|
}
|
|
74
72
|
|
|
75
73
|
async function promptKey() {
|
package/src/commands/messages.js
CHANGED
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
REQUEST_FIELD_HELP,
|
|
10
10
|
applyRequestFields,
|
|
11
11
|
} from "../args.js";
|
|
12
|
-
import { api, assertNoStreamError, sseStream } from "../api.js";
|
|
12
|
+
import { api, assertNoResponseError, assertNoStreamError, sseStream } from "../api.js";
|
|
13
13
|
import { c, info, isJsonMode, out, outln, printJSON } from "../output.js";
|
|
14
14
|
import {
|
|
15
15
|
SHARED_OPTIONS,
|
|
@@ -86,7 +86,7 @@ ${ALIGNMENT_HELP} --metadata <json|@file> String key/value pairs (max 16)
|
|
|
86
86
|
--tool <json|@file> Tool definition (repeatable). Function tools can
|
|
87
87
|
carry "defer_loading": true
|
|
88
88
|
--tool-choice <v> auto | none | required | <tool name>
|
|
89
|
-
${SERVER_TOOL_HELP} --include <csv> Extra output fields to include
|
|
89
|
+
${SERVER_TOOL_HELP} --include <csv> Extra output fields to include (e.g. web_search_call.action.sources)
|
|
90
90
|
--store Persist the response server-side
|
|
91
91
|
--previous-response-id <id> Continue a stored response
|
|
92
92
|
--background Run as a background response
|
|
@@ -277,11 +277,13 @@ export async function messagesCommand(argv) {
|
|
|
277
277
|
return 0;
|
|
278
278
|
}
|
|
279
279
|
|
|
280
|
+
// Checked inside withAlignmentErrors so an HTTP 200 alignment block
|
|
281
|
+
// still gets the alignment hint.
|
|
280
282
|
const data = await withAlignmentErrors(
|
|
281
283
|
api("POST", "/messages", {
|
|
282
284
|
auth: authFromValues(values),
|
|
283
285
|
body,
|
|
284
|
-
}),
|
|
286
|
+
}).then(assertNoResponseError),
|
|
285
287
|
);
|
|
286
288
|
if (isJsonMode() || values.raw) {
|
|
287
289
|
printJSON(data);
|
|
@@ -429,11 +431,13 @@ export async function responsesCommand(argv) {
|
|
|
429
431
|
return 0;
|
|
430
432
|
}
|
|
431
433
|
|
|
434
|
+
// Checked inside withAlignmentErrors so an HTTP 200 alignment block
|
|
435
|
+
// still gets the alignment hint.
|
|
432
436
|
const data = await withAlignmentErrors(
|
|
433
437
|
api("POST", "/responses", {
|
|
434
438
|
auth: authFromValues(values),
|
|
435
439
|
body,
|
|
436
|
-
}),
|
|
440
|
+
}).then(assertNoResponseError),
|
|
437
441
|
);
|
|
438
442
|
if (isJsonMode() || values.raw) {
|
|
439
443
|
printJSON(data);
|
package/src/commands/models.js
CHANGED
|
@@ -11,6 +11,29 @@ import { c, isJsonMode, outln, pricePerMillion, printResult, table } from "../ou
|
|
|
11
11
|
const ENDPOINT_SORT_FIELDS = ["throughput", "latency", "prompt", "completion", "uptime", "context"];
|
|
12
12
|
const MODEL_SORT_FIELDS = ["id", "name", "context", "prompt", "completion"];
|
|
13
13
|
|
|
14
|
+
// Artificial Analysis index filters: --min-<name>-index / --max-<name>-index (0-100).
|
|
15
|
+
const AA_INDEXES = [
|
|
16
|
+
"intelligence",
|
|
17
|
+
"coding",
|
|
18
|
+
"agentic",
|
|
19
|
+
"cyber",
|
|
20
|
+
"decision",
|
|
21
|
+
"economics",
|
|
22
|
+
"engineering",
|
|
23
|
+
"finance-and-accounting",
|
|
24
|
+
"healthcare-and-medical",
|
|
25
|
+
"legal",
|
|
26
|
+
"multilingual",
|
|
27
|
+
"openness",
|
|
28
|
+
"strategy-and-ops",
|
|
29
|
+
];
|
|
30
|
+
const INDEX_FLAGS = AA_INDEXES.flatMap((name) =>
|
|
31
|
+
["min", "max"].map((bound) => [
|
|
32
|
+
`${bound}-${name}-index`,
|
|
33
|
+
`${bound}_${name.replaceAll("-", "_")}_index`,
|
|
34
|
+
]),
|
|
35
|
+
);
|
|
36
|
+
|
|
14
37
|
const PRICE_COLUMN = {
|
|
15
38
|
label: "in/out $/M",
|
|
16
39
|
value: (x) => {
|
|
@@ -50,6 +73,14 @@ Options for list:
|
|
|
50
73
|
--providers <csv> Hosting provider names
|
|
51
74
|
--distillable <true|false> Filter by distillation capability
|
|
52
75
|
--zdr Only models with ZDR endpoints
|
|
76
|
+
--min-<name>-index <n> Artificial Analysis index score bounds (0-100;
|
|
77
|
+
--max-<name>-index <n> unscored models are excluded). <name>:
|
|
78
|
+
intelligence|coding|agentic|cyber|decision|
|
|
79
|
+
economics|engineering|finance-and-accounting|
|
|
80
|
+
healthcare-and-medical|legal|multilingual|
|
|
81
|
+
openness|strategy-and-ops
|
|
82
|
+
--min-tool-success-rate <n>, --max-tool-success-rate <n>
|
|
83
|
+
--min-age-days <n>, --max-age-days <n>
|
|
53
84
|
--endpoints <csv> Only models served on every listed API path, e.g.
|
|
54
85
|
/api/v1/messages or /api/alpha/extractions
|
|
55
86
|
(without --output-modalities: every modality)
|
|
@@ -81,12 +112,7 @@ function listQuery(values) {
|
|
|
81
112
|
["max-output-price", "max_output_price"],
|
|
82
113
|
["min-age-days", "min_age_days"],
|
|
83
114
|
["max-age-days", "max_age_days"],
|
|
84
|
-
|
|
85
|
-
["max-intelligence-index", "max_intelligence_index"],
|
|
86
|
-
["min-coding-index", "min_coding_index"],
|
|
87
|
-
["max-coding-index", "max_coding_index"],
|
|
88
|
-
["min-agentic-index", "min_agentic_index"],
|
|
89
|
-
["max-agentic-index", "max_agentic_index"],
|
|
115
|
+
...INDEX_FLAGS,
|
|
90
116
|
["min-tool-success-rate", "min_tool_success_rate"],
|
|
91
117
|
["max-tool-success-rate", "max_tool_success_rate"],
|
|
92
118
|
];
|
|
@@ -124,12 +150,7 @@ const LIST_OPTIONS = {
|
|
|
124
150
|
endpoints: { type: "string" },
|
|
125
151
|
"min-age-days": { type: "string" },
|
|
126
152
|
"max-age-days": { type: "string" },
|
|
127
|
-
|
|
128
|
-
"max-intelligence-index": { type: "string" },
|
|
129
|
-
"min-coding-index": { type: "string" },
|
|
130
|
-
"max-coding-index": { type: "string" },
|
|
131
|
-
"min-agentic-index": { type: "string" },
|
|
132
|
-
"max-agentic-index": { type: "string" },
|
|
153
|
+
...Object.fromEntries(INDEX_FLAGS.map(([flag]) => [flag, { type: "string" }])),
|
|
133
154
|
"min-tool-success-rate": { type: "string" },
|
|
134
155
|
"max-tool-success-rate": { type: "string" },
|
|
135
156
|
};
|
|
@@ -35,6 +35,8 @@ 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
|
+
otel-collector can also send OTLP metrics:
|
|
39
|
+
"shouldSendMetrics": true, "metricsEndpoint": "<url>".
|
|
38
40
|
For s3, key auth: {"accessKeyId":"...",
|
|
39
41
|
"secretAccessKey":"...",...} or IAM role auth:
|
|
40
42
|
{"authMode":"iam_role","provider":"aws",
|
package/src/commands/request.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { parseArgs, authFromValues } from "../args.js";
|
|
1
|
+
import { parseArgs, authFromValues, readStdinText } from "../args.js";
|
|
3
2
|
import { api } from "../api.js";
|
|
4
3
|
import { printJSON, out } from "../output.js";
|
|
5
4
|
|
|
@@ -20,14 +19,8 @@ Options:
|
|
|
20
19
|
--raw Print raw text response (no JSON parsing)
|
|
21
20
|
`;
|
|
22
21
|
|
|
23
|
-
async function readStdin() {
|
|
24
|
-
let data = "";
|
|
25
|
-
for await (const chunk of stdin) data += chunk;
|
|
26
|
-
return data;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
22
|
async function loadBody(value) {
|
|
30
|
-
if (value === "-") return JSON.parse(await
|
|
23
|
+
if (value === "-") return JSON.parse(await readStdinText());
|
|
31
24
|
if (value.startsWith("@")) {
|
|
32
25
|
const { readFile } = await import("node:fs/promises");
|
|
33
26
|
return JSON.parse(await readFile(value.slice(1), "utf8"));
|
package/src/commands/rerank.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { stdin } from "node:process";
|
|
2
1
|
import {
|
|
3
2
|
parseArgs,
|
|
4
3
|
authFromValues,
|
|
4
|
+
readStdinText,
|
|
5
5
|
numberOption,
|
|
6
6
|
loadJson,
|
|
7
7
|
applyRequestFields,
|
|
@@ -29,8 +29,7 @@ Options:
|
|
|
29
29
|
${MEDIA_FIELD_HELP}`;
|
|
30
30
|
|
|
31
31
|
async function readDocsFromStdin() {
|
|
32
|
-
|
|
33
|
-
for await (const chunk of stdin) data += chunk;
|
|
32
|
+
const data = await readStdinText();
|
|
34
33
|
return data
|
|
35
34
|
.split(/\r?\n/)
|
|
36
35
|
.map((l) => l.trim())
|
|
@@ -24,6 +24,8 @@ Options:
|
|
|
24
24
|
some providers only)
|
|
25
25
|
--language <code> ISO-639-1 language hint (e.g. en)
|
|
26
26
|
--temperature <n>
|
|
27
|
+
--prompt <text> Context to guide transcription (providers with
|
|
28
|
+
contextual prompting; beats provider prompt options)
|
|
27
29
|
--format <fmt> response_format: json | verbose_json (default: json;
|
|
28
30
|
verbose_json when --diarize or --timestamps is set)
|
|
29
31
|
--timestamps <l> word,segment (timestamp_granularities, verbose_json only)
|
|
@@ -83,6 +85,7 @@ export async function transcribeCommand(argv) {
|
|
|
83
85
|
url: { type: "string" },
|
|
84
86
|
language: { type: "string" },
|
|
85
87
|
temperature: { type: "string" },
|
|
88
|
+
prompt: { type: "string" },
|
|
86
89
|
format: { type: "string" },
|
|
87
90
|
timestamps: { type: "string", multiple: true },
|
|
88
91
|
diarize: { type: "boolean" },
|
|
@@ -123,6 +126,7 @@ export async function transcribeCommand(argv) {
|
|
|
123
126
|
if (values.language) form.append("language", values.language);
|
|
124
127
|
if (values.temperature !== undefined && values.temperature !== "")
|
|
125
128
|
form.append("temperature", String(numberOption(values.temperature, "--temperature")));
|
|
129
|
+
if (values.prompt !== undefined) form.append("prompt", values.prompt);
|
|
126
130
|
if (format) form.append("response_format", format);
|
|
127
131
|
for (const t of timestamps) form.append("timestamp_granularities[]", t);
|
|
128
132
|
if (values.diarize) form.append("diarize", "true");
|