Gateway address
AI models & keys shows your exact address under Gateway address, with a copy button. The examples below use
https://llm-gw.xpander.ai; replace it with yours on an Air-Gapped install.
The quick way: one copied command
- Open AI models & keys in Xpander Chat (Settings > AI models & keys).
- Under Connect a client, pick Claude Code, Codex CLI, OpenCode or Your own code.
- For Claude Code, Codex CLI and OpenCode, pick your system (macOS, Linux or Windows) and choose Copy setup command. Copying creates an API key for that client and computer. Paste the command in your terminal (PowerShell on Windows) and press Enter. Your coding tool starts already connected, and saves the connection in its own settings so every new terminal uses it.
- For Your own code, choose Copy prompt and paste it into the coding agent you use in your project. It wires your project’s OpenAI or Anthropic SDK calls to the gateway, reading the key from the
XPANDER_GATEWAY_KEYenvironment variable. The prompt never contains your key.
Claude Code
No/login is needed: your xpander key signs Claude Code in. Add this to ~/.claude/settings.json (%USERPROFILE%\.claude\settings.json on Windows):
/v1. CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY lists the models your organization enabled for you in Claude Code’s /model, so there is no model to set.
To try it in one terminal only:
claude -p "reply with exactly: OK". In Claude Code, /status shows the gateway address.
Codex
No login is needed: Codex reads your key fromXPANDER_GATEWAY_KEY. Add this to ~/.codex/config.toml (%USERPROFILE%\.codex\config.toml on Windows), with a model from AI models & keys:
codex. Switch models with /model. Check it: codex exec --skip-git-repo-check "reply with exactly: OK" answers OK.
OpenCode
No login is needed: OpenCode reads your key fromXPANDER_GATEWAY_KEY. Add a provider to ~/.config/opencode/opencode.json (%USERPROFILE%\.config\opencode\opencode.json on Windows):
models, and pick one as xpander/<name>. Keep XPANDER_GATEWAY_KEY for every new terminal as in the Codex section, then start opencode. Check it: opencode run "reply with exactly: OK" answers OK.
Your own code (SDKs)
The Anthropic SDK takes the address without/v1; the OpenAI SDK takes it with /v1. Both take your xpander key as their API key.
A call in one format can be served by a model from a provider that speaks another, so Codex can run a Claude model when your organization enabled one for you.
Sending your key next to another sign-in
The gateway reads your xpander key fromAuthorization: Bearer, from x-api-key, or from the x-xpander-api-key header. When the Authorization header already carries another sign-in, such as your own Claude plan in Claude Code, send your xpander key in x-xpander-api-key:
Check the connection
401 means the key is unknown, revoked or expired. Your newest call appears at the top of Logs (for admins) and in your own Usage. When a call is refused, Errors and what to do lists every message.
