Documentation / Connect

Connect → OpenCode

Use AxForge with OpenCode

OpenCode is an open-source coding agent for the terminal. It takes any OpenAI-compatible service as a provider in its config file.

Before you start
  • An AxForge API key. Get one (a minute).
  • Node.js 18 or newer. This guide was tried with OpenCode 2.3.0 on 2026-11-15.

Set it up

  1. Install OpenCode

    npm install -g @opencode/cli

    Had OpenCode before? If opencode --version says 1.x, remove that one first with npm uninstall -g opencode-ai, then install as above. opencode --version then says 2.x.

  2. Add AxForge to your project

    In your project folder, create a file opencode.json:

    {
      "$schema": "https://opencode.ai/config.json",
      "provider": {
        "axforge": {
          "npm": "@ai-sdk/openai-compatible",
          "name": "AxForge",
          "options": {
            "baseURL": "https://api.axforge.ai/v1"
          },
          "models": {
            "glm-5.3-flash": { "name": "GLM-5.3-Flash", "limit": { "context": 500000, "output": 16384 }, "options": { "reasoningEffort": "high" } },
            "mimo-v2.6-flash": { "name": "MiMo-V2.6-Flash", "limit": { "context": 262144, "output": 16384 } },
            "qwen3.8-27b": { "name": "Qwen3.8 27B", "limit": { "context": 262144, "output": 16384 } }
          }
        }
      },
      "model": "axforge/glm-5.3-flash"
    }

    The last line makes GLM-5.3-Flash the model OpenCode starts with, the one we set up for coding. GLM thinks before each step; its "reasoningEffort": "high" has it think harder than its default, low. Each model's limit tells OpenCode how much it reads at once (500,000 tokens for GLM, 262,144 for the other two), so it shortens a long session before it reaches that. The key is not in the file: you give it to OpenCode in the next step.

    opencode.json in the project folder, with the AxForge provider and its three models, GLM-5.3-Flash first
  3. Give OpenCode your key, once

    In the same folder:

    opencode auth login axforge

    Paste your key and press Enter. It says Connected to AxForge. OpenCode keeps the key, so every project with this opencode.json uses it and you don't give it again.

    opencode auth login axforge: the key hidden as dots, Connected to AxForge, Done
  4. Start it in your project

    cd my-project
    opencode

    Under the message box it says GLM-5.3-Flash AxForge.

    OpenCode started in a terminal, GLM-5.3-Flash AxForge under the message box
  5. Give it a task

    Ask in plain words. It finds the file, edits it and shows the result.

    OpenCode adding a function is_even to utils.py and showing the file, on GLM-5.3-Flash from AxForge

The settings

SettingValue
npm@ai-sdk/openai-compatible
options.baseURLhttps://api.axforge.ai/v1
the keyopencode auth login axforge, in the project folder
modelsglm-5.3-flash, mimo-v2.6-flash, qwen3.8-27b
options (glm-5.3-flash)reasoningEffort high
limitcontext 500000 (GLM) or 262144 (the other two), output 16384
modelaxforge/glm-5.3-flash

Which model for what: glm-5.3-flash is the one for coding and thinks before it answers, mimo-v2.6-flash is the fastest, qwen3.8-27b reads images. To start on another one, change the last line of the file, for example to axforge/mimo-v2.6-flash.

Check that it works

Under the message box it says GLM-5.3-Flash AxForge, and a task gets done. The calls show in the console under API Keys → Recent calls within a minute.

When it does not work

Not sure which it is? The connection doctor makes seven small checks on your key and names the fix: irm https://dev.axforge.ai/assets/axforge-doctor.ps1 | iex in PowerShell, curl -fsSL https://dev.axforge.ai/assets/axforge-doctor.sh | bash on macOS and Linux.

What you seeWhat it meansFix
"Invalid API key. Create one at https://console.axforge.ai/keys."OpenCode has no key for axforge, or it was refusedrun opencode auth login axforge again in your project folder (step 3); or make a new key
"Integration not found: axforge"OpenCode was started outside your projectrun it in the folder that holds opencode.json (step 2)
"Database is not empty and has no session table"an OpenCode 1 meets the data an OpenCode 2 (such as the OpenCode app) has already updated; nothing is lostnpm uninstall -g opencode-ai, then npm install -g @opencode/cli (step 1)
Another model or provider under the message boxthe config file was not foundstart OpenCode in the folder that holds opencode.json, and check its name

Test a call says in one click whether a problem is your key, your balance or us.

On the forum (1) Markdown For AI Updated 2026-11-26

Questions about this page

From the forum, most viewed first.

1replies
26views
2026-11-15 23:34
Ask about this page