Anthropic Messages to OpenAI Responses
Anthropic Messages to OpenAI Responses
Section titled “Anthropic Messages to OpenAI Responses”This page documents the conversion path used when the provider speaks Anthropic Messages and the client expects OpenAI Responses output.
Provider response
`anthropic_messages` Message or SSE stream
Read upstream
`src/upstream/` reads body or ByteStream
Translate response
Anthropic content blocks -> Responses output items
Rebuild client response
`src/http_support/` emits Responses JSON or typed SSE
Client response
`openai_responses` envelope or events
Non-streaming response mapping
Section titled “Non-streaming response mapping”| Anthropic concept | Responses target | Notes |
|---|---|---|
Message envelope | Responses response envelope | Anthropic returns one final message; Responses returns an envelope with output[]. |
| Text block | Message output item/content part | Preserve visible text order. |
tool_use block | function_call output item | Preserve call identity using Responses item/call identifiers. |
thinking block | Reasoning output item when representable | Transform provider-specific metadata instead of raw round-tripping. |
stop_reason | Responses terminal status and output state | Map terminal behavior, not just field names. |
Streaming event mapping
Section titled “Streaming event mapping”| Anthropic event | Responses-side behavior |
|---|---|
message_start | Initialize response and usage state. |
content_block_start | Emit or stage a Responses output item depending on block type. |
content_block_delta | Emit text, reasoning, or function-argument deltas. |
content_block_stop | Finalize the current Responses item/content part. |
message_delta | Update stop and usage metadata; may not have a standalone Responses event. |
message_stop | Emit Responses terminal event such as response.completed. |
Identity differences
Section titled “Identity differences”| Anthropic | Responses | Consequence |
|---|---|---|
Content block index | Stable item_id plus output index | The translator must mint/track item ids for Responses events. |
Tool id / tool result linkage | Function call item id and call_id | Do not expose raw provider ids as the only client identity. |
| Message-level terminal metadata | Response status plus item status | Terminal state may need to update both envelope and output items. |
Lossy areas
Section titled “Lossy areas”- Anthropic content block
indexis stream-local; Responses item identity is client-visible and can be stable across turns. - Provider-specific thinking metadata may not have a Responses equivalent.
- Anthropic
pause_turnand refusal metadata need behavior-preserving target semantics. - Usage and stop metadata may arrive late in streams.