Use Tresor with OpenCode

Configure the OpenCode coding agent to send completions through the Tresor router.

OpenCode is an open-source terminal coding agent that supports any OpenAI-compatible provider. Because Tresor speaks the OpenAI Chat Completions protocol, you can route OpenCode through the Tresor router with a one-time config change.

1. Register the credential

Start OpenCode with opencode, then run /connect and pick Other at the bottom of the provider list. Enter:

  • Provider id: tresor
  • API key: your Tresor key (starts with tr-)
$ opencode
> /connect
┌  Add credential
│  ●  Other
│  ◇  Enter provider id
│  tresor
│  ◇  Enter your API key
│  tr-...
└

OpenCode stores the key in ~/.local/share/opencode/auth.json.

2. Add the provider to your config

OpenCode needs a provider.tresor entry to know the base URL and which models to expose. Add it to either the project-local opencode.json or the global ~/.config/opencode/opencode.json:

opencode.json
{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "tresor": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Tresor",
      "options": {
        "baseURL": "https://api.tresor.co/v1"
      },
      "models": {
        "global/privatemode/gpt-oss-120b": {
          "name": "eu/privatemode/gpt-oss-120b"
        },
        "global/chutes/kimi-k2.6": { "name": "global/chutes/kimi-k2.6" },
        "global/tinfoil/deepseek-v4-pro": {
          "name": "global/tinfoil/deepseek-v4-pro"
        }
      }
    }
  },
  "model": "tresor/kimi-k2.6"
}

The model ids must match those returned by GET /v1/models. Run curl https://api.tresor.co/v1/models -H "Authorization: Bearer $TRESOR_API_KEY" to list the current set.

@ai-sdk/openai-compatible is the AI SDK adapter OpenCode ships for any OpenAI-compatible endpoint that uses /v1/chat/completions. No extra install step is required.

3. Pick the model

Inside OpenCode, run /models and select one of the entries you configured.

> /models
  Tresor / gpt-oss 120B
  Tresor / Qwen3 Coder 480B

That's it — every prompt OpenCode sends now goes through the Tresor router and returns a verifiable receipt.

See also