Skip to content

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
Anthropic conceptResponses targetNotes
Message envelopeResponses response envelopeAnthropic returns one final message; Responses returns an envelope with output[].
Text blockMessage output item/content partPreserve visible text order.
tool_use blockfunction_call output itemPreserve call identity using Responses item/call identifiers.
thinking blockReasoning output item when representableTransform provider-specific metadata instead of raw round-tripping.
stop_reasonResponses terminal status and output stateMap terminal behavior, not just field names.
Anthropic eventResponses-side behavior
message_startInitialize response and usage state.
content_block_startEmit or stage a Responses output item depending on block type.
content_block_deltaEmit text, reasoning, or function-argument deltas.
content_block_stopFinalize the current Responses item/content part.
message_deltaUpdate stop and usage metadata; may not have a standalone Responses event.
message_stopEmit Responses terminal event such as response.completed.
AnthropicResponsesConsequence
Content block indexStable item_id plus output indexThe translator must mint/track item ids for Responses events.
Tool id / tool result linkageFunction call item id and call_idDo not expose raw provider ids as the only client identity.
Message-level terminal metadataResponse status plus item statusTerminal state may need to update both envelope and output items.
  • Anthropic content block index is 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_turn and refusal metadata need behavior-preserving target semantics.
  • Usage and stop metadata may arrive late in streams.