Connect OpenCode to DIAL
In this tutorial you register DIAL as a custom provider in OpenCode, the terminal coding agent, then run a prompt against it. OpenCode speaks Chat Completions, so it talks to DIAL directly — no proxy needed. Every turn then runs on your DIAL deployment. This tutorial is for developers who already have a DIAL host and OpenCode installed.
Prerequisites
- A DIAL host and API key. See Before you begin.
- OpenCode installed —
npm i -g opencode-ai, or the installer at opencode.ai.
What you'll build
DIAL registered as a custom OpenCode provider. By the end, opencode run sends a prompt to your DIAL deployment and prints the reply.
Step 1: Set your DIAL key
Bash or Zsh:
export DIAL_API_KEY="<DIAL_API_KEY>"
PowerShell:
$env:DIAL_API_KEY = "<DIAL_API_KEY>"
Step 2: Add DIAL as a provider
Create opencode.json in your project directory (or globally at ~/.config/opencode/opencode.json; on Windows, %USERPROFILE%\.config\opencode\opencode.json). DIAL's deployment id is part of baseURL, so add one provider/model entry per deployment.
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"dial": {
"npm": "@ai-sdk/openai-compatible",
"name": "DIAL",
"options": {
"baseURL": "https://<YOUR_DIAL_HOST>/openai/deployments/gpt-5.5-2026-04-24",
"apiKey": "{env:DIAL_API_KEY}"
},
"models": {
"gpt-5.5-2026-04-24": {
"name": "GPT-5.5 (DIAL)",
"limit": { "context": 200000, "output": 128000 }
}
}
}
}
}
When you give a model a limit block, OpenCode requires both context and output. Set output to the deployment's maximum completion tokens — 128000 for gpt-5.5-2026-04-24. DIAL rejects a turn that asks for more than the ceiling with max_tokens is too large, so never set it higher than the deployment allows.
Note
Pick your deployment with the wire in mind.
@ai-sdk/openai-compatiblesends a plainmax_tokensand noapi-version, whichgpt-5.5-2026-04-24accepts. Some other GPT-5.x deployments reject a plainmax_tokens(wantingmax_completion_tokens) or require anapi-version, and OpenCode supplies neither — see Azure-backed deployment settings. DIAL accepts the key as a Bearer token viaapiKey; if your DIAL only accepts theApi-Keyheader, add"headers": { "Api-Key": "{env:DIAL_API_KEY}" }underoptions.
Step 3: Run OpenCode
opencode run --model dial/gpt-5.5-2026-04-24 "Reply with exactly: PONG"
Verify:
You see PONG. Launch plain opencode for the interactive TUI and pick the DIAL model from the model switcher.
What you learned
- How to register DIAL as a custom
@ai-sdk/openai-compatibleprovider inopencode.json. - How to set a model's
limit.outputto the deployment's completion-token ceiling. - How to run a prompt against your DIAL deployment from the terminal.
Good to know
- OpenCode uses Chat Completions, so it reaches DIAL directly — no proxy needed, unlike Codex. Deployments exposed only over the Responses API are not reachable this way.
- When a model has a
limitblock, OpenCode requireslimit.output. Set it to the deployment's max completion tokens; DIAL rejects a value above that ceiling withmax_tokens is too large. - Add one provider entry per DIAL deployment — the deployment id lives in
baseURL. - Tool calling and vision work only when the DIAL deployment advertises those capabilities.
Next steps
- Connect Claude Code to DIAL — a command-line agent that uses the native Anthropic Messages API
- Agentic tools overview — shared prerequisites and the other tools
- OpenCode custom providers — the provider configuration reference