Use a custom OpenAI-compatible or Anthropic-compatible gateway with Claude Code in about 3 minutes.
This repository is a public, sanitized starter. Replace every placeholder with values from your own dashboard before running it.
- Copy the example environment file.
Copy-Item .env.example .env- Edit
.env.
ANTHROPIC_BASE_URL=https://your-gateway.com
ANTHROPIC_AUTH_TOKEN=sk-example-xxx- Verify the endpoint before opening Claude Code.
.\scripts\verify-claude-gateway.ps1- Start Claude Code in the same terminal session.
claude- Configure Claude Code with a custom API endpoint.
- Verify your gateway before a real coding session.
- Keep secrets out of GitHub by using
.env.example. - Troubleshoot common base URL and token mistakes.
| Symptom | Likely cause | Fix |
|---|---|---|
| 401 or unauthorized | API token is missing or wrong | Recreate the key in your dashboard and update .env. |
404 on /v1/messages |
Base URL includes the wrong path | Use the provider's documented root URL. |
| Timeout | Proxy, DNS, or gateway outage | Test with curl and check provider status. |
| Claude Code ignores env | Terminal was opened before env changed | Restart the terminal and reload .env. |
- Never commit
.env. - Never paste a real API key into issues, screenshots, commits, or README files.
- Public examples must use
sk-example-xxxandhttps://your-gateway.com.
- Docs:
https://your-gateway.com/docs - Pricing:
https://your-gateway.com/pricing - Support:
https://your-gateway.com/support
MIT