OpenCode with APIMaster.ai
Add APIMaster as an OpenAI-compatible provider in OpenCode Desktop, with optional Reasoning tiers via opencode.jsonc.
OpenCode Desktop is the graphical client for OpenCode (currently beta): local agent sessions, file edits, and shell execution. APIMaster.ai is OpenAI-compatible — add it under Settings → Providers → Custom provider.
Get your API Key first. Use placeholder
your_apimaster_keybelow; screenshots mask real keys.
Prerequisites
- OpenCode Desktop installed from opencode.ai/download.
- Windows:
opencode-desktop-win-x64.exe - macOS:
brew install --cask opencode-desktopor.dmg - Linux:
.deb/.rpm/ AppImage
- Windows:
- APIMaster API Key from the console.
Step 1 — Open Providers
- Launch OpenCode Desktop and open a workspace.
- Click the gear icon (bottom-left).
- Select Providers in the sidebar.
- Scroll to Custom provider (Add an OpenAI-compatible provider by base URL).
- Click + Connect.

Step 2 — Custom provider form
| Field | Value |
|---|---|
| Provider ID | apimaster |
| Display name | APIMaster.ai |
| Base URL | https://apimaster.ai/v1 |
| API key | Your APIMaster key |

Leave Headers empty unless you authenticate via headers only.
Step 3 — Add models & Submit
On the next screen, map models (left = label in OpenCode, right = model id sent to APIMaster — usually the same):
| Left | Right |
|---|---|
gpt-5.4 |
gpt-5.4 |
claude-sonnet-4-6 |
claude-sonnet-4-6 |
- Click + Add model for more rows.
- Click Submit.

Pick ids from the marketplace. Avoid image-only models (e.g. gpt-image-2) for agent chat.
Step 4 — Pick a model
- Start or open a session.
- Open the model dropdown below the input.
- Under APIMaster.ai, select a model (e.g.
claude-sonnet-4-6).

Step 5 — Test
Send hello or a small coding task. A normal Assistant reply (file edits / shell) means APIMaster is connected.

Advanced: opencode.jsonc & Reasoning
The UI flow above is enough for a quick start. To configure Reasoning / thinking effort tiers (low, high, max, …) for the same model id, edit opencode.jsonc.
Config file location
| OS | Path |
|---|---|
| macOS / Linux | ~/.config/opencode/opencode.jsonc |
| Windows | C:\Users\<username>\.config\opencode\opencode.jsonc |
Create the file if missing. Restart OpenCode Desktop or start a new session after saving.
API Key (do not put in jsonc)
Do not store your API Key in opencode.jsonc.
Use:
/connectin the terminal, or- Settings → Providers → Connect Provider (same as Steps 1–2 above).
Keep secrets in OpenCode’s auth store; jsonc only defines provider, models, and Reasoning variants.
APIMaster provider in jsonc
Provider id: apimaster. npm package: @ai-sdk/openai-compatible.
baseURL must be:
https://apimaster.ai/v1
Not https://apimaster.ai/ — OpenCode appends /chat/completions. Without /v1 you get https://apimaster.ai/chat/completions → 404 Not Found.
Full example with Reasoning variants — download and overwrite OpenCode’s config:
- Download opencode.jsonc
- Overwrite (or save as):
- macOS / Linux:
~/.config/opencode/opencode.jsonc - Windows:
C:\Users\<username>\.config\opencode\opencode.jsonc
- macOS / Linux:
- Configure API Key via
/connector UI (never in jsonc). - Restart OpenCode Desktop or start a new session.
Back up your existing file before overwrite, or merge only the
provider.apimasterblock.
Minimal shape:
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"apimaster": {
"name": "APIMaster.ai",
"npm": "@ai-sdk/openai-compatible",
"options": { "baseURL": "https://apimaster.ai/v1" },
"models": {
"gpt-5.4": {
"name": "gpt-5.4",
"variants": {
"low": { "reasoningEffort": "low" },
"high": { "reasoningEffort": "high" }
}
}
}
}
}
}
Reasoning principles
variants= multiple Reasoning tiers for one model id in the UI.- For OpenAI-compatible APIs, OpenCode maps
reasoningEffort→reasoning_effortin the request body. - Variant names should match the actual parameter (
high→"reasoningEffort": "high"). - Each model supports different tiers — configure per official docs; no hidden remapping.
Reasoning tiers by model
| Model | Reasoning variants | Notes |
|---|---|---|
gpt-5.4 |
low, medium, high, xhigh |
GPT reasoning |
gpt-5.5 |
low, medium, high, xhigh |
GPT reasoning |
deepseek-v4-flash |
high, max |
DeepSeek thinking (recommended) |
deepseek-v4-pro |
high, max |
DeepSeek thinking (recommended) |
claude-sonnet-4-6 |
low, medium, high, max |
Claude Sonnet effort |
claude-opus-4-7 |
low, medium, high, xhigh, max |
Claude Opus effort |
claude-opus-4-8 |
low, medium, high, xhigh, max |
Claude Opus effort |
claude-haiku-4-5 |
none | No unconfirmed effort tiers |
minimax-m3 |
none | No unconfirmed effort tiers |
See opencode.jsonc for the full file.
Switching Reasoning in OpenCode
- Save
opencode.jsonc, then restart or new session. - Use the model / Reasoning dropdown (e.g.
gpt-5.4 / high). - If supported in your build:
Ctrl + Shift + Dcycles Reasoning tiers.
Troubleshooting
UI setup
| Issue | Fix |
|---|---|
| 401 | Check key; rotate if exposed |
| Model not found | Base URL must be https://apimaster.ai/v1; model id must match marketplace |
| No APIMaster models | Edit provider in Settings → add mappings → Submit |
| Slow / timeout | Try another model; use API Key Tester |
Reasoning / jsonc
Why only high and max for DeepSeek?
Official OpenAI-compatible thinking effort for DeepSeek is high and max. Avoid low / medium / xhigh that get remapped unpredictably.
Why max for Claude Sonnet, not xhigh?
Sonnet’s top tier is max; xhigh is for Opus (claude-opus-4-7 / claude-opus-4-8).
Why no variants for Haiku or MiniMax M3?
Without documented reasoningEffort values, skip variants — the model still works; UI just won’t show Reasoning sub-tiers.
Still getting 400?
baseURL=https://apimaster.ai/v1(not site root).- Model id spelling matches the marketplace.
- Key configured via
/connector UI. - Remove
variantstemporarily — if plain requests work, the chosenreasoning_effortmay be unsupported for that model.
Security
- Never share keys in chat or unredacted screenshots.
- Rotate keys that appeared in screenshots or logs.
- OpenCode can read/write files and run shell commands — use trusted workspaces only.
Checklist
- OpenCode Desktop installed
- Custom provider connected or
apimasterinopencode.jsonc - Base URL /
baseURL=https://apimaster.ai/v1(nothttps://apimaster.ai/) - API Key via
/connector UI (not in jsonc) - At least one chat model mapped
- (Optional) Reasoning variants match official tiers
- Test message succeeds
Summary
- Keys:
baseURL(https://apimaster.ai/v1), model id, API Key (/connector UI), optional Reasoning variants. - Variant names = actual
reasoning_effortvalues. - Configure tiers per model; skip variants when unsupported (Haiku, MiniMax M3).