OpenCode custom provider: Claude, GPT and DeepSeek on Lazu

Guide OpenCode custom provider claude-sonnet-5-5claude-haiku-5-5 Lazu

Short answer: add a provider.lazu block to ~/.config/opencode/opencode.json with baseURL set to https://api.lazu.ai/v1. One Lazu key then lets OpenCode switch across Claude, GPT, Gemini, DeepSeek, Kimi, GLM, and Qwen, while keeping a separate lightweight small_model for background tasks.

The quick way: one script #

In Console › API Keys, pick a key, click Connect, select OpenCode, and copy the one-line setup command (or run this directly):

curl -fsSL https://api.lazu.ai/setup/opencode | sh -s -- \
  --model claude-sonnet-5-5 \
  --light claude-haiku-5-5 \
  --also gpt-6.1-sol \
  --also deepseek-v4-pro

The script prompts for your key interactively (keeping it out of shell history), merges the lazu provider into ~/.config/opencode/opencode.json, and runs a quick connectivity check. A PowerShell command is in the same modal on Windows.

Manual setup in opencode.json #

If you prefer keeping secrets in environment variables so your config file stays clean, export LAZU_API_KEY in your shell profile (~/.zshrc or ~/.bashrc):

export LAZU_API_KEY="sk-lazu-..."

Then edit ~/.config/opencode/opencode.json (or $XDG_CONFIG_HOME/opencode/opencode.json if XDG_CONFIG_HOME is set):

{
  "$schema": "https://opencode.ai/config.json",
  "model": "lazu/claude-sonnet-5-5",
  "small_model": "lazu/claude-haiku-5-5",
  "provider": {
    "lazu": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Lazu",
      "options": {
        "baseURL": "https://api.lazu.ai/v1",
        "apiKey": "{env:LAZU_API_KEY}"
      },
      "models": {
        "claude-opus-5-5": { "name": "Claude Opus 5.5" },
        "claude-sonnet-5-5": { "name": "Claude Sonnet 5.5" },
        "claude-haiku-5-5": { "name": "Claude Haiku 5.5" },
        "gpt-6-luna": { "name": "GPT-6 Luna" },
        "deepseek-v4-pro": { "name": "DeepSeek V4 Pro" },
        "deepseek-flash": { "name": "DeepSeek Flash" },
        "kimi-k3": { "name": "Kimi K3" },
        "glm-5.3": { "name": "GLM-5.3" },
        "qwen3.8-max": { "name": "Qwen 3.8 Max" }
      }
    }
  }
}

Start opencode and run /models to switch between any listed model. Check the model catalog for the full list of model IDs.

Why split model and small_model #

OpenCode sends frequent background requests for session titles and lightweight summaries. When small_model is unset, those calls inherit your primary model — meaning a session running claude-opus-5-5 pays flagship rates just to title a thread.

Pointing small_model at lazu/claude-haiku-5-5 or lazu/deepseek-flash keeps your main coding loop on a frontier model and routes background chores to a fast, low-cost model under the same key budget and usage log.

Protocol notes for GPT-6 models #

@ai-sdk/openai-compatible speaks /v1/chat/completions. Lazu's protocol layer bridges those requests losslessly to Anthropic's Messages API for Claude and to native endpoints for DeepSeek, Kimi, GLM, Qwen, and Gemini, with streaming and tool calls preserved (see how Lazu translates APIs).

One upstream rule is worth knowing: OpenAI's reasoning-only GPT-6 variants (gpt-6.1-sol, gpt-6-astra) reject function tools on /v1/chat/completions and require /v1/responses. Under @ai-sdk/openai-compatible, pick gpt-6-luna or gpt-6-sol for tool-calling OpenAI sessions, or configure @ai-sdk/openai (Responses mode) / use Codex or Claude Code when running gpt-6.1-sol with tools.

Troubleshooting #

  • Model missing from /models: Verify the key under provider.lazu.models matches the exact ID in the Lazu model catalog (case-sensitive, e.g. MiniMax-M2.7).
  • 401 authentication error: If you use "{env:LAZU_API_KEY}", verify echo $LAZU_API_KEY is non-empty in the shell where you launch opencode.
  • Sessions not grouped under OpenCode in the console: Newer OpenCode releases changed their User-Agent format (opencode/<channel>/<version>/cli) and send x-opencode-session-id. Lazu updated its detection rules in v0.7.260 (details); updating OpenCode ensures every session is grouped cleanly.
Related
2026-11-18Claude Code gateway contract: 10 traps that stall agents 2026-10-21Claude Code on GPT and DeepSeek: how Lazu translates APIs 2026-09-30LLM API pricing comparison: Claude, GPT, Gemini, DeepSeek

Try it with a key

Start free