OpenCode rejects the file with Unrecognized key: "providers": how to fix it

Coding with AIOpenCode·· 21 views· 3 min read

OpenCode has two ways to write a provider in its configuration file. Newer versions know both. Older ones only know the first and, when they find the second, they stop with Unrecognized key: "providers". The fix takes a minute: write the provider in the format every version accepts.

Why it happens

The current OpenCode documentation shows the new format, with "providers" (plural), "package", "settings" and "env". An OpenCode that does not know this format rejects the whole file. It does not read the provider, so the Interweb models do not show in /models.

The older format, with "provider" (singular), "npm" and "options", still works in the new versions: the OpenCode migration guide says that existing configuration is meant to keep working. That is why our documentation and these articles use it.

The fix

1 Open the file that gives the error: opencode.json or opencode.jsonc in the project folder, or ~/.config/opencode/opencode.jsonc for all projects.
2 Replace its whole content with the block below.
3 Save, close OpenCode completely and open it again.
4 Type /models and check that the Interweb models show.

{
"$schema": "https://opencode.ai/config.json",
"provider": {
"api": {
"npm": "@ai-sdk/openai-compatible",
"name": "Interweb",
"options": {
"baseURL": "https://api.interweb.ao/v1",
"apiKey": "{env:INTERWEB_API_KEY}"
},
"models": {
"moonshotai/kimi-k2.7-code": { "name": "Kimi K2.7 Code", "limit": { "context": 262144, "output": 16000 } },
"deepseek-ai/deepseek-v4-pro": { "name": "DeepSeek V4 Pro", "limit": { "context": 1048576, "output": 16000 } },
"zai-org/glm-5.2": { "name": "GLM 5.2", "limit": { "context": 1048576, "output": 16000 } },
"deepseek-ai/deepseek-v4-flash": { "name": "DeepSeek V4 Flash", "limit": { "context": 1048576, "output": 16000 } }
}
}
},
"model": "api/moonshotai/kimi-k2.7-code"
}

What changes from one format to the other

New format (rejected) Format that always works
"providers" "provider"
"package" "npm": "@ai-sdk/openai-compatible"
"settings": { "baseURL": ... } "options": { "baseURL": ... }
"env": ["INTERWEB_API_KEY"] "apiKey": "{env:INTERWEB_API_KEY}", inside "options"

The models block, with the catalogue id and its slash, and the model line stay the same.

env takes the variable name, never the key

In the new format, "env" takes the name of the variable, such as INTERWEB_API_KEY. In "apiKey", {env:INTERWEB_API_KEY} also takes the name. If you paste the key itself there, OpenCode looks for a variable with that name, does not find it and the request goes without a key: the API answers 401.

If the key was written in a file that went to Git or to someone else, revoke it and create another. See what to do, in the right order.
The step-by-step setup of the file, from scratch, is in OpenCode with All in One AI. Other errors are in errors when setting up a tool.

Want OpenCode working with our models? Visit the Coding with AI page.

See Coding with AI

SEE ALSO

OpenCode with All in One AI: creating opencode.json from scratch, the key and the models

Keeping the key out of opencode.jsonc, and setx on Windows

OpenCode for all projects or for one: the global opencode.jsonc and the project file

Errors when setting up a tool with All in One AI: 401, model not found, no credits, /v1 and rejected config files

Coding with AI in All in One AI

RECOMMENDED PRODUCT

Web hosting with cPanel

Domain and SSL included, daily backups and the panel you already know. from $6.59/mo (3-year plan, with coupon)

See plans
Was this answer helpful? Your answer helps us improve this article.