Messages To Openai
Transforms Anthropic Messages API requests and responses for Chat Completions-compatible inference backends
Category: Setup-dependent integration
Task: Transforms Anthropic Messages API requests and responses for Chat Completions-compatible inference backends
Prerequisites: The external service, credentials, or certificates referenced by this configuration.
Run it: Use ghcr.io/praxis-proxy/ai:0.4.1 and follow the container quickstart to mount and start the configuration.
This configuration comes from the selected release. The example has not been run here; external services are not bundled.
Download the source file.
# Anthropic Messages to Chat Completions
#
# Transforms Anthropic Messages API requests and responses for
# Chat Completions-compatible inference backends.
#
# The `anthropic_messages_to_chat_completions` filter name reflects the
# wire formats it bridges. It targets the Chat Completions wire shape,
# so any Chat Completions-compatible backend can use it, not only OpenAI.
#
# Request: system hoisting, content block flattening, tool mapping.
# Response: content blocks, stop_reason, usage mapping back to
# Anthropic format. Streaming responses are converted by
# `anthropic_messages_to_chat_completions_stream`.
listeners:
- name: anthropic-gateway
address: "127.0.0.1:8080"
filter_chains: [anthropic-transform]
filter_chains:
- name: anthropic-transform
filters:
- filter: anthropic_messages_format
on_invalid: continue
- filter: anthropic_messages_to_chat_completions
max_body_bytes: 1048576
# response_conditions is optional: the filter self-arms via
# metadata and Content-Type checks internally. Adding it
# skips filter dispatch entirely for non-SSE responses.
- filter: anthropic_messages_to_chat_completions_stream
max_partial_event_bytes: 10485760
# Cap on distinct streaming tool-call content blocks retained per
# response. Bounds per-response memory when an upstream streams
# many unique tool-call indices; exceeding it fails the stream
# closed.
max_tool_blocks: 10000
response_conditions:
- when:
headers:
content-type: "text/event-stream"
- filter: path_rewrite
replace:
pattern: "^/v1/messages$"
replacement: "/v1/chat/completions"
conditions:
- when:
path_prefix: "/v1/messages"
- filter: router
routes:
- path_prefix: "/"
cluster: "chat-completions-backend"
- filter: load_balancer
clusters:
- name: "chat-completions-backend"
endpoints:
- "127.0.0.1:8000"
insecure_options:
allow_private_endpoints: true # example proxies to local backends