1. What is Claude Code?
Claude Code is Anthropic's official terminal coding agent (CLI) that allows you to read/write code, run commands, and execute tasks directly within your terminal. It natively supports environment variables like ANTHROPIC_BASE_URL and ANTHROPIC_API_KEY, making it easy to point to a proxy gateway and use your own API keys and credits.
2. Installing Claude Code
Requires Node.js (version 18 or higher recommended). Install it globally using:
npm install -g @anthropic-ai/claude-code
Once installed, type claude in your terminal to start; use /model or claude --model … to switch between models.
3. Configuring Environment Variables
Windows (PowerShell)
$env:ANTHROPIC_BASE_URL="https://www.relay-api.com"
$env:ANTHROPIC_API_KEY="sk-your-key"
$env:ANTHROPIC_MODEL="claude-sonnet-5"
claude
macOS / Linux (bash / zsh)
export ANTHROPIC_BASE_URL="https://www.relay-api.com"
export ANTHROPIC_API_KEY="sk-your-key"
export ANTHROPIC_MODEL="claude-sonnet-5"
claude
Note: The ANTHROPIC_API_KEY is included in the request header, and ANTHROPIC_BASE_URL overrides the default API endpoint to route requests through our Anthropic gateway.
4. API Endpoint Reference
| Model Group | Base URL | Protocol |
|---|---|---|
| Claude / Anthropic | https://www.relay-api.com | Anthropic Messages |
| GPT / OpenAI | https://www.relay-api.com/v1 | OpenAI Chat Completions |
| Gemini | https://www.relay-api.com/v1beta | Google generateContent |
5. Troubleshooting
| Issue | Resolution |
|---|---|
| 401 / 403 | Invalid key, disabled account, or insufficient balance; verify your sk- key and check your balance. |
| 404 / Model unavailable | Model name mismatch or model is not enabled; verify the model ID. |
| Unknown model | Model IDs must be exact (case-sensitive); verify them in the Model Marketplace. |
| Request timeout | Increase timeout for long-running tasks or retry if there is network instability. |
Security Recommendation: Never commit your API key to public repositories. Use .env files or system environment variables instead. Code generation tasks consume tokens quickly, so monitor your balance and check usage logs for every request.
