Skip to main content

OpenAI Chat Format

fromChatMessages()

Convert OpenAI chat-style messages to OpenResponses input:
Output

toChatMessage()

Convert an OpenResponses response to chat message format:
Output

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:
Output

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

Output

From Anthropic SDK

Output

Building Conversations

Accumulate messages across multiple calls:
Output

Next Steps