Using in Claude Code
Integrate MyTokenGate’s AI models with Claude Code for enhanced development experience.
This integration guide is compatible with macOS and Linux systems. Windows users should use WSL (Windows Subsystem for Linux).
Overview
Claude Code is Anthropic’s official command-line AI assistant that helps with coding tasks. By integrating it with MyTokenGate, you can access powerful AI models for code generation, debugging, and analysis directly from your terminal.
Prerequisites
- macOS or Linux operating system (or WSL on Windows)
- Node.js 18+ environment
- Valid MyTokenGate API key (Get your API key )
Install Claude Code
Install Claude Code globally using npm:
npm install -g @anthropic-ai/claude-codeAfter installation, launch Claude Code with:
claudeOn first run, it will guide you through the authentication process.
Configure MyTokenGate
Method 1: Environment Variables (Recommended)
Add the following environment variables to your shell profile (.bashrc, .zshrc, or .profile):
# MyTokenGate API Configuration
export ANTHROPIC_BASE_URL="https://gateway.mytokengate.com"
export ANTHROPIC_AUTH_TOKEN="sk-your-api-key-here" # Replace with your actual API keyWhen connecting through a third-party gateway, use
ANTHROPIC_AUTH_TOKEN(sent asAuthorization: Bearer) rather than the officialANTHROPIC_API_KEY(sent asx-api-key).
Reload your configuration:
# For bash users
source ~/.bashrc
# For zsh users
source ~/.zshrcMethod 2: Claude Code Configuration File
Create or edit .claude/settings.json in your project root:
{
"env": {
"ANTHROPIC_BASE_URL": "https://gateway.mytokengate.com",
"ANTHROPIC_AUTH_TOKEN": "sk-your-api-key-here"
}
}Model Selection
You can specify a platform model via environment variable:
export ANTHROPIC_MODEL="claude-sonnet-5" # Primary model
export ANTHROPIC_SMALL_FAST_MODEL="claude-haiku-4-5" # Lightweight background modelExplore available models at mytokengate.com/app/models .
Usage Tips
- Use specific, detailed prompts for better code suggestions
- Break complex tasks into smaller, manageable requests
- Review generated code before implementation
- Monitor your usage in the MyTokenGate Console
Troubleshooting
Authentication Error
# Verify your API key is correctly set
echo $ANTHROPIC_AUTH_TOKENConnection Issues
# Test API connectivity
curl -H "Authorization: Bearer $ANTHROPIC_AUTH_TOKEN" https://gateway.mytokengate.com/v1/models