OpenCode

OpenCode

OpenCode supports any OpenAI-compatible API as a custom provider, using the @ai-sdk/openai-compatible package against https://api.abliteratedllm.dev/v1. The setup below works with OpenCode 1.x and 2.x.

Placeholders: $API_BASE is https://api.abliteratedllm.dev/v1, $API_ORIGIN is https://api.abliteratedllm.dev, and $YOUR_KEY is your API key.

Signed in? The API keys page has this file ready-made for every model we currently serve, with live prices, a highlighted provider block and a download button.

1. Add the provider to opencode.json

The global config is ~/.config/opencode/opencode.json on macOS and Linux, and %USERPROFILE%\.config\opencode\opencode.json on Windows. For one project only, use opencode.json in the project root instead.

{
  "$schema": "https://opencode.ai/config.json",
  "model": "abliteratedllm/glm-5.3-flash-abliterated",
  "provider": {
    "abliteratedllm": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "AbliteratedLLM",
      "options": {
        "baseURL": "$API_BASE",
        "apiKey": "{env:ABLITERATEDLLM_API_KEY}"
      },
      "models": {
        "glm-5.3-flash-abliterated": {
          "name": "GLM-5.3 Flash Abliterated",
          "reasoning": true,
          "tool_call": true,
          "attachment": false,
          "modalities": {
            "input": [
              "text"
            ],
            "output": [
              "text"
            ]
          },
          "limit": {
            "context": 262144,
            "output": 65536
          },
          "cost": {
            "input": 0.0977,
            "output": 0.3421,
            "cache_read": 0.0098,
            "cache_write": 0
          }
        }
      }
    }
  }
}
  • New file: save it as shown. Existing file: copy only the "abliteratedllm" entry into your "provider" object, with a comma between it and the provider before it, and keep your other providers. Set "model" only if you want it as your default.
  • npm is @ai-sdk/openai-compatible, which calls /v1/chat/completions.
  • The keys under models must be our model ids exactly. Add one entry per id from GET /v1/models; the file on the dashboard already lists them all.
  • limit.context and limit.output are the model's context_length and max_output_tokens from GET /v1/models, so OpenCode knows how much context is left. On a trial account, output is capped at 4096 tokens regardless.
  • cost is in USD per 1M tokens (input, output and cached input), so OpenCode's cost display matches what we bill. We don't charge for cache writes.
  • reasoning marks models that reason before they answer. attachment and modalities keep OpenCode from sending images, which the API rejects.
  • Leave out the V1 api field. When OpenCode 2 migrates a config that sets it, it replaces baseURL with its value (issue #50286).

2. Connect your key

The file reads your key from the ABLITERATEDLLM_API_KEY environment variable through {env:ABLITERATEDLLM_API_KEY}, so the key never goes in the file.

Bash or Zsh (add the line to ~/.zshrc or ~/.bashrc to keep it):

export ABLITERATEDLLM_API_KEY="$YOUR_KEY"

Windows (applies to terminals you open afterwards):

setx ABLITERATEDLLM_API_KEY "$YOUR_KEY"

To store the key with /connect instead, first delete the "apiKey" line from the file, and the comma at the end of the "baseURL" line above it. Then start opencode, run /connect, choose Other, enter the provider id abliteratedllm and paste $YOUR_KEY. OpenCode 1.x saves it in ~/.local/share/opencode/auth.json.

Use one method, not both. OpenCode 1.x prefers a key set in the file over one saved with /connect, and an {env:…} variable that isn't set becomes an empty key, so the saved key would be ignored. When you rotate keys, update the variable or run /connect again.

3. Pick the model and say hi

opencode --model abliteratedllm/glm-5.3-flash-abliterated

The file's "model" already makes it the default, so plain opencode works too. Run /models to switch to another of our models.

Good to know

  • Text only. Image attachments fail with 400 unsupported_content.
  • Trial accounts allow 1 concurrent request, which is tight for agent work. See Rate limits and trial.

Verified against OpenCode docs on 2026-11-03: Providers, custom provider, Config, variables and Models.