OpenAI to Anthropic Migration Kit
A concept map + tested neutral adapter for migrating between (or supporting both) the OpenAI and Anthropic APIs: system prompts, required max_tokens, tool calling, stop reasons, streaming.
Product Preview
Try the interactive reader and demo tools below, or get the full product with all content unlocked.
Interactive Reader (Free Preview) Download Free SampleFile Structure 8 files
Documentation Preview README excerpt
OpenAI ↔ Anthropic SDK Migration Kit
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.
What actually differs (the map)
| 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.
What's inside
CONCEPT-MAP.md— every difference, with request/response examples side by side.src/types.ts— a neutralChatRequest/ChatResponseinterface.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— onechat(req)that routes to either provider + fallback.test/adapters.test.ts— proves the mappings both ways (Vitest).
Use it two ways
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.
Requirements
Node 18+, TypeScript 5+. (Adapters are transport-shaping only; wire your own HTTP
or the official SDKs behind them.)
License
MIT.