OpenCode
Run OpenCode through OpenLLM with openllm opencode, which adds an openllm provider with all your models per session and leaves your own config untouched.
| Command | openllm opencode |
| Mode | Per session. Nothing is installed. |
| Talks to | OpenAI-compatible Chat Completions at <gateway>/v1 |
| Default model | openllm/ultra |
| Skip approvals | Not available. OpenCode has no such flag. |
| Remove | Nothing to remove. Run opencode directly. |
Before you begin
- Install the OpenLLM CLI. See Install.
- Install OpenCode so that
opencodeis on yourPATH. If it is missing,openllm opencodeprints the official installer,https://opencode.ai/install. - Have at least one model available. See Providers.
Set up with openllm opencode
openllm opencodeEvery argument after opencode goes to OpenCode unchanged, so openllm opencode run "…" runs a non-interactive task. OpenLLM's own flags go before the client name: --new and --attach [id]. openllm -d opencode exits with an error, because OpenCode has no skip-approvals flag.
At launch, OpenLLM picks a gateway: your local daemon at http://127.0.0.1:8787 if it answers, otherwise https://www.openllm.sh. It then:
- Reads your
~/.config/opencode/opencode.json(or$XDG_CONFIG_HOME/opencode/opencode.json). - Merges in an
openllmprovider:@ai-sdk/openai-compatiblewithbaseURLset to<gateway>/v1, your key, and every model in your catalog. - Sets the default model to
openllm/ultraand adds theopenllmMCP server. - Writes the result to
~/.openllm/run/opencode/<pid>/opencode.jsonand pointsOPENCODE_CONFIGat it.
The merged file contains your key. It is readable only by you and is deleted when OpenCode exits. If your own config cannot be parsed, OpenLLM uses its provider block alone; it never writes your file back.
Interactive sessions run in a background session host. Run openllm --new opencode to skip the offer to attach to a running session.
Choose models
OpenCode shows OpenLLM models as openllm/<id>: openllm/ultra, openllm/plus, openllm/lite, and openllm/<provider>/<model> for each model you have activated. The default is openllm/ultra.
To pin a model, pick it in OpenCode's model picker. For a non-interactive run, pass OpenCode's flag: openllm opencode run --model openllm/plus "…". To change what the aliases resolve to, edit the chains in Configuration. See Routing and fallback.
OpenCode sessions get OpenLLM memory tools through MCP. See Memory.
Who pays for a request
The model that serves the request decides. A subscription hop runs on your own login through the daemon on one of your devices. An API-key hop bills your provider account. Included openllm/ models count against your plan's allowance. See Providers and Plans and limits.
Check that it works
openllm opencode run "Reply with OK"The reply prints to your terminal. Open Overview in the app: the request appears with the model that served it.
Common problems
| Symptom | Cause | Fix |
|---|---|---|
OpenCode is not installed | opencode is not on your PATH | Install OpenCode, then run openllm opencode again |
OpenCode has no skip-approvals flag, so -d does not apply. | -d has no OpenCode equivalent | Run without -d |
No models are available for your OpenLLM account. | Nothing in your model list | Connect a provider on Providers |
The openllm provider lists no models | The catalog fetch failed at launch | Check your connection and launch again |
| A new provider's models are missing | The catalog is read at launch | Exit and run openllm opencode again |
For anything else, see Troubleshooting.
Remove it
There is nothing to uninstall. Exit OpenCode and run opencode directly to use it without OpenLLM. Temporary files are deleted on exit.
Last updated on
Codex
Run the Codex CLI through OpenLLM with openllm codex, pick a model with -m, or add OpenLLM as a custom model provider in ~/.codex/config.toml.
Grok Build
Run Grok Build through OpenLLM with openllm grok, choose from your OpenLLM models in each session, and keep your ~/.grok config and auth.json unchanged.