# opencode

> Route opencode through sference: a sference provider in opencode.json with the full catalog in the model picker.

Source: https://sference.com/docs/sference-code/opencode

[opencode](https://opencode.ai) reads providers from `~/.config/opencode/opencode.json`. The sference launcher writes a `sference` provider there and starts opencode with it selected.

## Launch

```bash
curl -fsSL https://raw.githubusercontent.com/s-ference/sference/main/install.sh | sh
sference auth login --api-key 'sk_...'
sference launch opencode
```

## What the launcher writes

A `sference` provider using the AI SDK's OpenAI-compatible provider, with the full catalog registered:

```json
{
  "provider": {
    "sference": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Sference",
      "options": {
        "baseURL": "https://api.sference.com/v1",
        "apiKey": "{env:SFERENCE_API_KEY}"
      },
      "models": {
        "zai-org/GLM-5.3": { "name": "GLM 5.3" },
        "moonshotai/Kimi-K3": { "name": "Kimi K3" }
      }
    }
  }
}
```

The catalog is fetched live from `GET /v1/models`, so the picker matches your entitlements. The API key is injected at launch from `SFERENCE_API_KEY` rather than written into the file.

## Options

| Flag | Effect |
| --- | --- |
| `--model zai-org/GLM-5.3` | Select the active model |
| `--base-url <url>` | Point at a different API base |
| `--dry-run` | Print the provider config and command without launching |
| `sference launch opencode -- <args>` | Forward arguments to opencode |

## Reasoning levels

opencode exposes reasoning effort as a model variant. sference models are addressed as `sference/<model-id>`, and reasoning levels are selected through opencode's variant switcher rather than a separate model id — the launcher registers the base ids and opencode handles the level.

## Choosing a model

| Model | Input / output per 1M | Use for |
| --- | --- | --- |
| `zai-org/GLM-5.3-Flash` | 0.20 / 0.60 | Fast edits, formatting, small refactors |
| `zai-org/GLM-5.3` | 1.20 / 4.20 | General coding turns |
| `deepseek-ai/DeepSeek-V4.1-Flash` | 0.50 / 1.50 | Long-context work at low cost |
| `moonshotai/Kimi-K3` | 3.00 / 15.00 | Hard planning turns |

## Cost control

- **Prefix caching** — keep the system prompt and tool definitions stable and first. See [Prompt caching](https://sference.com/docs/guides/prompt-caching).
- **Per-engineer attribution** — one key per engineer shows up separately in `GET /control/v1/usage/by-key`. See [Usage & analytics](https://sference.com/docs/usage).

> **It is a compatibility layer**
>
> Open models plan differently and call tools less reliably than frontier closed models on long repo work. Validate on your own repository first. See [SferenceCode](https://sference.com/docs/sference-code) for what to expect.

- [SferenceCode](https://sference.com/docs/sference-code): All harnesses, model choices, and what to expect.
- [Pi](https://sference.com/docs/sference-code/pi): Provider block in ~/.pi/agent/models.json.
- [Claude Code](https://sference.com/docs/sference-code/claude-code): Proxy mode with hybrid routing.
