OpenCode
Connect OpenCode to APIClaw with an OpenAI-compatible provider in opencode.json.
Prerequisites
- Create an API key in the API Keys dashboard.
- Copy a full model ID from the model hub.
Install
curl -fsSL https://opencode.ai/install | bash
opencode --versionOn Windows, or if you prefer npm: npm install -g opencode-ai.
Configure opencode.json
Create or edit ~/.config/opencode/opencode.json (project-level opencode.json also works):
{
"$schema": "https://opencode.ai/config.json",
"model": "apiclaw/YOUR_MODEL_ID",
"provider": {
"apiclaw": {
"npm": "@ai-sdk/openai-compatible",
"name": "APIClaw",
"options": {
"baseURL": "https://apiclaw.biz/v1",
"apiKey": "{env:APICLAW_API_KEY}"
},
"models": {
"YOUR_MODEL_ID": {
"name": "YOUR_MODEL_ID",
"limit": { "context": 200000, "output": 16384 }
}
}
}
}
}Set limit to the model's real context and output sizes; OpenCode has no catalog entry for APIClaw models, so without it the context window is unknown to the client.
Then supply the key. Either export the variable the config refers to:
export APICLAW_API_KEY="sk-your-apiclaw-key"or store it in OpenCode instead with opencode auth login, choosing Other and entering apiclaw as the provider id. The two are alternatives; you do not need both.
| Setting | Value |
|---|---|
| Provider npm package | @ai-sdk/openai-compatible |
| Base URL | https://apiclaw.biz/v1 |
| Model | apiclaw/<full model ID from the model hub> |
Configure with /connect
Inside OpenCode, /connect stores credentials: pick Other, enter apiclaw as the provider id, and paste your key. It does not ask for a Base URL or model, so you still need the opencode.json block above.
Verify
Run /models to confirm your model appears, then send a test prompt. Check logs if the request does not show up.
Troubleshooting
- Provider id in
opencode auth loginmust match the key underprovider(for exampleapiclaw). - Model key must be the exact hub ID, not a display name.
- Use
@ai-sdk/openai-compatiblefor Chat Completions. Only switch to@ai-sdk/openaiif you need the Responses API.