OpenCode

The open-source coding agent for the terminal, with MafiaLLM as a provider.

Setup

Add MafiaLLM as a provider in ~/.config/opencode/opencode.json (every project) or in an opencode.json at the root of one project. List the models you want to use, with their limits from the model list:

opencode.json:

{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "mafiallm": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "MafiaLLM",
      "options": {
        "baseURL": "https://api.mafiallm.com/v1",
        "apiKey": "{env:MAFIA_KEY}"
      },
      "models": {
        "claude-sonnet-5-5": { "name": "Claude Sonnet 5.5", "limit": { "context": 1000000, "output": 64000 } },
        "glm-5.3": { "name": "GLM 5.3", "limit": { "context": 1000000, "output": 65536 } },
        "deepseek-v4.1-flash": { "name": "DeepSeek V4.1 Flash", "limit": { "context": 1000000, "output": 65536 } }
      }
    }
  },
  "model": "mafiallm/claude-sonnet-5-5",
  "small_model": "mafiallm/deepseek-v4.1-flash"
}

shell:

export MAFIA_KEY="sk-mf-…"
opencode

Switching models

Run /models in OpenCode, or start it with opencode -m mafiallm/${OPEN}. A model must be listed under models to appear.