OpenCode With an OpenAI-Compatible API: 2026 Setup Guide

Guides · 2026-11-29 · 9 min read

All blog posts · Model pricing · API docs

What OpenCode needs from a provider

OpenCode is an open-source terminal coding agent: it reads a repository, plans edits, calls tools and streams changes back to the terminal. Under the hood it needs the same three things every OpenAI-compatible client needs — a base URL, a bearer key and a model identifier — plus reliable streaming and tool calling.

That makes a gateway a practical backend: one key and one base URL can expose several model families, and switching between them is a config edit rather than a new integration. This guide uses API Volta as the example endpoint; the same provider block works with any gateway that speaks the OpenAI chat completions contract.

Step 1: create an API key

Create an API Volta account, open the console and add a key. Copy it once and store it in your local secret manager or shell environment. Never commit the key to a repository, and never paste it into an issue or a screenshot.

The key inherits your account's prepaid balance. A $5 card top-up or a $3 USDT top-up is enough to evaluate a coding workflow; token usage is billed per request at the published rate of whichever alias you select.

Step 2: add the provider block

OpenCode reads a project or global opencode.json. The provider block below registers API Volta as an OpenAI-compatible provider and lists three aliases you can pick from. Save it at the repository root or in the global config location used by your OpenCode version.

OpenCode's configuration schema has changed between releases. The block above matches the 2026 provider format; if an option is rejected, compare it with the OpenCode provider documentation for your installed version before changing the gateway URL.

{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "apivolta": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "API Volta",
      "options": {
        "baseURL": "https://app.apivolta.com/v1"
      },
      "models": {
        "DeepSeek-V4-Pro": { "name": "DeepSeek V4 Pro" },
        "Kimi-K2.7-Code": { "name": "Kimi K2.7 Code" },
        "GLM-5.3": { "name": "GLM-5.3" }
      }
    }
  },
  "model": "apivolta/DeepSeek-V4-Pro"
}

Step 3: store the key

Run opencode auth login, choose the custom/other provider option, enter the provider id apivolta and paste the API key. Credentials are stored in OpenCode's local auth file, outside the repository. If you prefer environment-based injection, set the key in your shell profile or secret manager and keep it out of the project tree.

Model identifiers use the provider prefix: apivolta/DeepSeek-V4-Pro. Aliases are case-sensitive. A lowercase copy returns no available channel even though the model exists in the catalog.

Which published aliases fit coding work

AliasInput $ / 1MOutput $ / 1MContext windowBest role
MiniMax-M3.1-Flash0.100.40262,144High-volume edits and file sweeps
DeepSeek-V4-Flash0.180.36131,072Fast plan-and-edit loops
Kimi-K2.60.652.68262,144Mixed coding and long-document work
DeepSeek-V4-Pro0.671.34262,144Default for multi-file changes
GLM-5.31.164.06262,144Hard refactors and synthesis
Kimi-K2.7-Code1.164.81262,144Coding-tuned tool loops

Prices reflect the catalog published on 2026-11-29. Test tool-calling behavior on small tasks before committing a long session to one alias.

What one agent task costs

A realistic coding task sends a large input: repository context, instructions, tool output and previous turns. The output is usually much smaller. This probe uses 200k input and 30k output tokens per task, billed at published rates:

AliasPer task1,100 tasks / month
MiniMax-M3.1-Flash≈ $0.032≈ $35
DeepSeek-V4-Flash≈ $0.047≈ $52
DeepSeek-V4-Pro≈ $0.174≈ $191
Kimi-K2.6≈ $0.210≈ $231
GLM-5.3≈ $0.354≈ $389
Kimi-K2.7-Code≈ $0.376≈ $414

Input tokens dominate agent bills. A cheaper alias that needs one extra retry per task can erase its advantage, so measure pass rate and task length, not just the sticker rate.

Validate tool calling before a long session

Tool use is a model behavior, not a gateway feature. The gateway forwards the standard tool-calling contract, but each model may interpret the schema differently. Run this five-task check on your own repository before trusting an alias with a large refactor:

1. Single-file edit with an exact diff.

2. Multi-file rename that touches imports and tests.

3. Shell command with a non-zero exit code, to see whether the agent recovers.

4. Ambiguous request, to see whether it asks a clarifying question instead of guessing.

5. Long-context task near the model's window, to check truncation behavior.

If an alias loops, drops tool calls or ignores file boundaries, switch aliases. The request shape stays identical, so the only change is the model string.

Troubleshooting checklist

SymptomCheck
401 / invalid keyKey copied fully, no trailing space, Authorization header present
No available channelAlias spelling and case match the published catalog
429 / rate limitedConcurrency cap, retry with jitter, shorter context
Empty or truncated outputContext window of the selected alias, max output setting
Tool calls ignoredModel supports tool use; validate on a small task first

Questions

Is OpenCode affiliated with API Volta?
No. OpenCode is an independent open-source project. API Volta only provides an OpenAI-compatible endpoint that OpenCode can be configured to use.
Which model should I start with in OpenCode?
Start with DeepSeek-V4-Pro for multi-file edits or Kimi-K2.7-Code for coding-tuned tool loops, then compare against MiniMax-M3.1-Flash on the same five-task check. The lowest-cost alias that completes the task without retries usually wins.
Why does my model string return no available channel?
Aliases are case-sensitive. Use the alias exactly as published, for example DeepSeek-V4-Pro rather than deepseek-v4-pro, and confirm it still appears on the model pricing page.
Can I reuse one key across OpenCode, Cline and Cursor?
Yes. All three can point at the same base URL with the same key. Create separate keys per tool if you want to attribute spend or revoke one tool without interrupting the others.
Does API Volta support streaming and tool calls?
Yes. Requests use the standard chat completions contract, including server-sent-event streaming and tool-calling fields. Whether a specific model follows a tool schema well is a model behavior that should be tested on your own tasks.

Prices reflect the catalog published on 2026-11-29 and may vary by provider, region and account. The live list is on model pricing.

Create an account · Full price table · Day Pass · support@apivolta.com

Keep reading