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 plus continuation envelopeKeep visible thinking as Responses reasoning content and store the Anthropic signature in encrypted_content for a compatible client to replay.
redacted_thinking blockReasoning output item continuation envelopeCarry provider-opaque data in the same client-held envelope; do not expose it as visible content.
stop_reasonResponses terminal status and output stateMap terminal behavior, not just field names.

Anthropic thinking signatures and redacted-thinking payloads are provider-scoped, but they are required when a client replays assistant history back to Anthropic. For the anthropic_messages → openai_responses pair, ProxAI writes a versioned continuation envelope into the standard Responses reasoning.encrypted_content field. On a later openai_responses → anthropic_messages request, it recognizes that envelope, removes it from the Responses representation, and restores the original Anthropic thinking or redacted_thinking block.

This is client-carried state, not proxy persistence. It only round-trips when the client preserves and replays Responses reasoning items. The envelope is prefixed and JSON-encoded, not cryptographically encrypted or authenticated; the encrypted_content name is the existing Responses carrier field. An unknown encrypted_content value is provider-scoped and is trace-skipped during Responses-to-Anthropic translation; only the versioned ProxAI prefix identifies restorable continuation data.

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 is preserved only for clients that replay ProxAI’s continuation envelope; other provider-specific metadata may still have no Responses equivalent.
  • Anthropic pause_turn and refusal metadata need behavior-preserving target semantics.
  • Usage and stop metadata may arrive late in streams.