Migrating from Anthropic
Step-by-step guide to migrate from Anthropic SDK to Cencori. Keep Claude while gaining security, logging, and multi-provider flexibility.
Why Migrate to Cencori?
Already using Claude? Here's what Cencori adds:
- Keep using Claude: Same models, same quality
- Add OpenAI & Gemini: Switch providers without code changes
- Built-in Security: Automatic PII and prompt injection detection
- Cost Tracking: See exact costs per request
- Complete Logging: Audit trail for compliance
Code Comparison
Before (Anthropic SDK)
before.ts
After (Cencori SDK)
after.ts
Migration Steps
Step 1: Install Cencori SDK
terminal
Step 2: Get Cencori API Key
- Sign up at cencori.com/dashboard
- Create a project
- Generate an API key
Step 3: Add Your Anthropic Key to Cencori
- In Cencori dashboard, go to Project Settings
- Navigate to "Provider Keys"
- Add your Anthropic API key
- Save
Note: Cencori uses your Anthropic key to make requests on your behalf. You keep full control.
Step 4: Update Your Code
Old:
old.ts
New:
new.ts
API Mapping Reference
| Anthropic SDK | Cencori SDK |
|---|---|
anthropic.messages.create() | cencori.ai.chat() |
claude-3-opus-20240229 | claude-3-opus |
max_tokens | maxTokens |
stream: true | cencori.ai.chatStream() |
System Message Handling
Anthropic SDK has a separate system parameter. Cencori handles this automatically:
Anthropic Native:
anthropic.ts
Cencori (automatic):
cencori.ts
Tip: Cencori automatically converts system messages to Anthropic's format. Just use the standard messages array.
Migrating Streaming Code
Anthropic Streaming:
anthropic-stream.ts
Cencori Streaming:
cencori-stream.ts
Bonus: Multi-Provider Freedom
Now that you're on Cencori, switching to other providers is trivial:
multi-provider.ts
Pro Tip: A/B test models to find the best quality/cost ratio for each use case.

