# Which API to use with OpenCode

> Connect OpenCode to Outrun with one prepaid key for every model. 1,000 requests cost from $0.09. Settings, model prices and common fixes.

Add Outrun to OpenCode as a custom provider in opencode.json at `https://api.outrun.to/v1`, then paste your Outrun key and a model ID. One prepaid key works for every model, and you pay per token with no subscription. 1,000 requests cost from $0.09 on Claude Haiku 5.5 route 2.

## How do I connect OpenCode?

These are the settings from the [OpenCode setup guide](https://outrun.to/docs/setup/opencode), which walks through each step.

**OpenCode settings**

```
{
 "provider": {
 "outrun": {
 "npm": "@ai-sdk/openai-compatible",
 "name": "Outrun",
 "options": {
 "baseURL": "https://api.outrun.to/v1",
 "apiKey": "{env:OUTRUN_API_KEY}"
 },
 "models": { "claude-sonnet-5-5": { "name": "Claude Sonnet 5.5" } }
 }
 }
}
```

## Which models fit my budget?

Models from the setup guide plus the lowest-cost general models, sorted by the cost of 1,000 requests.

**Models for OpenCode USD per 1M tokens**

| Model | Input | Output | Cached input | 1,000 requests |
| --- | --- | --- | --- | --- |
| Claude Haiku 5.5 (2) `claude-haiku-5-5-2` | $0.02 | $0.10 | $0.01 | $0.09 |
| GLM-5.3 Flash (2) `glm-5.3-flash-2` | $0.05 | $0.05 | $0.01 | $0.13 |
| DeepSeek V4.1 Flash 1017 Fast `deepseek-v4.1-flash-1017-fast` | $0.03 | $0.18 | $0.01 | $0.13 |
| MiniMax M3.1 Flash `minimax-m3.1-flash` | $0.05 | $0.18 | $0.01 | $0.18 |
| GLM-5.3 (2) `glm-5.3-2` | $0.10 | $0.10 | $0.02 | $0.25 |
| GPT-6.1 Sol `gpt-6.1-sol` up to 272k tokens | $0.12 | $0.59 | $0.01 | $0.53 |
| Claude Sonnet 5.5 `claude-sonnet-5-5` | $0.49 | $2.45 | $0.03 | $2.21 |
| DeepSeek V4 Pro `deepseek-v4-pro` | $1.35 | $4.05 | $0.05 | $4.73 |
| Claude Opus 5.5 `claude-opus-5-5` | $2.24 | $11.20 | $0.12 | $10.08 |

1,000 requests = each request sends 2,000 input tokens and returns 500 output tokens, with no cache discount. Prices are per 1M tokens, rounded up to the cent, as of December 4, 2026.

OpenCode resends the session context on each step, so long coding sessions use many input tokens. Cached input lowers the cost on models that list a cached price.

## OpenCode API questions

The [setup guide](https://outrun.to/docs/setup/opencode) covers errors and context limits.

### Where is opencode.json?

The global file is ~/.config/opencode/opencode.json (Windows: %USERPROFILE%\.config\opencode\opencode.json). A project folder can have its own.

### Does it work with OpenCode 2?

These settings use the OpenCode 1 config format. OpenCode 2 uses a different provider format.

### How much does OpenCode cost with Outrun?

You pay per token from a prepaid balance. 1,000 requests of 2,000 input and 500 output tokens cost from $0.09 on Claude Haiku 5.5 route 2.

### Can I switch models later?

Yes. Change the model ID; the key and base URL stay the same.

### Does Outrun keep my prompts or outputs?

Outrun does not store your prompts, images or outputs unless you choose to save them.

## Related pages

- [OpenCode setup guide](https://outrun.to/docs/setup/opencode)
- [Where is opencode.json?](https://outrun.to/fix/opencode-json-location)
- [OpenAI-compatible API](https://outrun.to/openai-compatible-api)
- [API for SillyTavern](https://outrun.to/api-for-sillytavern)
- [All model prices](https://outrun.to/pricing)
- [Get your API key](https://outrun.to/overview)

[Get your API key](https://outrun.to/key) [See all models and prices](https://outrun.to/pricing)
