Skip to main content

OpenAI Chat Format

fromChatMessages()

Convert OpenAI chat-style messages to OpenResponses input:

toChatMessage()

Convert an OpenResponses response to chat message format:

Supported Message Types

Tool Messages

Tool responses are converted to function call outputs:

Anthropic Claude Format

fromClaudeMessages()

Convert Anthropic Claude-style messages to OpenResponses input:

toClaudeMessage()

Convert an OpenResponses response to Claude message format:

Content Blocks

Claude’s content block format is supported:

Tool Use Blocks

Claude’s tool use format is converted:

Base64 Images

Both URL and base64 images are supported:

Limitations

Some Claude features are not preserved in conversion. e.g. is_error flag on tool_result blocks These features are Claude-specific and not supported by OpenRouter.

Migration Examples

From OpenAI SDK

From Anthropic SDK

Building Conversations

Accumulate messages across multiple calls:

Next Steps