OpenCode supports 75+ LLM providers out of the box, but what if you want to use a provider that isn't in the directory? You can add any OpenAI-compatible API as a custom provider with a few lines of config.
This guide walks through adding Haimaker — an inference routing platform that gives you access to dozens of models through a single API.
Why use a custom provider?
A few reasons you might want this:
- Access to different models. Haimaker routes to models you won't find on other platforms, including cost-optimized and specialized options.
- Cost control. Route by price, latency, or compliance requirements. Haimaker is typically 5% cheaper than comparable providers.
- Single API key. One key, many models. Less config sprawl.
Step 1: Get your Haimaker API key
- Sign up at haimaker.ai
- Join the Haimaker Discord and get verified for $50 in free credits
- Grab your API key from the dashboard
Step 2: Configure the provider
OpenCode uses a config file to define custom providers. Open (or create) your config at:
~/.config/opencode/opencode.jsonc
Add Haimaker as a provider:
{
"provider": {
"haimaker": {
"npm": "@ai-sdk/openai-compatible",
"options": {
"baseURL": "https://api.haimaker.ai/v1"
},
"models": {
"z-ai/glm-4.6": {}
}
}
}
}
A few notes:
- The
npmfield tells OpenCode to use the OpenAI-compatible SDK adapter baseURLpoints to Haimaker's API endpointmodelslists which models you want available — add more as needed
Step 3: Add your API key
OpenCode stores credentials separately from config. Add your Haimaker key to:
~/.local/share/opencode/auth.json
{
"haimaker": {
"type": "api",
"key": "HAIMAKER_API_KEY"
}
}
Replace HAIMAKER_API_KEY with the actual key from your dashboard.
Step 4: Select a model
Run OpenCode and use the /models command to switch to your Haimaker model. You should see haimaker/z-ai/glm-4.6 (or whatever models you configured) in the list.
Adding more models
Haimaker gives you access to a bunch of models. Check the model hub to see what's available, then add them to your config:
{
"provider": {
"haimaker": {
"npm": "@ai-sdk/openai-compatible",
"options": {
"baseURL": "https://api.haimaker.ai/v1"
},
"models": {
"z-ai/glm-4.6": {},
"anthropic/claude-3-5-sonnet": {},
"openai/gpt-4o": {},
"meta-llama/llama-3.1-405b": {}
}
}
}
}
Model IDs follow the format on Haimaker's model hub. Copy them exactly.
Troubleshooting
"Model not found" error Double-check the model ID matches what's in Haimaker's model hub. Case and formatting matter.
Authentication failed
Make sure auth.json has the right structure and your API key is valid. You can test your key with a quick curl:
curl https://api.haimaker.ai/v1/models \
-H "Authorization: Bearer HAIMAKER_API_KEY"
Provider not showing up Restart OpenCode after editing config files. Changes aren't picked up automatically.
This same pattern works for any OpenAI-compatible API. Just swap the baseURL and model names.
Questions? Hit us up in Discord.
