Claude API Proxy · Load Balancing · Custom Authentication
Pre-configured Python implementation ready for immediate deployment.
Download Code ArchiveRetrieve and extract the example code archive.
unzip cptc-ai-example.zip
cd cptc-ai-example
Install required dependencies using uv:
uv sync
Installation command for uv:
curl -LsSf https://astral.sh/uv/install.sh | sh
Initialize configuration file:
cp config.yaml.example config.yaml
Update config.yaml with your credentials:
api_key: your_custom_api_key_here # e.g., sk-cptc-alice
base_url:
uv run main.py
Response from Claude will include usage metrics.
Provide credentials via x-api-key header:
x-api-key: sk-cptc-your-key-here
curl /v1/messages \
-H "x-api-key: sk-cptc-your-key" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-4-5-20250929",
"max_tokens": 1024,
"messages": [
{"role": "user", "content": "Hello, Claude!"}
]
}'
Verify current rate limit status for your API key.
Implementation using the Anthropic Python SDK:
from anthropic import Anthropic
client = Anthropic(
api_key="sk-cptc-your-key",
base_url=""
)
message = client.messages.create(
model="claude-sonnet-4-5-20250929",
max_tokens=1024,
messages=[
{"role": "user", "content": "Hello!"}
]
)
print(message.content[0].text)
Configure Anthropic's Claude Code CLI to use this proxy server.
Installation: Install Claude Code CLI
Set the following environment variables in your shell:
export ANTHROPIC_BASE_URL=""
export ANTHROPIC_AUTH_TOKEN="sk-cptc-your-key-here"
To make these settings persistent, add them to your shell profile (~/.bashrc, ~/.zshrc, etc.):
echo 'export ANTHROPIC_BASE_URL=""' >> ~/.bashrc
echo 'export ANTHROPIC_AUTH_TOKEN="sk-cptc-your-key-here"' >> ~/.bashrc
source ~/.bashrc
Test your Claude Code setup:
claude-code --version
# Claude Code will now use your custom API endpoint