Skip to main content

Connect OpenCode to DIAL

Introduction

From this tutorial, you will learn how to 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. By the end, opencode run sends a prompt to your DIAL deployment and prints the reply.

Prerequisites

  • A DIAL host and API key. Refer to Prerequisites.
  • OpenCode installed — npm i -g opencode-ai, or the installer at opencode.ai.

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-compatible sends a plain max_tokens and no api-version, which gpt-5.5-2026-04-24 accepts. Some other GPT-5.x deployments reject a plain max_tokens (wanting max_completion_tokens) or require an api-version, and OpenCode supplies neither — refer to Azure-backed deployment settings. DIAL accepts the key as a Bearer token via apiKey; if your DIAL only accepts the Api-Key header, add "headers": { "Api-Key": "{env:DIAL_API_KEY}" } under options.

Step 3: Run OpenCode

opencode run --model dial/gpt-5.5-2026-04-24 "Reply with exactly: PONG"

You see PONG. Launch plain opencode for the interactive TUI and pick the DIAL model from the model switcher.

Additional Information

  • 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 limit block, OpenCode requires limit.output. Set it to the deployment's max completion tokens; DIAL rejects a value above that ceiling with max_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.