# Using OpenCode With Any OpenAI-Compatible API (2026 Setup Guide)

> Source: <https://dev.to/apivolta/using-opencode-with-any-openai-compatible-api-2026-setup-guide-23ec>
> Published: 2026-11-29 15:12:12+00:00

**Recommendation:** Route OpenCode's high-volume edits and file sweeps to the cheapest alias like MiniMax-M3.1-Flash and reserve pricier models for hard refactors, since input tokens dominate agent bills and a cheap model needing one extra retry can lose its advantage.
More in the playbook "Controlling LLM cost": <https://wpnews.pro/playbooks/llm-cost>

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 three things from a provider — a base URL, a bearer key and a model id — plus reliable streaming and tool calling.

I work on **API Volta**, an OpenAI-compatible gateway, so this guide uses it as the example endpoint. The same provider block works with any gateway that speaks the OpenAI chat completions contract.

Create an account, open the console and add a key. Store it in your local secret manager or shell environment. Never commit the key to a repository.

OpenCode reads a project or global `opencode.json`. Save this at the repository root or in the global config location used by your OpenCode version:

```
{
  "$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"
}
```

OpenCode's configuration schema has changed between releases. If an option is rejected, compare it with the OpenCode provider docs for your installed version.

Run `opencode auth login`, choose the custom/other provider option, enter the provider id `apivolta` and paste the key. Model identifiers use the provider prefix: `apivolta/DeepSeek-V4-Pro`.

| Alias | Input $/1M | Output $/1M | Context | Role | 
|---|---|---|---|---|
| MiniMax-M3.1-Flash | 0.10 | 0.40 | 262,144 | Volume edits and file sweeps | 
| DeepSeek-V4-Flash | 0.18 | 0.36 | 131,072 | Fast plan-and-edit loops | 
| Kimi-K2.6 | 0.65 | 2.68 | 262,144 | Mixed coding and document work | 
| DeepSeek-V4-Pro | 0.67 | 1.34 | 262,144 | Multi-file changes | 
| GLM-5.3 | 1.16 | 4.06 | 262,144 | Hard refactors and synthesis | 
| Kimi-K2.7-Code | 1.16 | 4.81 | 262,144 | Coding-tuned tool loops | 

Prices are the published catalog rates on 2026-11-29. The live table is the source of truth: [https://app.apivolta.com/pricing](https://app.apivolta.com/pricing)

If an alias loops or drops tool calls, switch aliases. The request shape stays identical, so only the model string changes.

A 200k-input + 30k-output task at published rates costs about $0.032 on MiniMax-M3.1-Flash, $0.047 on DeepSeek-V4.1-Flash, $0.174 on DeepSeek-V4-Pro and $0.376 on Kimi-K2.7-Code. Input tokens dominate agent bills, so a cheaper model that needs one extra retry can lose its advantage.

**API Volta** — one OpenAI-compatible endpoint, published USD per-token pricing, prepaid Pay-As-You-Go with a one-time trial quota for new accounts, optional 30-day Memberships from $19 (daily allowance resets at 00:00 UTC), and a $5 / 72-hour Unlimited Day Pass on DeepSeek V4.1 Flash with up to 5 parallel requests. Top-ups start at $5 by card or $3 in USDT.
