Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Migrate from OpenAI/GPT to Anthropic/Claude — API differences, Use when working with migration-deep-dive patterns. prompt adaptation, SDK swap, and feature mapping. Trigger with "migrate to claude", "openai to anthropic", "switch from gpt to claude", "replace openai with anthropic".
| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-13 | ✗→✓ | ▲ Improved | -19% | 0% |
| case-19 | ✗→✓ | ▲ Improved | 38% | 0% |
| case-09 | ✗→✓ | ▲ Improved | 26% | 0% |
| case-08 | ✓→✓ | = Same ✓ | 33% | 0% |
| case-02 | ✓→✓ | = Same ✓ | 245% | 0% |
Migrate from OpenAI/GPT to Anthropic/Claude. Covers the complete API mapping (endpoints, models, response shapes), SDK swap with before/after code, five key differences (max_tokens required, system as top-level param, alternating messages, response path, streaming events), and tool use migration.
| OpenAI | Anthropic | Notes | |--------|-----------|-------| | openai.chat.completions.create() | anthropic.messages.create() | Different request/response shape | | model: 'gpt-4o' | model: 'claude-sonnet-4-20250514' | Different model IDs | | response.choices[0].message.content | response.content[0].text | Different response path | | system in messages array | system as separate parameter | Claude uses top-level system | | response_format: { type: 'json_object' } | System prompt: "Respond in JSON only" | No native JSON mode | | tools / function_calling | tools (similar but different schema) | Input schema differences | | openai.embeddings.create() | N/A — use Voyage or Cohere | No embeddings API |
typescriptimport OpenAI from 'openai'; const openai = new OpenAI(); const response = await openai.chat.completions.create({ model: 'gpt-4o', messages: [ { role: 'system', content: 'You are helpful.' }, { role: 'user', content: 'Hello' }, ], }); console.log(response.choices[0].message.content);
typescriptimport Anthropic from '@claude-ai/sdk'; const anthropic = new Anthropic(); const response = await anthropic.messages.create({ model: 'claude-sonnet-4-20250514', max_tokens: 1024, // Required (not optional like OpenAI) system: 'You are helpful.', // Separate from messages messages: [ { role: 'user', content: 'Hello' }, ], }); console.log(response.content[0].text);
max_tokens is required — OpenAI defaults it, Anthropic requires itsystem is a top-level param — not a message in the arrayuser — can't start with assistantcontent[0].text not choices[0].message.contenttypescript// OpenAI tool definition { type: 'function', function: { name: 'get_weather', parameters: { ... } } } // Anthropic tool definition { name: 'get_weather', input_schema: { ... } } // Flatter structure
bash# Find all OpenAI imports grep -rn "from 'openai'" --include="*.ts" . grep -rn "import OpenAI" --include="*.ts" . # Find response access patterns to update grep -rn "choices\[0\]" --include="*.ts" . grep -rn "message.content" --include="*.ts" . # May need updating
openai imports replaced with @claude-ai/sdkchoices[0].message.content → content[0].text)system parametermax_tokens added to all API calls (required, not optional)| Error | Cause | Solution | |-------|-------|----------| | API Error | Check error type and status code | See clade-common-errors |
See API Mapping table, Before/After SDK code, Key Differences list, Tool Use Migration, and Grep & Replace commands above.
See clade-sdk-patterns for production Anthropic SDK patterns.
Other measured skills in the registry, with their headline benchmark lift.