CLI

Install the sference CLI, authenticate, and launch Claude Code, Codex, opencode, or Pi on sference models.

CLI

The sference command-line tool is published on PyPI as sference-cli. It wraps the same inference API as the Python SDK (auth, batches, streams, and responses), and sference launch runs your coding agent on sference models.

Install (one line)

macOS and Linux:

curl -fsSL https://raw.githubusercontent.com/s-ference/sference/main/install.sh | sh

That script installs sference on your PATH (via uv tool when available).

Other install options

uv tool install sference-cli
pip install sference-cli
# or
pipx install sference-cli

Then verify:

sference --help

Authenticate

Sign in with your sference account. No API key needed:

sference auth login

The CLI opens the sference console in your browser and shows a short code. Check that it matches the code in the console, approve the device, and the CLI finishes signing in on its own. Use --no-browser on a remote or headless machine: the CLI prints the approval URL and code, and you open the URL on any device where you're signed in.

The CLI saves a 24-hour access token and a 30-day refresh token to ~/.sference/credentials.json and refreshes the access token automatically whenever you run a command. sference launch claude also refreshes it mid-session, so a long Claude Code session doesn't drop. Codex, opencode, and Pi sessions run on the token issued at launch, which is valid for 24 hours. You only need to sign in again if you go 30 days without using the CLI or revoke the device. Each machine is listed under Profile → Signed-in devices in the console, where you can revoke it.

Check who you're signed in as:

sference auth me

CI and scripts: API key

For non-interactive environments, create an API key in the console and either save it or set it in the environment:

sference auth login --api-key 'sk_...'   # saves the key, no browser
export SFERENCE_API_KEY='sk_...'         # or: overrides any saved credential for every subcommand

Launch a coding agent

sference launch runs the coding agent you already use on open models served by sference. One command configures the agent and starts it; your existing settings, logins, and sessions are left as they are.

sference launch claude     # Claude Code
sference launch codex      # OpenAI Codex CLI
sference launch opencode   # opencode
sference launch pi         # Pi
sference launch cursor     # Cursor (its own-API-key mode; configures, does not start it)

Every launcher works the same way:

  • Your sference account, nothing else. The launcher uses your sference auth login sign-in (or SFERENCE_API_KEY). Usage is billed to your account like any other request.
  • Every catalog model in the picker. The launcher fetches the live catalog from GET /v1/models, so each model shows up in the agent's own model picker (/model and similar).
  • Pick a default. --model <catalog id> sets the model the session starts on. Without it the launcher uses SFERENCE_MODEL, then a built-in default. In the current OSS CLI that default is the alias zai-org/GLM-5.2 (still served; alias_of is zai-org/GLM-5.3) for Codex, opencode, and Pi. The built-in default for Claude Code and Cursor in the current release is a model that is no longer served, so pass --model deepseek-ai/DeepSeek-V4.1-Flash-1017 (or set SFERENCE_MODEL) for those two until the CLI ships a new default. Coming soon: --model sference/auto is not available on the public API yet. See auto model routing.
  • Forward agent flags after --. For example, sference launch codex -- exec "fix the failing test".
  • See what it does first. --dry-run prints the configuration and the command without starting the agent, with the API key redacted. For opencode and Pi it still writes the provider config file.
  • Going back is just starting the agent normally. Run claude, codex, opencode, or pi the usual way to use its native models. Claude Code and Codex keep no sference configuration. opencode and Pi keep a sference provider entry, which sits alongside your other providers until you pick it. For Cursor, sference launch cursor off restores the previous settings.
AgentWhat sference launch configures
Claude CodePoints Claude Code at sference's native /v1/messages via ANTHROPIC_BASE_URL and primes the /model picker from the live catalog (gateway model discovery). No proxy, nothing left behind when the session ends. Full guide: Claude Code.
Codex CLIAdds a sference provider on sference's /v1/responses through codex -c overrides, so ~/.codex/config.toml is never modified. Sub-agents and MCP servers run on sference too, and auto-compaction triggers at the model's real context window.
opencodeMerges a sference provider into ~/.config/opencode/opencode.json, with a thinking-effort variant on every model. Your other providers, keybinds, and theme are preserved.
PiWrites a sference provider to ~/.pi/agent/models.json (other providers are preserved) and scopes Pi's model picker to sference models. Reasoning effort maps to Pi's native levels.
CursorWrites the sference base URL, key, and live catalog into Cursor's settings (its own-API-key mode) and sets the default model for new chats. Cursor's own models stay available; sference launch cursor off restores. Requires a paid Cursor plan. Full guide: Cursor.

The agent itself must already be installed (claude, codex, opencode, pi on your PATH; the Cursor desktop app for launch cursor).

Want it on for every session?

sference launch scopes sference to the session it starts. To route the Claude Code and Codex sessions you start yourself, without a launcher, use Sference Switch: a macOS app that routes per model family and keeps Claude models available.

Batch JSONL

Each line in a batch input file becomes one row in POST /v1/batches. All rows must use the same model: either repeat body.model on every OpenAI-style line or set --model once for content-only lines. The model must be catalog-available; invalid or mixed models return 400 at create.

Inner body accepts chat completions (messages) or Responses (input). Responses fields are normalized at create; invalid rows return 400 with row index / custom_id.

{"custom_id":"a","method":"POST","url":"/v1/chat/completions","body":{"model":"…","messages":[{"role":"user","content":"hi"}]}}
{"custom_id":"b","method":"POST","url":"/v1/responses","body":{"model":"…","input":[{"role":"user","content":"hi"}]}}
{"content":"content-only, pass --model on submit"}

Full guide: Batch inference. Subcommand reference: OSS CLI README.

Decisions

sference decisions create sends one realtime decision. It prints one line per answer, or the full response with --json:

sference decisions create --model Cloudflare/clef \
  --state "I was charged twice, please refund me" \
  --questions '{"route": {"type": "choice", "criteria": {"billing": "Payments", "support": "Other"}}, "refund": {"type": "noul"}}'

Go deeper

Subcommands, JSONL batch formats, and stream workflows live in the sference OSS repository (cli/README.md).