Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.clearmaas.com/llms.txt

Use this file to discover all available pages before exploring further.

OpenCode is a terminal-based AI coding assistant that supports 75+ LLM providers through the AI SDK. Connect it to ClearMaas by configuring a custom provider in your JSON config file.

Prerequisites

  • OpenCode installed (npm install -g opencode or via installer)
  • A ClearMaas API key starting with sk-

Config file locations

OpenCode merges configuration from multiple sources (later overrides earlier):
  1. Remote config (.well-known/opencode) �?organizational defaults
  2. Global config (~/.config/opencode/opencode.json) �?user preferences
  3. OPENCODE_CONFIG env var �?custom overrides
  4. Project config (opencode.json in project root) �?project-specific
  5. OPENCODE_CONFIG_CONTENT env var �?runtime overrides

Setup via global config

Add to ~/.config/opencode/opencode.json:
{
  "$schema": "https://opencode.ai/config.json",
  "model": "anthropic/claude-sonnet-4-5",
  "provider": {
    "anthropic": {
      "options": {
        "apiKey": "sk-...",
        "baseURL": "https://api.clearmaas.com/v1"
      }
    }
  }
}

Setup via environment variable

For temporary or CI usage, use OPENCODE_CONFIG_CONTENT:
export OPENAI_API_KEY="sk-..."
export OPENCODE_CONFIG_CONTENT='{
  "model": "openai/gpt-4o",
  "provider": {
    "openai": {
      "options": {
        "baseURL": "https://api.clearmaas.com/v1"
      }
    }
  }
}'
opencode "Explain this code"

Using environment variables in config

Reference API keys via env vars to avoid hardcoding:
{
  "$schema": "https://opencode.ai/config.json",
  "model": "openai/gpt-4o-mini",
  "provider": {
    "openai": {
      "options": {
        "apiKey": "{env:OPENAI_API_KEY}",
        "baseURL": "https://api.clearmaas.com/v1"
      }
    }
  }
}
export OPENAI_API_KEY="sk-..."
opencode

Choosing models

Set the default model in config:
{
  "model": "anthropic/claude-sonnet-4-5"
}
Override with the /models command in the TUI:
/model openai/gpt-4o-mini

Using a separate small model

OpenCode can use a cheaper model for lightweight tasks (title generation, etc.):
{
  "model": "anthropic/claude-opus-4-5",
  "small_model": "anthropic/claude-haiku-4-5"
}

Verifying the setup

opencode
# In the TUI, type: /models
# You should see ClearMaas models listed
# Or type: /connect and verify the endpoint
Check your ClearMaas dashboard to confirm requests are being routed.

Config example with all options

{
  "$schema": "https://opencode.ai/config.json",
  "model": "anthropic/claude-sonnet-4-5",
  "small_model": "anthropic/claude-haiku-4-5",
  "autoupdate": true,
  "provider": {
    "anthropic": {
      "options": {
        "apiKey": "{env:OPENAI_API_KEY}",
        "baseURL": "https://api.clearmaas.com/v1",
        "timeout": 300000,
        "setCacheKey": true
      }
    }
  }
}
Available provider options:
  • timeout �?Request timeout in milliseconds (default: 300000)
  • setCacheKey �?Always set a cache key for designated provider
  • baseURL �?Override the default API endpoint

See also