The response_format Trap
Most OpenAI-to-Claude migrations break at the same spot: response_format={"type": "json_object"}. That parameter doesn't exist in Claude's API.
I tested this with a production RAG system that was making 2000+ API calls per day to GPT-4. The code looked clean — standard OpenAI client initialization, function calling for tool use, structured JSON output via response_format. Swapping the API key and base URL should've been a 5-minute fix.
It took four hours. Here's what actually changed.
Authentication Headers Are Different
OpenAI uses Authorization: Bearer sk-... for auth. Claude uses x-api-key and anthropic-version headers.
# OpenAI style (doesn't work with Claude)
import openai
client = openai.OpenAI(api_key="sk-...")
# Claude API requires explicit headers
import anthropic
client = anthropic.Anthropic(api_key="sk-ant-...")
Continue reading the full article on TildAlice

Top comments (0)