Skip to content

Anthropic Integration

Anthropic provides state-of-the-art language models with a focus on safety and sustainability. GateFlow integrates seamlessly with Anthropic's API to provide optimized routing, cost control, and observability.

Current Models

Chat Models

ModelContextOutputInput $/1MOutput $/1M
claude-opus-4-5-20251107200k8,192$15.00$75.00
claude-opus-4-1-20250805200k8,192$12.00$60.00
claude-sonnet-4-5-20250929200k8,192$3.00$15.00
claude-sonnet-4-20250514200k8,192$2.50$12.50
claude-haiku-4-5-20251015200k8,192$0.25$1.25

Setup

  1. Navigate to Dashboard: Go to Settings → Providers
  2. Add Provider: Click "Add Provider" and select Anthropic
  3. Enter API Key: Paste your Anthropic API key
  4. Configure Settings:
    • Region: Select preferred data center (e.g., us-east-1)
    • Sustainability Mode: Enable to prioritize low-carbon regions
    • Default Model: Set default model for chat completions
  5. Save: The provider is now available for routing

Configuration Options

json
{
  "provider": "anthropic",
  "api_key": "your-anthropic-api-key",
  "region": "us-east-1",
  "sustainability_mode": true,
  "default_model": "claude-sonnet-4-5-20250929",
  "quality_threshold": 0.95,
  "carbon_budget": 50
}

Best Practices

  • Cost Optimization: Use claude-haiku-4-5-20251015 for high-volume, low-latency tasks.
  • Quality Tasks: Use claude-opus-4-5-20251107 for complex reasoning and analysis.
  • Sustainability: Enable sustainability mode to route requests to low-carbon data centers.

Example Usage

python
from openai import OpenAI

client = OpenAI(
    base_url="https://api.gateflow.ai/v1",
    api_key="gw_prod_your_key_here"
)

# Use Anthropic for complex reasoning
response = client.chat.completions.create(
    model="claude-opus-4-5-20251107",
    messages=[{"role": "user", "content": "Solve this complex problem"}],
    routing_mode="sustain_optimized"
)

print(response.choices[0].message.content)
print(f"Model used: {response.model}")
print(f"Carbon footprint: {response.sustainability.carbon_gco2e} gCO₂e")
print(f"Carbon saved: {response.sustainability.carbon_saved_gco2e} gCO₂e")

Anthropic-Specific Features

Tool Use

Anthropic models support function calling with GateFlow's unified interface:

python
# Define tools (works across all providers)
tools = [
    {
        "type": "function",
        "function": {
            "name": "get_weather",
            "description": "Get weather information for a location",
            "parameters": {
                "type": "object",
                "properties": {
                    "location": {"type": "string"},
                    "unit": {"type": "string", "enum": ["celsius", "fahrenheit"]}
                }
            }
        }
    }
]

response = client.chat.completions.create(
    model="claude-opus-4-5-20251107",
    messages=[{"role": "user", "content": "What's the weather in Paris?"}],
    tools=tools,
    routing_mode="sustain_optimized"
)

Vision Support

python
# Multi-modal input with vision
response = client.chat.completions.create(
    model="claude-opus-4-5-20251107",
    messages=[
        {
            "role": "user",
            "content": [
                {"type": "text", "text": "Analyze this image"},
                {
                    "type": "image_url",
                    "image_url": {
                        "url": "https://example.com/image.jpg"
                    }
                }
            ]
        }
    ],
    routing_mode="sustain_optimized"
)

Sustainability Features

Anthropic models through GateFlow offer:

  • Carbon-Optimized Routing: Automatically select the most energy-efficient data center
  • Model Efficiency: Claude models are optimized for low energy consumption
  • Time-Shifted Execution: Defer non-urgent requests to low-carbon periods
  • Request Batching: Combine multiple requests for reduced overhead
  • Automatic Model Selection: Choose the most efficient Claude model for your task

Model Selection Guide

Use CaseRecommended ModelKey FeaturesSustainability Benefits
Complex reasoningclaude-opus-4-5-20251107200K context, visionHighest efficiency per token
Production useclaude-sonnet-4-5-20250929Balanced performanceBest quality-to-carbon ratio
Fast responsesclaude-haiku-4-5-20251015250ms latencyLowest carbon footprint
Cost-effectiveclaude-sonnet-4-20250514Balanced qualityOptimized for efficiency

Sustainability Best Practices

Optimization Strategies

  1. Right-size your model: Use claude-haiku-4-5-20251015 for simple tasks instead of Opus models
  2. Enable Sustain Mode: Let GateFlow automatically choose the most efficient Anthropic model
  3. Use time-shifting: Defer non-urgent requests to low-carbon periods
  4. Batch requests: Process multiple items in single API calls to reduce overhead
  5. Combine with caching: Cache frequent Anthropic requests for maximum savings

Configuration Example

python
# Configure Anthropic provider with sustainability settings
response = client.chat.completions.create(
    model="anthropic:auto",  # Let GateFlow choose most efficient Anthropic model
    messages=[{"role": "user", "content": "Process this sustainably"}],
    routing_mode="sustain_optimized",
    minimum_quality_score=8,  # Balance quality and efficiency
    region_preference="us-west"  # Prioritize low-carbon regions
)

Performance Characteristics

Latency Comparison

  • Fastest: claude-haiku-4-5-20251015 (250ms)
  • Balanced: claude-sonnet-4-5-20250929 (1,400ms)
  • Advanced: claude-opus-4-5-20251107 (2,000ms)

Token Limits

  • All models: 200K context window
  • Output limits: 8,192 tokens

Pricing Overview

  • Input prices: $0.25-$15.00 per 1M tokens
  • Output prices: $1.25-$75.00 per 1M tokens

Integration with Other GateFlow Features

Multi-Provider Fallbacks

python
# Configure Anthropic as primary with fallbacks
response = client.chat.completions.create(
    model="claude-opus-4-5-20251107",  # Primary: Anthropic
    messages=[{"role": "user", "content": "Important request"}],
    fallback_providers=["openai", "mistral"],  # Fallback chain
    routing_mode="sustain_optimized"
)

Semantic Caching

python
# Cache frequent Anthropic requests
response = client.chat.completions.create(
    model="claude-sonnet-4-5-20250929",
    messages=[{"role": "user", "content": "Frequently asked question"}],
    cache_ttl_seconds=3600,  # Cache for 1 hour
    embedding_model="text-embedding-3-small"  # Use for semantic matching
)

Troubleshooting

"Anthropic API key not configured"

Solution: Add your Anthropic API key in the GateFlow Dashboard under Settings → Providers.

"Model not found: claude-3-opus-20240229"

Solution: Use current models like claude-opus-4-5-20251107 instead of deprecated models.

"Rate limit exceeded"

Solution:

  1. Check your Anthropic account limits
  2. Configure fallbacks to other providers
  3. Enable request queuing in GateFlow settings
  4. Use claude-haiku-4-5-20251015 for high-volume applications

"Carbon savings lower than expected"

Solution:

  1. Verify Sustain Mode is properly configured
  2. Check grid carbon intensity in your region
  3. Try different Anthropic models for better efficiency
  4. Enable time-shifted execution for non-urgent requests

Migration from Direct Anthropic API

Key Differences

FeatureDirect Anthropic APIGateFlow Anthropic Integration
API FormatAnthropic-specificOpenAI-compatible
AuthenticationAnthropic API keyGateFlow API key
Model Namesclaude-3-opusclaude-opus-4-5-20251107
Carbon TrackingManualAutomatic
Multi-providerNoYes
FallbacksManualAutomatic
SustainabilityBasicAdvanced optimization

Migration Example

Before (Direct Anthropic API):

python
import anthropic
client = anthropic.Anthropic(api_key="your-anthropic-api-key")
response = client.messages.create(
    model="claude-3-opus-20240229",
    messages=[{"role": "user", "content": "Hello from Anthropic!"}]
)

After (GateFlow Integration):

python
from openai import OpenAI
client = OpenAI(
    base_url="https://api.gateflow.ai/v1",
    api_key="gw_prod_your_gateflow_key"
)
response = client.chat.completions.create(
    model="claude-opus-4-5-20251107",  # Use current models
    messages=[{"role": "user", "content": "Hello from Anthropic via GateFlow with sustainability benefits!"}],
    routing_mode="sustain_optimized"  # Enable carbon optimization
)

Next Steps

Built with reliability in mind.