OpenCode Integration
OGX includes built-in support for connecting OpenCode, a terminal-based AI coding assistant, with a single command. All available models on your OGX server are automatically configured and ready to use.
Quick Start
1. Start OGX
ogx go --no-auth --insecure
ogx go auto-detects running inference providers (vLLM, Ollama, OpenAI via OPENAI_API_KEY, and more). For a local, non-exposed server, --no-auth turns off the API key (no OGX_API_KEY needed below) and --insecure runs without TLS, so the connect step below needs no extra flags. Both are local-development only. By default, ogx go serves HTTPS with a self-signed certificate and prints API keys — pair those with ogx connect --insecure --api-key <key>.
2. Connect OpenCode
ogx connect opencode
That's it. OpenCode starts with all your OGX models available and the first model pre-selected.
OpenCode must be installed and on your PATH.
3. Test it out
The launched TUI is already connected — just type:
> What is 2+2?
> Create a Flask hello world app
How It Works
The ogx connect opencode command:
- Queries the running OGX server for available models
- Filters out embedding models
- Generates an OpenCode provider configuration with all discovered models
- Launches OpenCode with the generated configuration
ogx connect opencode
|
v
GET /v1/models (discover available models)
|
v
Generate OpenCode config (all LLM models)
|
v
Launch OpenCode with the generated config
|
v
OpenCode TUI (connected to OGX)
CLI Reference
ogx connect [--url URL] opencode [--model MODEL] [-- OPENCODE_ARGS...]
Options:
| Flag | Default | Description |
|---|---|---|
--model | First available model | Model to pre-select as the default in OpenCode |
--url (group) | https://localhost:8321/v1 | OGX server base URL, including /v1. Applies to all ogx connect subcommands (port defaults from OGX_PORT env var) |
--api-key (group) | OGX_API_KEY env var, or none | Bearer API key for the OGX server. Applies to all ogx connect subcommands. |
--insecure / -k (group) | off | Allow HTTPS connections to servers with untrusted (for example, self-signed) certificates, like curl -k. Only affects this connect invocation |
Arguments after -- are forwarded to the opencode command.
All discovered LLM models are available in OpenCode regardless of which model is set as the default. You can switch models inside OpenCode at any time.
Model selection
ogx connect opencode --model openai/gpt-4o
With a Remote OGX Server
ogx connect --url http://192.168.1.100:9000/v1 opencode
For more information about OGX's provider architecture, see Providers Overview. For OpenCode documentation, visit opencode.ai/docs.