@aaronjmars/openroutercli 0.1.6 → 0.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/README.md CHANGED
@@ -207,3 +207,7 @@ This is an **unofficial** community project. It is not affiliated with,
207
207
  endorsed by, or sponsored by OpenRouter. "OpenRouter" and the OpenRouter
208
208
  logo are trademarks of their respective owners; usage here is for
209
209
  identification only.
210
+
211
+ ---
212
+
213
+ Built by [Aaron Elijah Mars](https://aaronjmars.com), founder of Aeon and MiroShark · [@aaronjmars](https://github.com/aaronjmars)
package/SKILL.md CHANGED
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: openrouter-cli
3
- description: Use the `openrouter` CLI to call any OpenRouter API endpoint from the shell - chat / messages / responses, embeddings, rerank, audio, video, model + provider discovery, generation lookup, credits, activity, and full key / guardrail / workspace management. Pass `--json` on every command for machine-parseable output.
3
+ description: Use the `openrouter` CLI to call any OpenRouter API endpoint from the shell - chat / messages / responses (with web search, PDF input, prompt caching, reasoning budgets, tools), embeddings, rerank, text-to-speech, speech-to-text, image + video generation, model + provider discovery, generation lookup, credits, activity, and full key / BYOK / guardrail / workspace / files / presets management. Pass `--json` on every command for machine-parseable output.
4
4
  ---
5
5
 
6
6
  # openrouter-cli skill
@@ -18,8 +18,12 @@ TRIGGER when the user asks to:
18
18
  - check credits, per-key spend, daily/weekly/monthly usage, or rate limits
19
19
  - inspect or audit a specific generation (`gen-...` id) - input, output, cost,
20
20
  latency, finish reason
21
+ - run chat with web search, a PDF/file attachment, prompt caching, a reasoning
22
+ budget, tools, or structured output
23
+ - generate an image, transcribe audio to text (STT), or synthesize speech (TTS)
21
24
  - create / list / disable / delete OpenRouter API keys programmatically
22
- - manage guardrails, workspaces, or organization members
25
+ - manage BYOK provider integrations, guardrails, workspaces, files, presets, or
26
+ organization members
23
27
  - log in to OpenRouter from a fresh machine (OAuth PKCE in the browser)
24
28
 
25
29
  SKIP when the user is already using the OpenAI / Anthropic / Cohere SDKs
@@ -72,8 +76,8 @@ command automatically.
72
76
 
73
77
  | Slot | Used by | How to obtain |
74
78
  | --- | --- | --- |
75
- | **User key** | `chat`, `messages`, `responses`, `embed`, `rerank`, `speech`, `video`, `generation`, `credits`, `whoami` | OAuth (`openrouter login`) or paste from dashboard |
76
- | **Management key** | `keys`, `guardrails`, `workspaces`, `activity`, `org members`, `auth-code` | Dashboard only - <https://openrouter.ai/settings/provisioning-keys>. Cannot be obtained via OAuth. Save with `openrouter login --management`. |
79
+ | **User key** | `chat`, `messages`, `responses`, `embed`, `rerank`, `speech`, `transcribe`, `image`, `video`, `files`, `presets`, `generation`, `credits`, `whoami` | OAuth (`openrouter login`) or paste from dashboard |
80
+ | **Management key** | `keys`, `byok`, `guardrails`, `workspaces`, `activity`, `org members`, `auth-code` | Dashboard only - <https://openrouter.ai/settings/provisioning-keys>. Cannot be obtained via OAuth. Save with `openrouter login --management`. |
77
81
 
78
82
  You can store both - they live side by side in the config file. `--key sk-or-...`
79
83
  always wins over both. Inference commands prefer the user key; management
@@ -129,8 +133,26 @@ openrouter chat "What is 2+2?" -m openai/gpt-4o-mini \
129
133
  --tool '{"name":"add","parameters":{"type":"object","properties":{"a":{"type":"number"},"b":{"type":"number"}},"required":["a","b"]}}' \
130
134
  --tool-choice required --raw
131
135
 
132
- # Reasoning effort
136
+ # Reasoning: effort level, an explicit token budget, or reason-but-hide
133
137
  openrouter chat "tricky question" -m anthropic/claude-sonnet-4.5 --reasoning high
138
+ openrouter chat "prove it" -m openai/gpt-5-mini --reasoning-max-tokens 2000
139
+ openrouter chat "quick" -m openai/gpt-5-mini --reasoning-exclude
140
+
141
+ # Web search plugin (also works via the :online model suffix)
142
+ openrouter chat "what shipped in the news today?" -m openai/gpt-4o-mini --web --web-max-results 3
143
+
144
+ # Attach a PDF / file and parse it
145
+ openrouter chat "summarize this" -m google/gemini-2.5-flash --file ./report.pdf --pdf-engine mistral-ocr
146
+
147
+ # Prompt caching: mark the system (or user) prompt as a cache breakpoint
148
+ openrouter chat "answer from the doc" -m anthropic/claude-sonnet-4.5 -s "$(cat big-context.txt)" --cache-system
149
+
150
+ # Sampling / output controls
151
+ openrouter chat "..." -m openai/gpt-4o-mini --top-a 0.2 --logprobs --top-logprobs 5
152
+
153
+ # Escape hatch: merge extra body fields, or send a fully-formed body
154
+ openrouter chat "..." -m openai/gpt-4o-mini --extra '{"transforms":["middle-out"]}'
155
+ openrouter chat --body @request.json
134
156
 
135
157
  # Provider routing / fallback models
136
158
  openrouter chat "..." -m primary/model --models fallback1/m,fallback2/m
@@ -141,13 +163,19 @@ openrouter chat -i -m openrouter/auto
141
163
  # Inside the REPL: /model <id>, /reset, /exit
142
164
 
143
165
  # Anthropic-format and OpenAI Responses API are also available
144
- openrouter messages "..." -m anthropic/claude-sonnet-4.5
145
- openrouter responses "..." -m openai/gpt-4o-mini
166
+ openrouter messages "..." -m anthropic/claude-sonnet-4.5 --thinking-budget 2000
167
+ openrouter responses "..." -m openai/gpt-4o-mini --store --include reasoning.encrypted_content
146
168
 
147
- # Embeddings, rerank, TTS, video
169
+ # Embeddings, rerank
148
170
  openrouter embed -m openai/text-embedding-3-small "hello" "world"
149
171
  openrouter rerank -m cohere/rerank-v3.5 --query "italian food" -d pizza -d sushi -d pasta
172
+
173
+ # Text to speech (audio out) and speech to text (audio in)
150
174
  openrouter speech "Hello there" -m elevenlabs/eleven-turbo-v2 --voice alloy -o out.mp3
175
+ openrouter transcribe ./clip.wav -m openai/gpt-4o-transcribe # alias: stt
176
+
177
+ # Image generation (writes image-0.png, ...); and video jobs
178
+ openrouter image "a red bike on a beach" -m google/gemini-2.5-flash-image -o bike.png
151
179
  openrouter video create "a sunset over mountains" -m google/veo-3
152
180
  openrouter video wait <jobId> && openrouter video download <jobId> -o out.mp4
153
181
  ```
@@ -156,16 +184,22 @@ openrouter video wait <jobId> && openrouter video download <jobId> -o out.mp4
156
184
 
157
185
  ```bash
158
186
  # Browse / filter / sort the catalog
159
- openrouter models # all (~370)
160
- openrouter models --filter sonnet --sort prompt # cheapest first
187
+ openrouter models # all (~430)
188
+ openrouter models --filter sonnet --sort prompt # local sort, cheapest first
189
+ openrouter models --order intelligence-high-to-low # server-side ranking
161
190
  openrouter models --free # only :free models
162
- openrouter models --output-modalities image # image-output models
191
+ openrouter models --input-modalities image # image-INPUT (vision) models
192
+ openrouter models --output-modalities image # image-OUTPUT models
163
193
  openrouter models --supported tools # filter by capability
164
194
 
165
- # Full detail for one model: pricing breakdown, architecture, supported params
195
+ # Full detail for one model: pricing breakdown, architecture, supported params,
196
+ # reasoning config, supported voices
166
197
  openrouter models show anthropic/claude-sonnet-4.5
167
198
 
168
- # Compare provider variants for one model - find the best one
199
+ # Supported params + popularity analytics (p10/p50/p90 per parameter)
200
+ openrouter models parameters openai/gpt-4o --provider openai
201
+
202
+ # Compare provider variants for one model - find the best one (status column too)
169
203
  openrouter models endpoints anthropic/claude-sonnet-4.5 --sort throughput --best
170
204
  openrouter models endpoints openai/gpt-4o-mini --sort latency
171
205
  openrouter models endpoints openai/gpt-4o-mini --sort prompt
@@ -173,6 +207,7 @@ openrouter models endpoints openai/gpt-4o-mini --sort prompt
173
207
  # Supporting metadata
174
208
  openrouter providers # all providers
175
209
  openrouter embed models # embedding models
210
+ openrouter image models # image gen models
176
211
  openrouter video models # video gen models
177
212
  openrouter zdr # ZDR-eligible endpoints
178
213
  ```
@@ -217,7 +252,7 @@ response - capture it then.
217
252
  ```bash
218
253
  openrouter guardrails list
219
254
  openrouter guardrails create "no-paid-models" --allowed-providers "" --enforce-zdr
220
- openrouter guardrails update <id> --limit-usd 10 --reset-interval daily
255
+ openrouter guardrails update <id> --limit-usd 10 --reset-interval daily --include-byok
221
256
  openrouter guardrails assign-key <id> <key-hash>
222
257
  openrouter guardrails delete <id>
223
258
 
@@ -229,6 +264,36 @@ openrouter workspaces delete <id|slug>
229
264
  openrouter org members
230
265
  ```
231
266
 
267
+ ### BYOK provider integrations (management key required)
268
+
269
+ Bring-your-own-key: register upstream provider secrets so OpenRouter routes
270
+ through your own provider accounts.
271
+
272
+ ```bash
273
+ openrouter byok list
274
+ openrouter byok create --provider anthropic --api-key sk-ant-... --name "my anthropic" --fallback
275
+ openrouter byok update <id> --allowed-models "anthropic/claude-sonnet-4.5" --disabled
276
+ openrouter byok get <id>
277
+ openrouter byok delete <id>
278
+ ```
279
+
280
+ The `--api-key` flag is the upstream provider secret (never echoed back).
281
+
282
+ ### Files, presets (user key)
283
+
284
+ ```bash
285
+ # Files - backing store for file/PDF inputs
286
+ openrouter files upload ./report.pdf --purpose user_data
287
+ openrouter files list
288
+ openrouter files download <file_id> -o report.pdf
289
+ openrouter files delete <file_id>
290
+
291
+ # Presets - saved config profiles (read-only). Invoke via @preset/<slug> as a model.
292
+ openrouter presets list
293
+ openrouter presets get <slug>
294
+ openrouter presets versions <slug>
295
+ ```
296
+
232
297
  ### Raw escape hatch
233
298
 
234
299
  For any endpoint that doesn't have a first-class subcommand yet (or new
package/bin/openrouter.js CHANGED
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env node
2
- import { run } from '../src/cli.js';
2
+ import { run } from "../src/cli.js";
3
3
 
4
4
  run(process.argv.slice(2)).catch((err) => {
5
5
  const msg = err && err.message ? err.message : String(err);
6
6
  process.stderr.write(`error: ${msg}\n`);
7
7
  if (process.env.OPENROUTER_DEBUG && err && err.stack) {
8
- process.stderr.write(err.stack + '\n');
8
+ process.stderr.write(err.stack + "\n");
9
9
  }
10
- process.exit(err && typeof err.exitCode === 'number' ? err.exitCode : 1);
10
+ process.exit(err && typeof err.exitCode === "number" ? err.exitCode : 1);
11
11
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aaronjmars/openroutercli",
3
- "version": "0.1.6",
3
+ "version": "0.2.1",
4
4
  "description": "Command-line interface for the OpenRouter API. Built for humans and LLM agents.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -50,6 +50,11 @@
50
50
  "access": "public"
51
51
  },
52
52
  "scripts": {
53
- "start": "node bin/openrouter.js"
53
+ "start": "node bin/openrouter.js",
54
+ "format": "biome format --write .",
55
+ "format:check": "biome ci ."
56
+ },
57
+ "devDependencies": {
58
+ "@biomejs/biome": "^2.5.12"
54
59
  }
55
60
  }
package/src/api.js CHANGED
@@ -1,9 +1,9 @@
1
- import { resolveAuth } from './config.js';
1
+ import { resolveAuth } from "./config.js";
2
2
 
3
3
  export class APIError extends Error {
4
4
  constructor(message, { status, body } = {}) {
5
5
  super(message);
6
- this.name = 'APIError';
6
+ this.name = "APIError";
7
7
  this.status = status;
8
8
  this.body = body;
9
9
  this.exitCode = 2;
@@ -12,9 +12,9 @@ export class APIError extends Error {
12
12
 
13
13
  function buildHeaders({ apiKey, referer, title, extra }) {
14
14
  const headers = {
15
- Accept: 'application/json',
16
- 'HTTP-Referer': referer,
17
- 'X-Title': title
15
+ Accept: "application/json",
16
+ "HTTP-Referer": referer,
17
+ "X-Title": title,
18
18
  };
19
19
  if (apiKey) headers.Authorization = `Bearer ${apiKey}`;
20
20
  return { ...headers, ...(extra || {}) };
@@ -22,7 +22,7 @@ function buildHeaders({ apiKey, referer, title, extra }) {
22
22
 
23
23
  function joinUrl(base, path) {
24
24
  if (/^https?:\/\//i.test(path)) return path;
25
- return base.replace(/\/$/, '') + (path.startsWith('/') ? path : '/' + path);
25
+ return base.replace(/\/$/, "") + (path.startsWith("/") ? path : "/" + path);
26
26
  }
27
27
 
28
28
  async function parseError(res) {
@@ -33,10 +33,10 @@ async function parseError(res) {
33
33
  } catch {}
34
34
  const message =
35
35
  (body && body.error && body.error.message) ||
36
- (typeof body === 'string' ? body : `HTTP ${res.status}`);
36
+ (typeof body === "string" ? body : `HTTP ${res.status}`);
37
37
  throw new APIError(`${res.status} ${res.statusText}: ${message}`, {
38
38
  status: res.status,
39
- body
39
+ body,
40
40
  });
41
41
  }
42
42
 
@@ -46,28 +46,40 @@ export async function api(method, path, opts = {}) {
46
46
  const auth = await resolveAuth(authOpts);
47
47
  if (opts.requireAuth !== false && !auth.apiKey) {
48
48
  const msg = opts.requiresManagement
49
- ? 'No API key set. This command needs a management key. Run `openrouter login --management` or set OPENROUTER_MANAGEMENT_KEY.'
50
- : 'No API key set. Run `openrouter login` or `openrouter login --key sk-or-...`, or set OPENROUTER_API_KEY.';
49
+ ? "No API key set. This command needs a management key. Run `openrouter login --management` or set OPENROUTER_MANAGEMENT_KEY."
50
+ : "No API key set. Run `openrouter login` or `openrouter login --key sk-or-...`, or set OPENROUTER_API_KEY.";
51
51
  const e = new Error(msg);
52
52
  e.exitCode = 3;
53
53
  throw e;
54
54
  }
55
55
 
56
- const url = joinUrl(auth.baseUrl, path) + (opts.query ? '?' + new URLSearchParams(opts.query).toString() : '');
56
+ const url =
57
+ joinUrl(auth.baseUrl, path) +
58
+ (opts.query ? "?" + new URLSearchParams(opts.query).toString() : "");
57
59
  const headers = buildHeaders({
58
60
  apiKey: auth.apiKey,
59
61
  referer: auth.referer,
60
62
  title: auth.title,
61
- extra: opts.headers
63
+ extra: opts.headers,
62
64
  });
63
65
 
64
66
  let body;
65
67
  if (opts.body !== undefined) {
66
- if (opts.body instanceof Uint8Array || typeof opts.body === 'string') {
68
+ // Pass raw byte/string/streaming bodies straight through. FormData in
69
+ // particular must reach fetch untouched so it can set the multipart
70
+ // Content-Type (with boundary) itself.
71
+ const raw =
72
+ opts.body instanceof Uint8Array ||
73
+ typeof opts.body === "string" ||
74
+ (typeof FormData !== "undefined" && opts.body instanceof FormData) ||
75
+ (typeof Blob !== "undefined" && opts.body instanceof Blob) ||
76
+ opts.body instanceof ArrayBuffer ||
77
+ opts.body instanceof URLSearchParams;
78
+ if (raw) {
67
79
  body = opts.body;
68
80
  } else {
69
81
  body = JSON.stringify(opts.body);
70
- headers['Content-Type'] = 'application/json';
82
+ headers["Content-Type"] = "application/json";
71
83
  }
72
84
  }
73
85
 
@@ -75,7 +87,7 @@ export async function api(method, path, opts = {}) {
75
87
  method: method.toUpperCase(),
76
88
  headers,
77
89
  body,
78
- signal: opts.signal
90
+ signal: opts.signal,
79
91
  });
80
92
 
81
93
  if (!res.ok) await parseError(res);
@@ -96,31 +108,30 @@ export async function api(method, path, opts = {}) {
96
108
  // non-2xx status, so nothing above this catches them.
97
109
  export function assertNoStreamError(evt) {
98
110
  if (!evt) return;
99
- const err = evt.error ?? (evt.type === 'error' ? evt : null);
111
+ const err = evt.error ?? (evt.type === "error" ? evt : null);
100
112
  if (!err) return;
101
- const message =
102
- (typeof err === 'string' ? err : err.message) || JSON.stringify(err);
113
+ const message = (typeof err === "string" ? err : err.message) || JSON.stringify(err);
103
114
  throw new APIError(`stream error: ${message}`);
104
115
  }
105
116
 
106
117
  export async function* sseStream(res) {
107
118
  if (!res.body) return;
108
119
  const reader = res.body.getReader();
109
- const decoder = new TextDecoder('utf8');
110
- let buffer = '';
120
+ const decoder = new TextDecoder("utf8");
121
+ let buffer = "";
111
122
  while (true) {
112
123
  const { value, done } = await reader.read();
113
124
  if (done) break;
114
125
  buffer += decoder.decode(value, { stream: true });
115
126
  let idx;
116
- while ((idx = buffer.indexOf('\n')) !== -1) {
117
- const line = buffer.slice(0, idx).replace(/\r$/, '');
127
+ while ((idx = buffer.indexOf("\n")) !== -1) {
128
+ const line = buffer.slice(0, idx).replace(/\r$/, "");
118
129
  buffer = buffer.slice(idx + 1);
119
130
  if (!line) continue;
120
- if (line.startsWith(':')) continue; // SSE comment / keepalive
121
- if (line.startsWith('data:')) {
131
+ if (line.startsWith(":")) continue; // SSE comment / keepalive
132
+ if (line.startsWith("data:")) {
122
133
  const data = line.slice(5).trim();
123
- if (data === '[DONE]') return;
134
+ if (data === "[DONE]") return;
124
135
  try {
125
136
  yield JSON.parse(data);
126
137
  } catch {
package/src/args.js CHANGED
@@ -1,15 +1,15 @@
1
- import { parseArgs as nodeParseArgs } from 'node:util';
2
- import { stdin } from 'node:process';
3
- import { isJsonMode } from './output.js';
1
+ import { parseArgs as nodeParseArgs } from "node:util";
2
+ import { stdin } from "node:process";
3
+ import { isJsonMode } from "./output.js";
4
4
 
5
5
  const GLOBAL_OPTIONS = {
6
- key: { type: 'string', short: 'k' },
7
- 'base-url': { type: 'string' },
8
- referer: { type: 'string' },
9
- title: { type: 'string' },
10
- json: { type: 'boolean' },
11
- quiet: { type: 'boolean', short: 'q' },
12
- help: { type: 'boolean', short: 'h' }
6
+ key: { type: "string", short: "k" },
7
+ "base-url": { type: "string" },
8
+ referer: { type: "string" },
9
+ title: { type: "string" },
10
+ json: { type: "boolean" },
11
+ quiet: { type: "boolean", short: "q" },
12
+ help: { type: "boolean", short: "h" },
13
13
  };
14
14
 
15
15
  export function parseArgs(argv, options = {}) {
@@ -18,7 +18,7 @@ export function parseArgs(argv, options = {}) {
18
18
  args: argv,
19
19
  options: merged,
20
20
  allowPositionals: true,
21
- strict: true
21
+ strict: true,
22
22
  });
23
23
  }
24
24
 
@@ -28,15 +28,15 @@ export function parseArgs(argv, options = {}) {
28
28
  export function numberOption(value, flag) {
29
29
  if (value === undefined) return undefined;
30
30
  const n = Number(value);
31
- if (String(value).trim() === '' || !Number.isFinite(n)) {
31
+ if (String(value).trim() === "" || !Number.isFinite(n)) {
32
32
  throw new Error(`Invalid number for ${flag}: "${value}"`);
33
33
  }
34
34
  return n;
35
35
  }
36
36
 
37
37
  export const PAGINATION_OPTIONS = {
38
- offset: { type: 'string' },
39
- limit: { type: 'string' }
38
+ offset: { type: "string" },
39
+ limit: { type: "string" },
40
40
  };
41
41
 
42
42
  export function paginationQuery(values) {
@@ -49,7 +49,7 @@ export function paginationQuery(values) {
49
49
  export function authFromValues(values) {
50
50
  const out = {};
51
51
  if (values.key) out.key = values.key;
52
- if (values['base-url']) out.baseUrl = values['base-url'];
52
+ if (values["base-url"]) out.baseUrl = values["base-url"];
53
53
  if (values.referer) out.referer = values.referer;
54
54
  if (values.title) out.title = values.title;
55
55
  return out;
@@ -57,14 +57,13 @@ export function authFromValues(values) {
57
57
 
58
58
  export async function readStdinIfPiped() {
59
59
  if (stdin.isTTY) return null;
60
- let data = '';
60
+ let data = "";
61
61
  for await (const chunk of stdin) data += chunk;
62
62
  return data.trim() || null;
63
63
  }
64
64
 
65
65
  export function shouldStream(values) {
66
66
  return (
67
- values.stream ||
68
- (!values['no-stream'] && !values.raw && !isJsonMode() && process.stdout.isTTY)
67
+ values.stream || (!values["no-stream"] && !values.raw && !isJsonMode() && process.stdout.isTTY)
69
68
  );
70
69
  }
package/src/cli.js CHANGED
@@ -1,26 +1,31 @@
1
- import { setJsonMode, setQuiet, outln } from './output.js';
2
- import { loginCommand, logoutCommand } from './commands/login.js';
3
- import { whoamiCommand, creditsCommand, activityCommand } from './commands/account.js';
4
- import { modelsCommand, providersCommand } from './commands/models.js';
5
- import { chatCommand, completeCommand } from './commands/chat.js';
6
- import { embedCommand } from './commands/embed.js';
7
- import { rerankCommand } from './commands/rerank.js';
8
- import { speechCommand } from './commands/speech.js';
9
- import { videoCommand } from './commands/video.js';
10
- import { messagesCommand, responsesCommand } from './commands/messages.js';
11
- import { generationCommand } from './commands/generation.js';
12
- import { keysCommand } from './commands/keys.js';
13
- import { requestCommand } from './commands/request.js';
14
- import { guardrailsCommand } from './commands/guardrails.js';
15
- import { workspacesCommand } from './commands/workspaces.js';
16
- import { orgCommand, zdrCommand, authCodeCommand } from './commands/misc.js';
17
- import { DEFAULT_BASE_URL } from './config.js';
18
- import { readFileSync } from 'node:fs';
19
- import { fileURLToPath } from 'node:url';
20
- import { dirname, join } from 'node:path';
21
-
22
- const pkgPath = join(dirname(fileURLToPath(import.meta.url)), '..', 'package.json');
23
- const VERSION = JSON.parse(readFileSync(pkgPath, 'utf8')).version;
1
+ import { setJsonMode, setQuiet, outln } from "./output.js";
2
+ import { loginCommand, logoutCommand } from "./commands/login.js";
3
+ import { whoamiCommand, creditsCommand, activityCommand } from "./commands/account.js";
4
+ import { modelsCommand, providersCommand } from "./commands/models.js";
5
+ import { chatCommand, completeCommand } from "./commands/chat.js";
6
+ import { embedCommand } from "./commands/embed.js";
7
+ import { rerankCommand } from "./commands/rerank.js";
8
+ import { speechCommand } from "./commands/speech.js";
9
+ import { transcribeCommand } from "./commands/transcribe.js";
10
+ import { videoCommand } from "./commands/video.js";
11
+ import { imageCommand } from "./commands/image.js";
12
+ import { messagesCommand, responsesCommand } from "./commands/messages.js";
13
+ import { generationCommand } from "./commands/generation.js";
14
+ import { keysCommand } from "./commands/keys.js";
15
+ import { byokCommand } from "./commands/byok.js";
16
+ import { filesCommand } from "./commands/files.js";
17
+ import { presetsCommand } from "./commands/presets.js";
18
+ import { requestCommand } from "./commands/request.js";
19
+ import { guardrailsCommand } from "./commands/guardrails.js";
20
+ import { workspacesCommand } from "./commands/workspaces.js";
21
+ import { orgCommand, zdrCommand, authCodeCommand } from "./commands/misc.js";
22
+ import { DEFAULT_BASE_URL } from "./config.js";
23
+ import { readFileSync } from "node:fs";
24
+ import { fileURLToPath } from "node:url";
25
+ import { dirname, join } from "node:path";
26
+
27
+ const pkgPath = join(dirname(fileURLToPath(import.meta.url)), "..", "package.json");
28
+ const VERSION = JSON.parse(readFileSync(pkgPath, "utf8")).version;
24
29
 
25
30
  const COMMANDS = {
26
31
  login: loginCommand,
@@ -36,17 +41,24 @@ const COMMANDS = {
36
41
  rerank: rerankCommand,
37
42
  speech: speechCommand,
38
43
  tts: speechCommand,
44
+ transcribe: transcribeCommand,
45
+ stt: transcribeCommand,
39
46
  video: videoCommand,
47
+ image: imageCommand,
48
+ images: imageCommand,
40
49
  messages: messagesCommand,
41
50
  responses: responsesCommand,
42
51
  generation: generationCommand,
52
+ presets: presetsCommand,
43
53
  keys: keysCommand,
54
+ byok: byokCommand,
55
+ files: filesCommand,
44
56
  guardrails: guardrailsCommand,
45
57
  workspaces: workspacesCommand,
46
58
  org: orgCommand,
47
59
  zdr: zdrCommand,
48
- 'auth-code': authCodeCommand,
49
- request: requestCommand
60
+ "auth-code": authCodeCommand,
61
+ request: requestCommand,
50
62
  };
51
63
 
52
64
  const HELP = `openrouter - CLI for the OpenRouter API
@@ -69,15 +81,19 @@ Inference:
69
81
  embed [text...] Embeddings
70
82
  rerank --query --doc Reranking
71
83
  speech [text...] Text to speech (audio out)
84
+ transcribe <file> Speech to text (audio in). Alias: stt
72
85
  video <sub> Video generation jobs (create / get / wait / download / models)
86
+ image <sub> Image generation (create / models / endpoints). Alias: images
73
87
 
74
88
  Discovery:
75
- models [list|show|endpoints|count|user] List models, full model detail,
76
- provider variants, count, or your
77
- workspace-filtered set
89
+ models [list|show|endpoints|parameters|count|user] List models, full model
90
+ detail, provider variants, param
91
+ analytics, count, or your set
78
92
  embed models List embedding models
79
93
  video models List video generation models
94
+ image models List image generation models
80
95
  providers List providers (with HQ + datacenters)
96
+ presets <sub> list / get / versions (saved config profiles)
81
97
  generation <id> [--content] Generation metadata or content
82
98
  credits Remaining credits
83
99
  activity Usage activity (management key)
@@ -85,8 +101,10 @@ Discovery:
85
101
 
86
102
  Management (require a management key):
87
103
  keys <sub> list / get / create / update / delete
104
+ byok <sub> list / get / create / update / delete (provider integrations)
88
105
  guardrails <sub> list / get / create / update / delete / assignments
89
106
  workspaces <sub> list / get / create / update / delete / add-members / remove-members
107
+ files <sub> list / get / upload / download / delete
90
108
  org members List organization members
91
109
  auth-code Mint a PKCE authorization code so a user can claim a key
92
110
  request <METHOD> <path> Raw authenticated request to any endpoint
@@ -112,7 +130,7 @@ Environment:
112
130
 
113
131
  Examples:
114
132
  openrouter login
115
- openrouter chat "Hello, world" -m anthropic/claude-3.5-sonnet
133
+ openrouter chat "Hello, world" -m anthropic/claude-sonnet-4.5
116
134
  echo "summarize this" | openrouter chat -m openai/gpt-4o-mini --no-stream
117
135
  openrouter models --filter claude --json
118
136
  openrouter embed -m openai/text-embedding-3-small "hello" "world"
@@ -131,10 +149,10 @@ function preParseGlobals(argv) {
131
149
  let version = false;
132
150
  for (let i = 0; i < argv.length; i++) {
133
151
  const a = argv[i];
134
- if (a === '--json') json = true;
135
- else if (a === '-q' || a === '--quiet') quiet = true;
136
- else if (a === '-V' || a === '--version') version = true;
137
- else if (a === '-h' || a === '--help') {
152
+ if (a === "--json") json = true;
153
+ else if (a === "-q" || a === "--quiet") quiet = true;
154
+ else if (a === "-V" || a === "--version") version = true;
155
+ else if (a === "-h" || a === "--help") {
138
156
  help = true;
139
157
  out.push(a); // forward so subcommand help can also pick it up
140
158
  } else out.push(a);
@@ -166,7 +184,7 @@ export async function run(argv) {
166
184
  return safeExit(1);
167
185
  }
168
186
  const code = await handler(rest);
169
- if (typeof code === 'number') await safeExit(code);
187
+ if (typeof code === "number") await safeExit(code);
170
188
  }
171
189
 
172
190
  function safeExit(code) {
@@ -183,7 +201,7 @@ function safeExit(code) {
183
201
  for (const stream of [process.stdout, process.stderr]) {
184
202
  if (stream && stream.writableLength > 0) {
185
203
  pending++;
186
- stream.write('', done);
204
+ stream.write("", done);
187
205
  }
188
206
  }
189
207
  if (pending === 0) {