API Reference Overview¶
Claude Code Proxy API provides both Anthropic and OpenAI-compatible endpoints for seamless integration with Claude AI models.
Base URLs¶
API Format | Base URL | Description |
---|---|---|
Anthropic | http://localhost:8000/v1 |
Native Anthropic API format |
OpenAI | http://localhost:8000/openai/v1 |
OpenAI-compatible format |
Endpoint Summary¶
Chat Completions¶
Method | Anthropic Endpoint | OpenAI Endpoint | Description |
---|---|---|---|
POST | /v1/chat/completions |
/openai/v1/chat/completions |
Create chat completion |
Models¶
Method | Anthropic Endpoint | OpenAI Endpoint | Description |
---|---|---|---|
GET | /v1/models |
/openai/v1/models |
List available models |
Health & Monitoring¶
Method | Endpoint | Description |
---|---|---|
GET | /health |
Service health check |
Authentication¶
Claude Code Proxy integrates with Claude CLI for authentication. No API key is required in requests as authentication is handled automatically through your Claude CLI setup.
Request Headers¶
Note: Unlike direct API usage, no Authorization
header is required when using the proxy.
Request/Response Format¶
Anthropic Format¶
Follows the standard Anthropic API format:
{
"model": "claude-3-5-sonnet-20241022",
"messages": [
{
"role": "user",
"content": "Hello!"
}
],
"max_tokens": 1000
}
OpenAI Format¶
Compatible with OpenAI's chat completions format:
{
"model": "claude-3-5-sonnet-20241022",
"messages": [
{
"role": "user",
"content": "Hello!"
}
],
"max_tokens": 1000,
"temperature": 0.7
}
Streaming¶
Both endpoints support streaming responses:
{
"model": "claude-3-5-sonnet-20241022",
"messages": [{"role": "user", "content": "Tell me a story"}],
"stream": true
}
Error Handling¶
The API uses standard HTTP status codes and returns detailed error information:
Error Response Format¶
{
"error": {
"type": "validation_error",
"message": "Invalid request parameters",
"details": {
"field": "model",
"issue": "Model not found"
}
}
}
Common Status Codes¶
Code | Description | Common Causes |
---|---|---|
200 | Success | Request completed successfully |
400 | Bad Request | Invalid request format or parameters |
401 | Unauthorized | Authentication failed |
404 | Not Found | Model or endpoint not found |
429 | Too Many Requests | Rate limit exceeded |
500 | Internal Server Error | Server or Claude CLI error |
503 | Service Unavailable | Claude CLI not available |
Rate Limiting¶
The API includes built-in rate limiting to protect against abuse:
- Default: 60 requests per minute per IP
- Burst: 10 additional requests allowed
- Headers: Rate limit information included in response headers
Rate Limit Headers¶
Content Types¶
Supported Input Content Types¶
application/json
(required)
Supported Output Content Types¶
application/json
(default)text/event-stream
(for streaming responses)
Models¶
Currently supported Claude models:
Model ID | Description | Context Length |
---|---|---|
claude-3-5-sonnet-20241022 |
Latest Claude 3.5 Sonnet | 200K tokens |
claude-3-7-sonnet-20250219 |
Latest Claude 3.5 Haiku | 200K tokens |
claude-opus-4-20250514 |
Claude 3 Opus | 200K tokens |
API Compatibility¶
Anthropic API Compatibility¶
The proxy is fully compatible with: - Anthropic Python SDK - Anthropic REST API - All Anthropic message formats
OpenAI API Compatibility¶
The proxy supports OpenAI-compatible: - Chat completions endpoint - Streaming responses - Error response format - Model listing
Note: Only chat completions are supported. Other OpenAI endpoints (completions, embeddings, etc.) are not available.
Client Libraries¶
Python¶
# Using OpenAI client
from openai import OpenAI
client = OpenAI(base_url="http://localhost:8000/v1", api_key="dummy")
# Using Anthropic client
from anthropic import Anthropic
client = Anthropic(base_url="http://localhost:8000", api_key="dummy")
# Using requests
import requests
response = requests.post("http://localhost:8000/v1/chat/completions", json=data)
JavaScript/Node.js¶
// Using OpenAI SDK
import OpenAI from 'openai';
const client = new OpenAI({
baseURL: 'http://localhost:8000/v1',
apiKey: 'dummy'
});
// Using fetch
const response = await fetch('http://localhost:8000/v1/chat/completions', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(requestData)
});
curl¶
# Anthropic format
curl -X POST http://localhost:8000/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{"model": "claude-3-5-sonnet-20241022", "messages": [{"role": "user", "content": "Hello"}]}'
# OpenAI format
curl -X POST http://localhost:8000/openai/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{"model": "claude-3-5-sonnet-20241022", "messages": [{"role": "user", "content": "Hello"}]}'
Next Steps¶
- Anthropic Endpoints - Detailed Anthropic API documentation
- OpenAI Endpoints - Detailed OpenAI API documentation
- Models - Available models and their capabilities
- Health Check - Health monitoring endpoints