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
`src/ingress/` parses Chat messages and tools
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.
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 blockChat-compatible reasoning extension when supportedPlain Chat has weak reasoning structure; do not mix reasoning into ordinary content unless required.
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.
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.
  • Reasoning support is weaker and often extension-based.
  • 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.