Skip to content
Connect a clientOpenCode

OpenCode

new

OpenCode on a universal Guard API key.

Set up with your own AI
Model protocol

OpenCode is configured the same way as Claude Code — via the Anthropic variables.

Environment variables
bash · macOS / Linux
export ANTHROPIC_BASE_URL="https://api.guardrelay.ai"
export ANTHROPIC_API_KEY="$GUARD_API_KEY"
PowerShell · Windows
$env:ANTHROPIC_BASE_URL = "https://api.guardrelay.ai"
$env:ANTHROPIC_API_KEY = "$GUARD_API_KEY"

Kimi, Composer and Grok

The ANTHROPIC_* variables point OpenCode at /v1/messages. Composer and Grok accept that surface, client tools included.

Environment variables
bash · macOS / Linux
export ANTHROPIC_BASE_URL="https://api.guardrelay.ai"
export ANTHROPIC_API_KEY="$GUARD_API_KEY"
# then pick a model in the client, e.g. cursor-grok-4.6-high or composer-2.5
PowerShell · Windows
$env:ANTHROPIC_BASE_URL = "https://api.guardrelay.ai"
$env:ANTHROPIC_API_KEY = "$GUARD_API_KEY"
# then pick a model in the client, e.g. cursor-grok-4.6-high or composer-2.5

For Kimi, configure an OpenAI-compatible provider in OpenCode pointing at https://api.guardrelay.ai/v1 and use one of the four Kimi IDs.

Kimi in OpenCode

The ANTHROPIC_* variables take OpenCode to the Anthropic Messages protocol. The path below goes through an OpenAI-compatible provider: it is configured with the same two values, an address and a key.

Take an OpenAI-compatible provider. Base URL https://api.guardrelay.ai/v1, exactly with /v1, header Authorization: Bearer gd-…, and one of the four ids in the model field: k3, k3-256k, kimi-for-coding or kimi-for-coding-highspeed.

First make sure the key answers. The command below returns the model text:

bash
curl -X POST https://api.guardrelay.ai/v1/chat/completions \
  -H "Authorization: Bearer $GUARD_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "k3",
    "messages": [{"role": "user", "content": "Hello!"}],
    "max_tokens": 128
  }'

Documentation sections

On this page