sharedllm
v0.3.7
Published
SharedLLM CLI — route agentic coding tools (Claude Code, etc.) through the SharedLLM gateway
Downloads
1,351
Maintainers
Readme
sharedllm
Launch agentic coding tools (Claude Code today; Codex and Aider next) through the SharedLLM gateway with one command. Pick a model from an interactive list, let Auto route to the best available one, track every request, and map Anthropic-tier aliases (Opus / Sonnet / Haiku) to whichever upstream you've configured.
The CLI is a launcher, not a proxy. It loads your SharedLLM credentials, sets the right environment variables, and execs the target tool. The gateway handles auth, model resolution, billing, and forwarding.
Install
One-line installer (recommended):
macOS / Linux:
curl -fsSL https://sharedllm.com/install.sh | shWindows (PowerShell):
irm https://sharedllm.com/install.ps1 | iexBoth pick whichever JS package manager you already have (bun → pnpm → npm; the Unix script also tries yarn and can bootstrap bun), install sharedllm globally, and put the install dir on your PATH — appending to ~/.bashrc / ~/.zshrc / fish config on Unix, or your User PATH on Windows.
Or pick a package manager directly:
bun add -g sharedllm # bun (macOS / Linux / Windows)
pnpm add -g sharedllm # pnpm (macOS / Linux / Windows)
npm install -g sharedllm # npm (Unix may need sudo for /usr/local)On Windows, the npm/pnpm global launchers are rewritten to call
nodedirectly by the package'spostinstallstep, sosharedllm/sllmwork from cmd.exe and PowerShell out of the box (Node.js ≥ 18 required).
The package installs both sharedllm (long) and sllm (short) on your PATH.
Use whichever you prefer. Examples below use sllm.
Quickstart
sllm login # opens browser, creates a CLI key
sllm claude # pick a model from the interactive listOr name a model directly (skips the picker):
sllm claude --model kimi-2.6Don't have a browser handy (SSH, CI, sandboxes)? Grab a key from your dashboard and paste it:
sllm login --no-browser --key sk-sharedllm-...Choosing a model
Interactive picker
Run sllm claude with no --model in a terminal and you get a searchable,
colour-coded list:
Select a model ↑/↓ navigate · type to search · enter select · esc cancel
search: kimi
❯ ollama kimi-2.6 translated/chat
3/41 models- ↑/↓ (or
Ctrl-P/Ctrl-N) to move, Enter to select, Esc / Ctrl-C to cancel. - Type to filter by provider, model id, or type; Backspace edits, Ctrl-U clears the search.
- Each row shows the provider and whether it runs native (green) or via
translated (yellow) Anthropic↔OpenAI conversion. Your default is
marked with a
★.
Set NO_COLOR=1 to disable colour; on non-interactive shells (pipes / CI) the
CLI falls back to a plain numbered prompt.
Auto (smart routing)
auto resolves, per request, to the first model in a priority list that
currently has an available key — your own contributed key first, then the
shared pool:
sllm claude --model autoThe priority order comes from your list (set it in the dashboard under Playground → Auto, up to 10 models), falling back to the admin default order, and finally to the best available model. Pick Auto at the top of the interactive picker to do the same thing.
Make it your default so plain sllm claude always uses it:
sllm config set default_model autoCommands
sllm login [--key <key>] [--endpoint <url>] [--no-browser]
sllm logout [--all] [--profile <name>]
sllm status [--profile <name>]
sllm <tool> [--model <id>] [--profile <name>] [--no-preflight] [--no-pick] [-- <tool args...>]
tools: claude
--model accepts any model id, or "auto"
sllm models [--provider <name>] [--type <type>] [--json]
sllm models resolve <model-id>
sllm usage [--days <n>] [--json]
sllm config show
sllm config set <key> <value>
sllm config path
sllm update [--pm <bun|pnpm|npm|yarn>] [--check] [--to <version>] [--force]
sllm versionKeeping the CLI up to date
sllm update # upgrade the global install to the latest published version
sllm update --check # just report whether a newer version existsupdate detects the package manager that installed the CLI (bun / pnpm / npm /
yarn) and runs its global-upgrade command; override detection with --pm. If
the gateway enforces a minimum CLI version and yours is older, sllm claude
(and other launches) will update in place automatically and re-run your
command — no manual step. Set SHAREDLLM_NO_AUTO_UPDATE=1 (or run under CI)
to disable the silent auto-update and just be told what to run instead.
Pass-through to the wrapped tool
Anything after a bare -- is forwarded verbatim to the child binary:
sllm claude --model kimi-2.6 -- --resume --dangerously-skip-permissionsTier overrides for Claude
If you want Claude Code's built-in Opus/Sonnet/Haiku selectors to map to specific upstream models, set them once:
sllm config set tier_models.opus claude-opus-4-20250918
sllm config set tier_models.sonnet claude-sonnet-4-20250514
sllm config set tier_models.haiku claude-haiku-4-5-20251001From then on, selecting Sonnet inside Claude Code routes through the model
you mapped, no flags needed.
Profiles
Multiple SharedLLM accounts or endpoints (prod / staging / self-hosted)? Profiles are first-class:
sllm login --profile staging --endpoint https://api.staging.sharedllm.com
sllm config set active_profile staging
sllm claude # uses staging
sllm claude --profile defaultSelf-hosted gateway
sllm login \
--endpoint http://localhost:3000 \
--endpoint-dashboard http://localhost:3001When the gateway runs on :3000, the CLI defaults the dashboard to :3001.
Override either with the flags above, or via SHAREDLLM_ENDPOINT /
SHAREDLLM_ENDPOINT_DASHBOARD env vars.
Configuration
Config is stored at:
- macOS / Linux:
~/.config/sharedllm/config.json - Windows:
%APPDATA%\sharedllm\config.json
Permissions are enforced to 0600 on POSIX (the file contains your API token).
Run sllm config path to see the location, or sllm config show for a
redacted dump.
Setting precedence: CLI flag → SHAREDLLM_* env var → active profile → built-in default.
Environment variables the CLI sets for claude
When sllm claude runs, it sets these for the child process:
| Variable | Value |
|---|---|
| ANTHROPIC_BASE_URL | <endpoint>/anthropic |
| ANTHROPIC_AUTH_TOKEN | your SharedLLM key |
| ANTHROPIC_API_KEY | "" (must be empty for AUTH_TOKEN to take effect) |
| ANTHROPIC_MODEL | from --model or default_model (may be auto) |
| ANTHROPIC_DEFAULT_OPUS_MODEL | from tier_models.opus (if set) |
| ANTHROPIC_DEFAULT_SONNET_MODEL | from tier_models.sonnet (if set) |
| ANTHROPIC_DEFAULT_HAIKU_MODEL | from tier_models.haiku (if set) |
If you already have ANTHROPIC_* vars in your shell, the CLI overrides them
and prints a one-line warning so the source of changes stays obvious.
Troubleshooting
| Symptom | Fix |
|---|---|
| claude not found in PATH | npm install -g @anthropic-ai/claude-code |
| Not authenticated. Run: sllm login | Run that. |
| Stored key was rejected | The key was revoked from the dashboard. Run sllm login to issue a new one. |
| Auto: no model … has an available key | Add a provider key (dashboard → Resource Pool), or adjust your Auto order. |
| Browser doesn't open | The login URL is printed; open it manually. Or pass --no-browser and --key sk-sharedllm-.... |
| Config has loose permissions | chmod 600 ~/.config/sharedllm/config.json |
License
MIT
