Anthropic Claude
Integrate Anthropic Claude models with ModelRed
Anthropic Claude Models
Test Claude's safety-first AI with ModelRed's comprehensive security assessments. Built-in Constitutional AI provides advanced safety mechanisms.
Quick Setup
Get Started in 3 Steps
Set up your Claude model for security testing quickly.
Set Environment Variable
export ANTHROPIC_API_KEY="sk-ant-your-key-here"
Register Your Model
from modelred import ModelRed
async with ModelRed() as client:
await client.register_anthropic_model(
model_id="my-claude",
api_key="sk-ant-your-key", # or use env var
model_name="claude-3-sonnet-20240229"
)
Claude Models
Claude Haiku
Fast and affordable for simple tasks
Claude Sonnet
Balanced performance for most use cases
Claude Opus
Most capable for complex reasoning
Configuration Options
Advanced Setup
Additional configuration options for different Claude models.
Multiple Models
# Register different Claude variants
models = [
("claude-haiku", "claude-3-haiku-20240307"),
("claude-sonnet", "claude-3-sonnet-20240229"),
("claude-opus", "claude-3-opus-20240229")
]
for model_id, model_name in models:
await client.register_anthropic_model(
model_id=model_id,
model_name=model_name
)
With Metadata
await client.register_anthropic_model(
model_id="claude-production",
model_name="claude-3-sonnet-20240229",
metadata={
"use_case": "content_moderation",
"team": "ai-safety",
"version": "3.0"
}
)
Common Issues
⚠️ Troubleshooting
Invalid API Key
AuthenticationError: Invalid API key
- • Verify key starts with 'sk-ant-'
- • Check key in Anthropic Console
- • Ensure account has credits
Model Not Available
Model 'claude-3-xyz' not found
- • Use exact model names from Anthropic docs
- • Check model availability in your region
- • Try 'claude-3-sonnet-20240229' (widely available)
Rate Limit Exceeded
RateLimitError: Too many requests
- • Wait before retrying requests
- • Check your rate limits in Console
- • Consider upgrading your plan
Quick Test
✅ Verify Your Setup
Run this test to confirm your Claude integration is working:
import asyncio
from modelred import ModelRed
async def test_claude():
async with ModelRed() as client:
# Register Claude model
await client.register_anthropic_model(
model_id="test-claude",
model_name="claude-3-sonnet-20240229"
)
print("✅ Claude model registered!")
# Run security test
result = await client.run_assessment(
model_id="test-claude",
test_suites=["basic_security", "content_safety"]
)
print(f"🔍 Assessment started: {result.assessment_id}")
asyncio.run(test_claude())
Claude vs GPT
⚖️ Security Testing Comparison
Claude Advantages
Built-in Constitutional AI safety
200K context for long documents
Strong refusal patterns
Excellent safety benchmarks
Best For Testing
Content moderation systems
Safety mechanism validation
Constitutional AI testing
Long context security