Add an OpenAI-compatible endpoint to OpenCode, including reasoning-effort tiers.
Gear icon → Providers → Custom provider → + Connect:
| Field | Value |
|---|---|
| Provider ID | apimaster |
| Display name | APIMaster.ai |
| Base URL | https://apimaster.ai/v1 |
| API key | your key |
Next screen maps labels to model ids (usually identical). Submit.
1. /v1 is required. OpenCode appends /chat/completions itself. Without
/v1 you get https://host/chat/completions → 404.
2. Don't invent an api. subdomain. https://api.host/v1 can fail at TLS
if the provider doesn't serve that hostname. Use exactly what the docs say.
- macOS / Linux:
~/.config/opencode/opencode.jsonc - Windows:
C:\Users\<you>\.config\opencode\opencode.jsonc
See opencode.jsonc in this repo for a complete example with
reasoning variants. Restart OpenCode or start a new session after editing.
The config file defines providers, models and reasoning variants only. Keys belong in OpenCode's auth store:
/connector Settings → Providers → Connect Provider. A key committed to opencode.jsonc
ends up in git history.
Models that accept image input need an explicit capability declaration in
OpenCode — supporting the feature upstream isn't enough. See the attachment
field in the example config.
| Symptom | Cause | Fix |
|---|---|---|
| 404 on every request | Base URL missing /v1 |
Add it |
| TLS / connection failure | api. subdomain that doesn't exist |
Use the documented host |
| Config changes ignored | Session cached | Restart or open a new session |
| Image upload rejected | Capability not declared | Add attachment to the model entry |
| Reasoning tier ignored | Endpoint doesn't forward the param | Test with a direct curl |
Before blaming the agent, confirm the endpoint itself works. This repo ships a zero-dependency checker that tests both protocols and prints the exact base_url to paste into each tool:
python check_endpoint.py --url https://apimaster.ai --key YOUR_API_KEYIt reports which protocol the endpoint speaks, TTFT, the advertised model list, and whether your model id is actually on it.
Configs for Claude Code, Kilo Code, OpenCode, Aider, Codex, Cursor, LiteLLM and LangChain: ai-coding-agent-api-configs
Examples use https://apimaster.ai/v1, an OpenAI-compatible endpoint fronting
multiple model providers with one key. Every config here works with any
OpenAI-compatible endpoint — substitute your own, including a self-hosted
new-api or LiteLLM proxy.
MIT