A concept map + a thin adapter for moving code between the OpenAI and
Anthropic APIs (or supporting both behind one interface). This is a task
agents get constantly ("switch us from GPT to Claude", "add a fallback provider")
and the two SDKs differ in enough places — message shape, system prompts, token
params, tool calling, streaming, stop reasons — to break a naive swap.
| Concept | OpenAI | Anthropic |
|---|---|---|
| System prompt | a role:"system" message | top-level system param |
| Messages | messages[] incl. system | messages[] (user/assistant only) |
| Max tokens | max_tokens (optional) | max_tokens (required) |
| Multi-turn | roles in one array | strict user/assistant alternation |
| Tool calling | tools + tool_calls | tools + tool_use/tool_result blocks |
| Response text | choices[0].message.content | content[0].text (content blocks) |
| Stop reason | finish_reason | stop_reason |
| Streaming | SSE deltas | SSE content_block_delta events |
Full detail with examples in CONCEPT-MAP.md.
CONCEPT-MAP.md — every difference, with request/response examples side by side.src/types.ts — a neutral ChatRequest/ChatResponse interface.src/openai_adapter.ts — map neutral ⇄ OpenAI shape.src/anthropic_adapter.ts — map neutral ⇄ Anthropic shape (system extraction,required max_tokens, content-block flattening, stop-reason normalization).
src/provider.ts — one chat(req) that routes to either provider + fallback.test/adapters.test.ts — proves the mappings both ways (Vitest).1. One-time migration: translate your call sites to the neutral interface, then
flip the provider.
2. Multi-provider: keep the neutral interface permanently and switch providers
by config, with automatic fallback when one is down or rate-limited.
Node 18+, TypeScript 5+. (Adapters are transport-shaping only; wire your own HTTP
or the official SDKs behind them.)
Get the full OpenAI to Anthropic Migration Kit and unlock everything.
Get the complete guide with every chapter unlocked, including code samples, diagrams, and best practices.
Access all interactive tools with complete data, all workload profiles, and the full scenario library.
Downloadable source code, configuration files, and working examples from every chapter.
Free updates for life. Every new chapter, tool, and improvement included.