Skip to content

OpenAI Chat Completions to Anthropic Messages

OpenAI Chat Completions to Anthropic Messages

Section titled “OpenAI Chat Completions to Anthropic Messages”

This page documents the conversion pair used when a client speaks OpenAI Chat Completions and the selected provider speaks Anthropic Messages.

Inbound
`openai_chat_completions` request payload
Normalize
`proxai-core/ingress` validates the structured Chat request
Translate request
Chat messages/tools -> Anthropic Messages request
Translate response
Anthropic Message/content blocks -> Chat choices
Outbound
`openai_chat_completions` response or SSE chunks
Chat conceptAnthropic Messages targetNotes
messages[]messages[] plus normalized system placementChat system/developer instructions must not be duplicated as user-visible turns.
Assistant textAssistant content blocksPreserve ordered visible text.
Assistant reasoning_contentAnthropic thinking blocks when a ProxAI continuation is presentA versioned continuation suffix restores signed or redacted Anthropic thinking and is removed before forwarding. Plain unsigned reasoning has no Anthropic signature, so translation traces and skips it rather than forging one.
tools[] function definitionstools[]Preserve name, description, and JSON schema where possible.
Assistant tool_calls[]Anthropic tool_use blocksChat tool_calls[].index is stream-local; Anthropic content blocks use content-block indices.
Tool result messagesAnthropic tool_result blocksPreserve call id linkage where target protocol can represent it.
Anthropic conceptChat targetNotes
Text content blockchoices[0].message.contentChat has a single assistant message per choice.
Tool use blockchoices[0].message.tool_calls[]Assign stable call ids and function names.
Thinking/reasoning blockchoices[0].message.reasoning_contentZed consumes this OpenAI-compatible extension as thinking output; ProxAI appends a versioned continuation suffix to preserve Anthropic signatures and redacted payloads for replay without mixing them into visible content.
stop_reasonfinish_reasonMap natural turns, token limits, tool use, and refusals carefully.
Anthropic eventChat SSE expectation
message_startInitialize choice and assistant role delta.
Text content_block_deltaEmit delta.content chunks.
Thinking content_block_deltaEmit delta.reasoning_content chunks consumed by Zed as thinking; append the continuation suffix before the terminal chunk.
Tool input_json_deltaEmit delta.tool_calls[].function.arguments chunks keyed by Chat tool index.
message_delta.stop_reasonSet final finish_reason when terminal state is known.
message_stopEmit final chunk and [DONE].
  • Chat has no native output item graph.
  • Plain thinking text is preserved through the reasoning_content compatibility extension. ProxAI appends its versioned continuation suffix only for compatible clients that replay it; Chat itself still has no native per-item identity or signature field.
  • The continuation suffix can preserve redacted/encrypted thinking across ProxAI’s Anthropic conversion pair, but is not a portable Chat Completions feature.
  • Chat streaming uses tool_calls[].index; Anthropic streaming uses content block index.
  • Chat [DONE] is a stream carrier terminator; Anthropic message_stop is the semantic terminal event.