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

All in One AI·· 19 views· 12 min read

OpenCode is an open-source coding agent that works in the terminal. It speaks the OpenAI format (Chat Completions), so it can use All in One AI models, paid with AI credits or with the Coding Plan. Its configuration is a JSON file. This article shows how to create it from scratch, even if you have never done it.

Before you start

1 Create a key in the API Center with the ai:read and ai:write permissions. Use a sandbox_ key to check the setup without spending and a prod_ key to work. The fields are explained in creating an API key.
2 Have AI credits or an active Coding Plan in All in One AI.
3 Have OpenCode installed, following the instructions on the official site, opencode.ai.

1. Keep the key in a variable

On Windows, open Command Prompt or PowerShell and type (with your key in quotes):

setx MOZOUT_API_KEY "prod_..."

setx saves the variable for the windows you open afterwards. Close the terminal and the tool, then open them again.

On Linux and macOS, type in the terminal:

export MOZOUT_API_KEY="prod_..."

To have the variable in every new terminal, add the same line at the end of ~/.bashrc or ~/.zshrc.

2. Where the file goes

For File
One project only (Windows, macOS and Linux) opencode.json, in the project folder
All projects (Linux and macOS) ~/.config/opencode/opencode.json

The OpenCode documentation does not give the location of the global file on Windows. On Windows, use the project file, which works the same. OpenCode accepts .json and .jsonc (the second lets you write comments).

3. Create the folder and the file

On Linux and macOS, for all projects:

mkdir -p ~/.config/opencode
nano ~/.config/opencode/opencode.json

On Windows, open PowerShell, go to the project folder (change the path to yours) and open the file in Notepad:

cd "C:\Projects\my-site"
notepad opencode.json

Notepad asks whether to create the file: answer yes. That way the name is exact. If you use Save as, choose All files (*.*) as the type: otherwise Windows adds .txt and the file becomes opencode.json.txt, which the tool does not read. Windows hides that ending. To check, type dir in the same folder: the name must end in .json.

4. Paste the configuration and save

Paste the whole block, exactly as it is:

{
"$schema": "https://opencode.ai/config.json",
"provider": {
"api": {
"npm": "@ai-sdk/openai-compatible",
"name": "MozOut",
"options": {
"baseURL": "https://api.mozout.com/v1",
"apiKey": "{env:MOZOUT_API_KEY}"
},
"models": {
"anthropic/claude-fable-5": { "name": "Claude Fable 5", "limit": { "context": 1000000, "output": 16000 } },
"anthropic/claude-fable-5.1": { "name": "Claude Fable 5.1", "limit": { "context": 1000000, "output": 16000 } },
"openai/gpt-6-astra-codex": { "name": "GPT 6 Astra Codex", "limit": { "context": 1050000, "output": 16000 } },
"anthropic/claude-fable-5.2-ccmax": { "name": "Claude Fable 5.2", "limit": { "context": 1000000, "output": 16000 } },
"openai/gpt-6.2-astra": { "name": "GPT 6.2 Astra", "limit": { "context": 1050000, "output": 16000 } },
"openai/gpt-6.2-astra-codex": { "name": "GPT 6.2 Astra Codex", "limit": { "context": 1050000, "output": 16000 } },
"openai/gpt-5.5": { "name": "GPT 5.5", "limit": { "context": 1050000, "output": 16000 } },
"anthropic/claude-opus-4.5-20251101-coding": { "name": "Claude Opus 4.5", "limit": { "context": 200000, "output": 16000 } },
"anthropic/claude-opus-4.6": { "name": "Claude Opus 4.6", "limit": { "context": 1000000, "output": 16000 } },
"anthropic/claude-opus-4.7": { "name": "Claude Opus 4.7", "limit": { "context": 1000000, "output": 16000 } },
"anthropic/claude-opus-4.8": { "name": "Claude Opus 4.8", "limit": { "context": 1000000, "output": 16000 } },
"anthropic/claude-opus-5": { "name": "Claude Opus 5", "limit": { "context": 1000000, "output": 16000 } },
"anthropic/claude-opus-5.5": { "name": "Claude Opus 5.5", "limit": { "context": 1000000, "output": 16000 } },
"moonshotai/kimi-k3.1-pro-highspeed": { "name": "Kimi K3.1 Pro HighSpeed", "limit": { "context": 1048576, "output": 16000 } },
"openai/gpt-5.6-sol-codex": { "name": "GPT 5.6 Sol Codex", "limit": { "context": 1050000, "output": 16000 } },
"anthropic/claude-sonnet-4.6": { "name": "Claude Sonnet 4.6", "limit": { "context": 200000, "output": 16000 } },
"moonshotai/kimi-k3": { "name": "Kimi K3", "limit": { "context": 1048576, "output": 16000 } },
"google/gemini-3.1-pro-preview": { "name": "Gemini 3.1 Pro Preview", "limit": { "context": 1000000, "output": 16000 } },
"anthropic/claude-sonnet-5": { "name": "Claude Sonnet 5", "limit": { "context": 1000000, "output": 16000 } },
"anthropic/claude-sonnet-5.5-aws": { "name": "Claude Sonnet 5.5", "limit": { "context": 1000000, "output": 16000 } },
"moonshotai/kimi-k3.1-pro": { "name": "Kimi K3.1 Pro", "limit": { "context": 1048576, "output": 16000 } },
"openai/gpt-6-sol-codex": { "name": "GPT 6 Sol Codex", "limit": { "context": 1050000, "output": 16000 } },
"openai/gpt-6.1-sol-codex": { "name": "GPT 6.1 Sol Codex", "limit": { "context": 1050000, "output": 16000 } },
"openai/gpt-6.2-sol-codex": { "name": "GPT 6.2 Sol Codex", "limit": { "context": 1050000, "output": 16000 } },
"google/gemini-2.5-pro": { "name": "Gemini 2.5 Pro", "limit": { "context": 1000000, "output": 16000 } },
"google/gemini-3.5-flash": { "name": "Gemini 3.5 Flash", "limit": { "context": 1048576, "output": 16000 } },
"qwen/qwen3.7-max": { "name": "Qwen3.7 Max", "limit": { "context": 1000000, "output": 16000 } },
"google/gemini-4-argon": { "name": "Gemini 4 Argon", "limit": { "context": 1048576, "output": 16000 } },
"google/gemini-3.6-flash": { "name": "Gemini 3.6 Flash", "limit": { "context": 1048576, "output": 16000 } },
"xai/grok-4.5": { "name": "Grok 4.5", "limit": { "context": 500000, "output": 16000 } },
"xai/grok-4.6": { "name": "Grok 4.6", "limit": { "context": 500000, "output": 16000 } },
"xai/grok-4.7": { "name": "Grok 4.7", "limit": { "context": 500000, "output": 16000 } },
"google/gemini-4-carbon-developer": { "name": "Gemini 4 Carbon", "limit": { "context": 1048576, "output": 16000 } },
"anthropic/claude-haiku-4.5-20251001": { "name": "Claude Haiku 4.5", "limit": { "context": 200000, "output": 16000 } },
"openai/gpt-6.1-terra-codex": { "name": "GPT 6.1 Terra Codex", "limit": { "context": 1050000, "output": 16000 } },
"zai-org/glm-5.3": { "name": "GLM 5.3", "limit": { "context": 1048576, "output": 16000 } },
"qwen/qwen3.8-max": { "name": "Qwen3.8 Max", "limit": { "context": 1000000, "output": 16000 } },
"bytedance/doubao-seed-2.1-pro-260628": { "name": "Doubao Seed 2.1 Pro", "limit": { "context": 262144, "output": 16000 } },
"zai-org/glm-5.1": { "name": "GLM 5.1", "limit": { "context": 202752, "output": 16000 } },
"deepseek-ai/deepseek-v4-pro": { "name": "DeepSeek V4 Pro", "limit": { "context": 1048576, "output": 16000 } },
"moonshotai/kimi-k2.6": { "name": "Kimi K2.6", "limit": { "context": 262144, "output": 16000 } },
"moonshotai/kimi-k2.7-code": { "name": "Kimi K2.7 Code", "limit": { "context": 262144, "output": 16000 } },
"google/gemini-3.7-flash": { "name": "Gemini 3.7 Flash", "limit": { "context": 1048576, "output": 16000 } },
"google/gemini-3.8-flash": { "name": "Gemini 3.8 Flash", "limit": { "context": 1048576, "output": 16000 } },
"zai-org/glm-5": { "name": "GLM 5", "limit": { "context": 202752, "output": 16000 } },
"qwen/qwen3.5-397b-a17b": { "name": "Qwen3.5 397BA17B", "limit": { "context": 262144, "output": 16000 } },
"zai-org/glm-5.2": { "name": "GLM 5.2", "limit": { "context": 1048576, "output": 16000 } },
"xai/grok-4.3": { "name": "Grok 4.3", "limit": { "context": 1000000, "output": 16000 } },
"bytedance/doubao-seed-2.0-pro-260215": { "name": "Doubao Seed 2.0 Pro", "limit": { "context": 262144, "output": 16000 } },
"google/gemini-3-flash-preview": { "name": "Gemini 3 Flash Preview", "limit": { "context": 200000, "output": 16000 } },
"qwen/qwen3.8-27b": { "name": "Qwen3.8 27B", "limit": { "context": 1048576, "output": 16000 } },
"tencent/hy4-preview": { "name": "Hunyuan 4 Preview", "limit": { "context": 1048576, "output": 16000 } },
"moonshotai/kimi-k2.5": { "name": "Kimi K2.5", "limit": { "context": 262144, "output": 16000 } },
"google/gemini-2.5-flash": { "name": "Gemini 2.5 Flash", "limit": { "context": 1048576, "output": 16000 } },
"google/gemini-3.5-flash-lite": { "name": "Gemini 3.5 Flash Lite", "limit": { "context": 1048576, "output": 16000 } },
"qwen/qwen3.5-plus": { "name": "Qwen3.5 Plus", "limit": { "context": 1000000, "output": 16000 } },
"bytedance/doubao-seed-2.1-turbo-260628": { "name": "Doubao Seed 2.1 Turbo", "limit": { "context": 262144, "output": 16000 } },
"qwen/qwen3.5-122b-a10b": { "name": "Qwen3.5 122B A10B", "limit": { "context": 262144, "output": 16000 } },
"qwen/qwen3.5-27b": { "name": "Qwen3.5 27B", "limit": { "context": 262144, "output": 16000 } },
"qwen/qwen3.6-plus": { "name": "Qwen3.6 Plus", "limit": { "context": 1000000, "output": 16000 } },
"bytedance/doubao-seed-2.0-lite-260428": { "name": "Doubao Seed 2.0 Lite", "limit": { "context": 262144, "output": 16000 } },
"qwen/qwen3.7-plus": { "name": "Qwen3.7 Plus", "limit": { "context": 1000000, "output": 16000 } },
"google/gemini-3.1-flash-lite": { "name": "Gemini 3.1 Flash Lite", "limit": { "context": 1048576, "output": 16000 } },
"deepseek-ai/deepseek-v4.1-flash": { "name": "DeepSeek V4.1 Flash", "limit": { "context": 1048576, "output": 16000 } },
"meituan-longcat/longcat-2.0": { "name": "LongCat 2.0", "limit": { "context": 1048756, "output": 16000 } },
"xiaomi/mimo-v2.5-pro": { "name": "MiMo V2.5 Pro", "limit": { "context": 1024000, "output": 16000 } },
"qwen/qwen3.6-35b-a3b": { "name": "Qwen3.6 35B A3B", "limit": { "context": 262144, "output": 16000 } },
"bytedance/doubao-seed-character-260628": { "name": "Doubao Seed Character", "limit": { "context": 131072, "output": 16000 } },
"tencent/hy3": { "name": "Hunyuan 3", "limit": { "context": 262144, "output": 16000 } },
"zai-org/glm-5.3-flash": { "name": "GLM 5.3 Flash", "limit": { "context": 1048576, "output": 16000 } },
"deepseek-ai/DeepSeek-V3.2-Exp": { "name": "DeepSeek V3.2 Exp", "limit": { "context": 163840, "output": 16000 } },
"deepseek-ai/deepseek-v3.2": { "name": "DeepSeek V3.2", "limit": { "context": 163840, "output": 16000 } },
"anthropic/claude-haiku-5.5-ccmax": { "name": "Claude Haiku 5.5", "limit": { "context": 1000000, "output": 16000 } },
"openai/gpt-6-luna-codex": { "name": "GPT 6 Luna Codex", "limit": { "context": 1050000, "output": 16000 } },
"bytedance/doubao-seed-2.0-mini-260428": { "name": "Doubao Seed 2.0 Mini", "limit": { "context": 262144, "output": 16000 } },
"google/gemini-2.5-flash-lite": { "name": "Gemini 2.5 Flash Lite", "limit": { "context": 1048576, "output": 16000 } },
"qwen/qwen3.5-flash": { "name": "Qwen3.5 Flash", "limit": { "context": 1000000, "output": 16000 } },
"deepseek-ai/deepseek-v4-flash": { "name": "DeepSeek V4 Flash", "limit": { "context": 1048576, "output": 16000 } },
"dots-studio/dots-3-note-prev-free": { "name": "Dots 3 Note Preview", "limit": { "context": 512000, "output": 16000 } }
}
}
},
"model": "api/moonshotai/kimi-k2.7-code"
}

Part What it does
"api" The provider id. It can have another name, but it must match the start of model.
npm The package that speaks the OpenAI format. OpenCode handles it on its own.
baseURL Our address, with /v1.
apiKey {env:MOZOUT_API_KEY} reads the key from the variable in step 1, so the key is not in the file. If the variable does not exist, OpenCode puts an empty value there and the API answers 401.
models The models that show in OpenCode. Each one takes the catalogue id, with the slash.
limit The context and the maximum per answer. We reserve credits for the maximum output the tool asks for in each answer. That is why the examples ask for 16,000 tokens: it is enough for coding and needs a smaller balance than a higher value.
model The starting model: the provider, a slash and the catalogue id.

Save: in Notepad, Ctrl+S; in nano, Ctrl+O, Enter and Ctrl+X.

5. Open OpenCode and check

Close OpenCode completely and open it again. If you used the project file, open it inside that folder. Type /models: the MozOut provider's models should show. Pick one and say "hello". With a sandbox_ key, the answer is always "Resposta de teste (sandbox)." If you see it, everything is right. Then set the variable to the prod_ key and close and open OpenCode again.

The models in the list

For your own provider, OpenCode only shows the models written in models. The block in step 4 already has the 79 that support tools, from the most expensive to the cheapest. If you want fewer, delete the lines you do not use. In JSON the items are separated by commas, so the last line in models has no comma at the end.

The ids are in the Models tab of All in One AI or in the API list. On Linux and macOS:

curl "https://api.mozout.com/v1/models?type=text" -H "Authorization: Bearer $MOZOUT_API_KEY"

In Windows PowerShell:

curl.exe "https://api.mozout.com/v1/models?type=text" -H "Authorization: Bearer $env:MOZOUT_API_KEY"

Each model comes with its id (always with the slash), its context_length and its price in pricing. Listing the models spends no credits.

Use models that support tools (function calling), because OpenCode needs them to edit files and run commands:

Model Context What for
moonshotai/kimi-k2.7-code 262,144 tokens Built for coding: the starting point for everyday work.
deepseek-ai/deepseek-v4-pro 1,048,576 tokens Strong reasoning, for big changes and hard bugs.
zai-org/glm-5.2 1,048,576 tokens Made for agents: handles tools well in long tasks.
deepseek-ai/deepseek-v4-flash 1,048,576 tokens Fast and cheap, for background tasks and short questions.

The error "Unrecognized key: "providers""

Newer OpenCode versions have a new format, with "providers". A version that does not know it rejects the file with this error. The format in this article, with "provider", is still accepted, according to the OpenCode documentation, and works in every version. If you copied an example with "providers", replace it with this one. And if an example has "env", it takes the variable name, never the key.

Never write the key in opencode.json. The project file usually goes into the repository. With {env:MOZOUT_API_KEY}, the file only holds the variable name. If a key ends up in Git, see what to do, in the right order.
Other errors and what to do are in errors when setting up a tool with All in One AI.

Want to code with AI in OpenCode? Visit the Coding with AI page.

See Coding with AI

SEE ALSO

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

Which coding tool to use with All in One AI: OpenCode, Claude Code, Codex, Cursor, Cline, Kilo Code or Aider

Coding Plan: which plan to choose, what it costs and how to subscribe

The All in One AI MCP server: images, video and voice inside Claude Code, Codex and ChatGPT

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.60/mo (3-year plan, with coupon)

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