Skip to content
All posts

A unified AI API: one endpoint, every provider dialect

OpenAI ships /chat/completions, Anthropic ships /messages, OpenAI's newer surface is /responses. A unified AI API speaks all of them at one URL, so the client library you already use keeps working. You swap the base URL, not the code.

Unify the contract, not just the routing

Routing many models behind one endpoint solves half the fragmentation problem. The other half is dialect: OpenAI's SDK expects /chat/completions, Anthropic's SDK expects /messages, and OpenAI's newer Responses API expects /responses. A unified AI API implements all three request shapes on one surface, so whichever SDK your codebase already speaks keeps working unchanged.

DialectEndpointFor
OpenAI chat/api/v1/chat/completionsDrop-in for OpenAI's chat SDK
Anthropic messages/api/v1/messagesDrop-in for Claude clients
OpenAI Responses/api/v1/responsesThe newer OpenAI Responses surface
Embeddings/api/v1/embeddingsOpenAI-style vector embeddings

The same model, two dialects

Because the contract is the standard API, you keep the client library you have and just point it at AnyRouter. An OpenAI client:

OpenAI SDK, swap the base URL, keep the code
from openai import OpenAI

client = OpenAI(base_url="https://anyrouter.dev/api/v1", api_key="sk-ar-v1-...")
resp = client.chat.completions.create(
  model="anthropic/claude-opus-4-8",
  messages=[{"role": "user", "content": "Hello"}],
)

…or an Anthropic client, against the same account and key:

Anthropic SDK, same key, the /messages surface
from anthropic import Anthropic

client = Anthropic(base_url="https://anyrouter.dev/api", api_key="sk-ar-v1-...")
msg = client.messages.create(
  model="anthropic/claude-opus-4-8",
  max_tokens=256,
  messages=[{"role": "user", "content": "Hello"}],
)

No SDK lock-in

A unifying layer is only safe if leaving it is easy. Every surface here is a public standard, not a proprietary protocol. The same code points straight back at OpenAI or Anthropic if you ever move on. Model ids become provider/model strings, so choosing a model is a config value, and you get one key, one bill, and one audit log across every dialect.

This is the contract side of the story. For the routing side, automatic failover and provider preferences across hundreds of models, see /blog/one-api-every-llm.

One endpoint that speaks OpenAI chat, Anthropic /messages, and the Responses API.

See the unified API