Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

OpenCode — custom provider setup

Add an OpenAI-compatible endpoint to OpenCode, including reasoning-effort tiers.

Quick path (UI)

Gear icon → ProvidersCustom 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.

Two URL traps specific to OpenCode

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.

Config file (for reasoning tiers)

  • 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.

Never put your key in the JSONC

The config file defines providers, models and reasoning variants only. Keys belong in OpenCode's auth store:

/connect

or Settings → Providers → Connect Provider. A key committed to opencode.jsonc ends up in git history.

Vision

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.

Troubleshooting

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

Verify before you debug

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_KEY

It reports which protocol the endpoint speaks, TTFT, the advertised model list, and whether your model id is actually on it.


Other agents

Configs for Claude Code, Kilo Code, OpenCode, Aider, Codex, Cursor, LiteLLM and LangChain: ai-coding-agent-api-configs


Endpoint used in the examples

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.

Get a key · Docs

License

MIT

About

OpenCode custom provider setup — configure opencode.jsonc with an OpenAI-compatible base URL, model mapping, and reasoning effort tiers. Covers the /v1 path trap and auth store handling.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages