OpenCode

Add Tchavi to OpenCode as a custom OpenAI-compatible provider and pay for it with mobile money.

Part of the coding agents guides.

OpenCode reaches any OpenAI-compatible endpoint through a custom provider block, so Tchavi drops in as one more provider in the /models picker.

1. Declare the provider

Put this in opencode.json at the root of your project, or in ~/.config/opencode/opencode.json to apply it everywhere:

JSON
{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "tchavi": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Tchavi",
      "options": {
        "baseURL": "https://tchavi.com/api/v1",
        "apiKey": "{env:TCHAVI_API_KEY}"
      },
      "models": {
        "claude-sonnet-4-6": { "name": "Claude Sonnet 4.6" },
        "gpt-5.4": { "name": "GPT-5.4" },
        "deepseek-v4-pro": { "name": "DeepSeek V4 Pro" }
      }
    }
  }
}

2. Export the key and start

Bash
export TCHAVI_API_KEY=sk-tch-your-key
opencode

{env:TCHAVI_API_KEY} is what keeps the key out of the file, which matters because opencode.json sits in your repository. Run /models and the three entries appear under Tchavi.

Adding more models

Add any model you want to the models map — the keys are Tchavi model ids, exactly as GET /v1/models returns them. A model missing from the map simply does not appear in the picker; nothing else breaks.

You can also declare a context window per model, which OpenCode uses to decide when to compact:

JSON
"deepseek-v4-pro": {
  "name": "DeepSeek V4 Pro",
  "limit": { "context": 128000, "output": 8192 }
}

Which npm package

Use @ai-sdk/openai-compatible, which posts to /v1/chat/completions. The @ai-sdk/openai package targets the Responses API instead. Tchavi serves both, but the models map and streaming behave most predictably on the first.

Keep the key out of the repository

If you put the provider block in the project's opencode.json, the {env:...} reference is the only thing standing between your key and a commit. Writing the key inline there will publish it the first time you push.


Next: Deep Code · Back to coding agents

On this page