# Where is opencode.json?

> Where is opencode.json? The global file is ~/.config/opencode/opencode.json. How to create it and add a custom provider, step by step.

The global OpenCode config is ~/.config/opencode/opencode.json, or %USERPROFILE%\.config\opencode\opencode.json on Windows. You can also put an opencode.json in a project folder for that project only. If the folder or file is missing, create it, then add a provider block with the base URL https://api.outrun.to/v1.

## What causes it?

- OpenCode reads the global file in ~/.config/opencode/ and a project file in the folder you open.
- A missing folder is not created for you.
- These settings use the OpenCode 1 config format; OpenCode 2 uses a different provider format.

## How do I fix it?

In this order. [The OpenCode setup guide](https://outrun.to/docs/setup/opencode) has the full setup.

- Create ~/.config/opencode/ if it does not exist (Windows: %USERPROFILE%\.config\opencode\).
- Create opencode.json there and paste the provider block below.
- Save your key in the OUTRUN_API_KEY environment variable and open a new terminal.
- Start opencode and pick a model with /models: it appears as outrun/ followed by the ID.

**~/.config/opencode/opencode.json**

```
{
 "$schema": "https://opencode.ai/config.json",
 "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" }
 }
 }
 }
}
```

## Questions

### Can I have a project opencode.json and a global one?

Yes. The global file applies everywhere; an opencode.json in a project folder applies to that project.

### Why does OpenCode not find my key?

An unset variable is read as an empty key. Save your key in OUTRUN_API_KEY, keep "apiKey": "{env:OUTRUN_API_KEY}" and open a new terminal.

### Does Outrun keep my prompts or outputs?

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

## Related pages

- [401 Invalid API key in an OpenAI-compatible app](https://outrun.to/fix/openai-compatible-401-invalid-api-key)
- [Model not found (404)](https://outrun.to/fix/model-not-found-404)
- [OpenCode setup guide](https://outrun.to/docs/setup/opencode)
- [All error fixes](https://outrun.to/fix)
- [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)
