For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
DiscordPlatform
DocumentationIntegrationsAPI referenceSDKsChangelog
DocumentationIntegrationsAPI referenceSDKsChangelog
    • Overview
  • Tracing
  • Gateway
      • Claude Code
      • Codex CLI
      • Gemini CLI
      • OpenCode
  • Others
  • Migrating
    • Braintrust
    • Portkey
    • Langfuse
LogoLogo
DiscordPlatform
On this page
  • Setup
  • Switch models
GatewayCoding Agents

OpenCode (gateway)

Was this page helpful?
Previous

OpenAI (gateway)

Route OpenAI model calls through Respan Gateway and track requests.
Next
Built with

Route OpenCode’s LLM calls through the Respan gateway for automatic logging, caching, and model switching. Only your RESPAN_API_KEY is needed.

Setup

1

Install OpenCode

$npm install -g opencode-ai
2

Set environment variables

Add to your shell profile (.bashrc, .zshrc, or PowerShell $PROFILE):

$export OPENAI_BASE_URL="https://api.respan.ai/api/"
$export OPENAI_API_KEY="YOUR_RESPAN_API_KEY"

No separate OpenAI API key needed — the Respan gateway handles provider authentication.

3

Run OpenCode

$opencode run -m "openai/gpt-4.1" "your prompt"

All LLM calls now route through Respan.

Switch models

Change the -m flag to use 250+ models from different providers through the same gateway.

$opencode run -m "openai/gpt-4.1" "your prompt"
$opencode run -m "openai/claude-sonnet-4-5-20250929" "your prompt"
$opencode run -m "openai/gemini-2.5-flash" "your prompt"

See the full model list.