Skip to content
FluxCDNFluxCDN
esc
On this page

DocsTools guide

OpenCode with FluxCDN AI

OpenCode reads and changes code from the terminal (and its desktop app and editor extension). You add FluxCDN to it as an OpenAI-compatible provider.

Licence:
MIT, open source
Platforms:
macOS, Linux, Windows (it recommends WSL)
Address (OpenAI-compatible):
https://ai.fluxcdn.cloud/api/v1
The tool's own docs ↗

Before you start

  • Create an API key. On the API keys page press “Create key” and copy the key right away. It starts with flux_live_ and is never shown in full again.
  • Give agents a key of their own and set a daily or monthly spending limit on it with “Limits”. Agents send request after request by themselves; the limit stops spending you didn't expect.
  • Have some credit in the account (Billing).
  • In the examples, put your own key where it says flux_live_YOUR_KEY.

Set it up

  1. Step 1: Give OpenCode the key

    In OpenCode type /connect, choose Other at the bottom of the list, enter fluxcdn as the provider id and paste the key. It is kept in ~/.local/share/opencode/auth.json.

  2. Step 2: Pick a model setup and write opencode.json

    For every project in ~/.config/opencode/opencode.json, or for one project at its root. Every model you want must be listed under models; give limit too, as OpenCode doesn't know a custom provider's model sizes.

    Pick a setup; the settings below change with it. Any id from the models page works in their place too.

    Price per million tokens. Free plan prices, in Toman at today's rate. Routers (router/auto and the like) are not recommended for agents: an agent needs a model that is sure to support tools.

    ~/.config/opencode/opencode.json
    {
      "$schema": "https://opencode.ai/config.json",
      "provider": {
        "fluxcdn": {
          "npm": "@ai-sdk/openai-compatible",
          "name": "FluxCDN AI",
          "options": {
            "baseURL": "https://ai.fluxcdn.cloud/api/v1"
          },
          "models": {
            "anthropic/claude-haiku-5.5": { "name": "Claude Haiku 5.5", "limit": { "context": 1000000, "output": 32000 } },
            "anthropic/claude-sonnet-5.5": { "name": "Claude Sonnet 5.5", "limit": { "context": 1000000, "output": 32000 } }
          }
        }
      },
      "model": "fluxcdn/anthropic/claude-sonnet-5.5",
      "small_model": "fluxcdn/anthropic/claude-haiku-5.5"
    }

    Instead of /connect, the key can come from an environment variable: add "apiKey": "{env:FLUXCDN_API_KEY}" to options.

  3. Step 3: Pick the model

    Type /models in OpenCode and pick one of the FluxCDN models.

Check it works

  1. Step 1: Try it from the terminal

    The first lists the models you set up, the second sends one message. If it fails, add --print-logs.

    Terminal
    opencode models fluxcdn
    opencode run "Say hello in one sentence"

Troubleshooting

A 401 with the key from an environment variable
When the variable isn't set, {env:FLUXCDN_API_KEY} becomes empty and the request goes without a key. Set the variable in that terminal, or give the key with /connect.
The model isn't in /models
Each model must be listed under models in opencode.json. Its full name in OpenCode looks like fluxcdn/deepseek/deepseek-v4-pro.
Error 401 or invalid_api_key
The key wasn't copied whole, was revoked, or went in the wrong field. It starts with flux_live_ and has no spaces. If the tool reads it from an environment variable, open a new terminal or window after setting it.
Error 402, insufficient_credit (in Codex: insufficient_quota) although you have credit
Before each request, the most it could cost is set aside from your credit. When the answer ends, only the real cost is taken and the rest is released. A tool that asks for a very long output on every request sets aside a large amount. Lower the tool's output limit (for example to 32000 tokens) or add credit.
Error 404 or model_not_found
The model id must be exactly as on the models page, with the maker's prefix: anthropic/claude-sonnet-5.5, not claude-sonnet-5.5. Lower case and dots matter. Copy the id rather than typing it.
A 404 that doesn't mention the model
The base address is wrong. Most tools want https://ai.fluxcdn.cloud/api/v1 and add the rest themselves; don't write /chat/completions twice and don't leave out /v1. See the which address table.
The agent calls no tools, or the model is missing from the agent's list
Pick a model that supports tools; it has the Tools label on the models page. Some tools need that switched on for the model (the steps above). Routers are not recommended for agents.
Error 429: rate_limit_exceeded or budget_exceeded
Either requests per minute went over the limit (wait a little; most tools retry by themselves), or this key's spending today or this month reached its limit. See it on API keys under “Limits”.
Error 502, 503, 504 or 529
The model's service was briefly unavailable. Send again; most tools do it themselves. A request that fails before answering costs nothing. If it lasts, switch to another model for a while.

Limits

  • OpenCode needs tool calling to work; pick a model with the Tools label.

What doesn't work this way →