Clients/opencode
Use the Wokey API with opencode
Get a Wokey API key, point opencode at the Wokey base URL, then confirm the connection with one curl request.
Updated
Get an API key and the base URLlink
Every client uses the same Wokey API key and the same base URL.
Create an API key
Sign in and create a platform key on the API page. Keys in one account share its balance.
Create an API keykeyUse the Wokey base URL
Set the client base URL to the gateway domain; the configuration below shows whether to append /v1.
Configure the clientlink
One command writes the Wokey provider and switches the default model to wokey/auto.
export WOKEY_API_KEY="YOUR_API_KEY"
curl -fsSL https://wokey.ai/downloads/opencode/install.sh | sh
opencodeAPI formats and base URLslink
When one client switches API format, whether the base URL ends in /v1 can change.
| Format | Base URL | Use it for |
|---|---|---|
| OpenAI Chat Completions | https://api.wokey.ai | DeepSeek, GLM, Kimi, and other models |
Where it is configured: ~/.config/opencode/opencode.json
Verify with curllink
If the client reports an error, rule out the key and base URL with curl first.
opencode uses the OpenAI Chat Completions format by default. A 200 from this request means the key and base URL are right. Replace YOUR_API_KEY with your key before sending it.
curl https://api.wokey.ai/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-6-sol",
"messages": [
{ "role": "user", "content": "Hello" }
]
}'Errors & Troubleshootinglink
Separate auth, balance, rate limit, model availability, and upstream timeout cases first.
invalid api key
The key is missing, mistyped, deleted, or Authorization / x-api-key headers conflict.
insufficient balance
The account balance is too low. Top up before sending more requests.
model_denylisted / account_restricted
Calls to the model, or to every model on the account, are paused after repeated violations. See Violation Handling Fees & Restrictions.
request_blocked
This request was blocked before reaching the upstream and is not charged, for example an unchanged resend of a request the model just refused, or a paused end user (X-End-User-Id). The error message says what is blocked; change the request as it says or retry later. Other requests are not affected.
rate limited
Traffic is too frequent. Retry later or reduce concurrency. If only one model, or one end user (X-End-User-Id), keeps returning 429, it may be a temporary limit after violations.
client disconnected
The client closed the connection before the response finished (code downstream_aborted). This is free by default. Once an account has at least 50 client disconnects in the past 24 hours and they make up 10% or more of its requests, later disconnected requests are billed for the usage the upstream reported: the processed input, including cache reads and writes, and output only when the upstream counted it. A disconnect before the upstream reported any usage stays free. The account is notified when billing starts, and billing stops automatically within an hour once the disconnect rate is back to normal. The usual cause is a client or proxy timeout that is too short, or a program that cancels requests before they finish.
upstream unavailable
The upstream model service is temporarily unavailable. Switch models or retry later.
upstream timeout
The upstream response timed out. Shorten context, reduce max_tokens, or retry.
upstream overloaded
The upstream model is temporarily overloaded and Wokey already retried on other routes (code upstream_overloaded). It is unrelated to your balance. Retry shortly or switch models.
Frequently asked questionslink
- What does the install script change?
- It adds a provider named wokey to ~/.config/opencode/opencode.json and sets the default model to wokey/auto. An existing file is first backed up as opencode.json.bak, and other providers in it are kept.
- Can I avoid putting the API key in the command?
- Run the script without WOKEY_API_KEY set and it asks for the key in the terminal without echoing it. The key is stored in opencode.json, so do not share that file.
- How do I use a specific model?
- Set WOKEY_MODEL before running the script, for example export WOKEY_MODEL=claude-opus-5-5, and the default model becomes wokey/claude-opus-5-5. Without it the script uses auto.