Use CoralBricks with OpenCode
Run OpenCode's coding agent on CoralBricks open-model inference — GLM and Kimi with up to 1M context. Set one environment variable and CoralBricks shows up in the model picker.
OpenCode is an open-source terminal coding agent.
CoralBricks ships in OpenCode's built-in provider registry, so there is no
config file to write: export your API key and the CoralBricks models appear
in the picker. Chat, agent mode, and tool calling all route through the Coral
gateway.

No config file: the models show up once CORAL_API_KEY is set, then
opencode run does the work on GLM 5.2 — file writes, shell commands,
streaming.
1. Get an API key
Create a key from your API keys page — it looks like cb_....
2. Connect
Pick either route; both end up in the same place.
Connect once (desktop app or CLI). In the desktop app, add CoralBricks
from the provider list and paste the key. From the terminal:
opencode auth login
Either one saves the key to ~/.local/share/opencode/auth.json, which the
desktop app and the CLI both read — connect in one and the other is
connected too.
Or use the environment, which suits servers, CI, and throwaway shells:
export CORAL_API_KEY="cb_..."
Add that to your shell profile (~/.zshrc / ~/.bashrc) so it persists.
Note that a GUI app launched from the Dock does not inherit your shell
profile, so the desktop app needs the connect-once route (or a launch from
a terminal that already has the variable).
3. Run it
opencode # interactive TUI
opencode run "explain this repo" -m coralbricks/glm-5.2-fp4
opencode run "fix the failing test" -m coralbricks/kimi-k3
Switch models any time inside the TUI with /models, or set a default in
~/.config/opencode/opencode.json:
{
"$schema": "https://opencode.ai/config.json",
"model": "coralbricks/glm-5.2-fp4"
}
opencode models | grep coralbricks lists the three models, but it lists
them from the public registry whether or not you are authenticated — so it
confirms OpenCode can see CoralBricks, not that your key works. The first
opencode run is what proves the connection.
Available models
| Model |
Slug |
Context |
Input $/M |
Output $/M |
| GLM 5.2 |
coralbricks/glm-5.2-fp4 |
1M |
$1.12 |
$4.40 |
| Kimi K3 |
coralbricks/kimi-k3 |
1M |
$3.00 |
$15.00 |
| GPT-OSS 120B |
coralbricks/gpt-oss-120b |
128K |
$0.12 |
$0.60 |
Cached input tokens are always free.
Already added CoralBricks by hand?
Earlier versions of this guide had you define the provider yourself in
~/.config/opencode/opencode.json. That block is no longer needed, and if
you leave it in you will see CoralBricks listed twice in the model picker —
once from your config, once from the registry. Delete the provider entry
(and point model at coralbricks/glm-5.2-fp4) to clear the duplicate:
{
"$schema": "https://opencode.ai/config.json",
"model": "coralbricks/glm-5.2-fp4"
}
Notes
- Tool calling and agent mode work out of the box — the gateway emits
OpenAI-exact streaming tool calls; OpenCode's file edits, shell commands,
and multi-step agent loops run unmodified.
- Reasoning control: models think by default. Disable per request with
"reasoning": {"enabled": false} if you call the API directly; OpenCode
manages this itself.
- Long context is the point — GLM 5.2 and Kimi K3 take up to 1M tokens,
so whole-repo context and long agent sessions fit without pruning.
- The API is OpenAI wire-format at
https://inference.coralbricks.ai/v1 —
the same config shape works in any tool that speaks OpenAI-compatible
providers (Cline, Continue, aider). See the
API reference for the full surface.