OpenCode Error From Provider: Fix Base URL and API Key
An opencode error from provider appears when the endpoint OpenCode calls rejects or fails to process a request. In practice three causes account for many of them: a wrong base URL, an invalid API key, or a model ID that isn't in the catalog. All three live in opencode.json, so you can check them without reinstalling anything.
An opencode error from provider usually comes from the base URL, the API key or the model ID, and all three can be verified in opencode.json before you change anything else.
What does opencode error from provider mean in OpenCode?
The message appears when the endpoint OpenCode calls rejects or fails to process the request. OpenCode doesn't call a model directly. It sends an HTTP request to the base URL written in your configuration, then prints the provider's reply to the terminal.
So an opencode error from provider is not a sign that the app is broken. What you need to inspect lives in configuration: the endpoint address, the credentials, and the model name being requested. Follow a fixed order so you don't overwrite settings that were already correct.
Check the base URL and API key in opencode.json
OpenCode reads its configuration from ~/.config/opencode/opencode.json, or %USERPROFILE%\.config\opencode\opencode.json on Windows. Open that file and look at the provider object inside it.
The provider is written as an object, not an array. If yours is wrapped in square brackets, OpenCode can't read the provider list and requests never reach the right endpoint. The shape looks roughly like this:
{
"provider": {
"tokenomixai": {
"npm": "@ai-sdk/openai-compatible",
"options": {
"baseURL": "https://api.tokenomixai.com/v1",
"apiKey": "sk-tkx-..."
}
}
}
}The two fields that break setup in practice are baseURL and apiKey. For an OpenAI-compatible endpoint, baseURL runs all the way to /v1, for example https://api.tokenomixai.com/v1. The key has to be complete, including the sk-tkx- prefix, with no spaces or stray quotes picked up while copying.
If the error mentions 401 or unauthorized, look at the key first. How to read that status is covered in 401 API key error.
A wrong model ID also appears as error from provider
The model name in your configuration must match the ID in the catalog exactly. Guessing from the display name, adding a version suffix or swapping hyphens usually ends with the endpoint rejecting the request.
Model IDs, context sizes and which models exist are only listed in the docs. Copy from there instead of retyping from memory or from an old conversation.
The symptom is distinctive: one model fails while the others run fine. If all models fail, the check moves back to the base URL and the API key, not the model ID.
Read the status code before changing the configuration
The provider reply normally carries a status code. That number narrows the problem before you change settings one at a time and guess at the result.
| Status or message | Usual cause |
|---|---|
| 401 unauthorized | API key is empty, truncated, or no longer active |
| 404 not found | baseURL doesn't end at /v1, or the endpoint path is wrong |
| Model not found | Model ID was typed by hand and doesn't match the catalog |
| 429 too many requests | The 600 requests per minute per account limit was crossed, check the Retry-After header |
On a 429, wait for the Retry-After value and send again. That limit is counted per account and shared by all its keys, so one fast script can trigger 429s for other keys on the same account.
An order for checking opencode.json
Work through these in order, and don't reach for the installer until the first three are done. Each step rules out one possibility.
- Open
~/.config/opencode/opencode.jsonand confirmprovideris an object. - Check the
baseURLof the provider you use. For an OpenAI-compatible endpoint it must reach/v1. - Paste the
apiKeyagain from the original source, not from a chat or a screenshot. - Replace the model ID with one listed in the documentation catalog.
- Save the file and restart OpenCode so the configuration is read again.
Copy the file before you edit it. If your changes add new problems, you can put the old contents back instead of guessing which setting was right before.
Config looks right but it still fails: quota and rate limit
Two things on the account side produce similar errors: an exhausted quota and the rate limit. Quota is counted in tokens, not time windows, so there is no 5-hour limit. The key keeps working while tokens remain and before it expires.
curl https://api.tokenomixai.com/v1/quota -H "Authorization: Bearer sk-tkx-..."The response contains status, remainingTokens, maxTokens, usagePercent, expiresAt, and low, which is true at 10 percent or less. If status is already exhausted, a top-up with the same key adds the remaining tokens together and validity follows the latest top-up. The key itself doesn't change, so opencode.json needs no edits.
Each of those fields is explained in check API quota.
Reinstall the provider with one command
If the configuration file has become messy, the installer rewrites the provider section while keeping your other providers, MCP servers and plugins. It makes a backup first, then asks for the API key in the terminal rather than through a URL.
bash <(curl -fsSL https://tokenomixai.com/install/opencode.sh)On Windows the same flow runs from PowerShell.
irm https://tokenomixai.com/install/opencode.ps1 | iexTo return to the configuration you had before installing, run the installer with the restore flag.
bash <(curl -fsSL https://tokenomixai.com/install/opencode.sh) --restoreThe full walkthrough is in OpenCode provider: change base URL and API key.
Frequently asked questions
Why does the error show up for one model while others work?
That means your base URL and API key are fine and the problem sits with the model ID you're asking for. The model may not be in the catalog, or the name is misspelled. Take the ID from the documentation page again and save the change.
Do I need to reinstall OpenCode to fix this error?
No. The error comes from configuration or from the account side, not from a broken application. Fix opencode.json, or run the installer with the restore flag if you want to go back to the state before your edits.
Can an exhausted quota cause error from provider?
Yes. When remaining tokens hit zero, the endpoint rejects requests even with a correct base URL and key. Call the quota endpoint, read the status and remainingTokens fields, then top up with the same key if it's used up.
Are my prompts and the code I send stored anywhere?
The gateway logs request metadata only: model, token count, time and status. Prompt and completion contents are not stored. That applies to the TokenomixAI gateway, not to other tools you run on your own machine.
How many requests can I send to the API per minute?
The limit is 600 requests per minute per account, shared by all keys on that account. Above it the API returns 429 with a Retry-After header, so wait for that value before sending again.