Blog · Engineering
How to Use Both OpenAI Chat Completions and Anthropic Messages on a Single API Key
· Moyra Engineering
Moyra natively speaks /v1/chat/completions, /v1/responses, and /v1/messages—allowing any model in the catalog to be called from either SDK.
Three native wire protocols
Modern AI stacks rarely stick to a single wire format. Your backend service might use the OpenAI Python SDK, your agent runner might expect OpenAI Responses, and your coding assistant might speak Anthropic Messages.
Moyra translates and routes across all three endpoints (/v1/chat/completions, /v1/responses, and /v1/messages) using the same virtual API key and unified credit balance.
from anthropic import Anthropic
client = Anthropic(
base_url="https://moyra.ai.id",
api_key="sk-moyra-...",
)
msg = client.messages.create(
model="anthropic/claude-3-5-sonnet-latest",
max_tokens=1024,
messages=[{"role": "user", "content": "Review this Rust trait implementation."}],
)
print(msg.content[0].text)Preserving prompt caching and tool calls
When calling Anthropic models via /v1/messages, Moyra preserves cache_control breakpoints on system prompts, tools, and user turns so you get full upstream prompt-cache discounts.
Tool definitions and streaming deltas (including reasoning_content chunks) are normalized automatically across providers.