Skip to content
AnyRouter
All posts

One OpenAI-compatible API for every model

An OpenAI-compatible gateway lets you keep your client and change two settings. This post shows the four API shapes behind one AnyRouter base URL, a working request, and how model ids are written.

What does OpenAI-compatible mean?

Many apps already talk to the OpenAI API. An OpenAI-compatible gateway accepts those same requests, so you do not rewrite the client.

The gateway then routes the request to the model you named. AnyRouter is an LLM gateway: one API key, one base URL, and hundreds of models behind it.

Which API shapes sit behind one base URL?

AnyRouter serves four shapes at https://anyrouter.dev/api/v1. Pick the one your client already speaks.

API shapePath under the base URL
OpenAI Chat Completions/chat/completions
OpenAI Responses/responses
OpenAI Embeddings/embeddings
Anthropic Messages/messages

The Chat Completions page shows the unified shape in detail.

How do I switch an existing client?

  1. 1

    Create a key. Make an inference key in the dashboard. It starts with sk-ar-v1-.

  2. 2

    Change the base URL. Set it to https://anyrouter.dev/api/v1.

  3. 3

    Name a model. Use a provider/model id, such as anyrouter/free.

export ANYROUTER_API_KEY="sk-ar-v1-your-key"

curl https://anyrouter.dev/api/v1/chat/completions \
  -H "Authorization: Bearer $ANYROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "anyrouter/free",
    "messages": [{"role": "user", "content": "Hello!"}]
  }'
from openai import OpenAI

client = OpenAI(
    base_url="https://anyrouter.dev/api/v1",
    api_key="sk-ar-v1-your-key",
)

response = client.chat.completions.create(
    model="anyrouter/free",
    messages=[{"role": "user", "content": "Hello!"}],
)
print(response.choices[0].message.content)
import OpenAI from "openai"

const client = new OpenAI({
  baseURL: "https://anyrouter.dev/api/v1",
  apiKey: "sk-ar-v1-your-key",
})

const response = await client.chat.completions.create({
  model: "anyrouter/free",
  messages: [{ role: "user", content: "Hello!" }],
})
console.log(response.choices[0].message.content)

The full walkthrough is the quickstart. For the Vercel AI SDK, see the AI SDK page.

How are model ids written?

Every id has the form provider/model. The part before the slash names the provider or owner. The part after it names the model.

  • moonshotai/kimi-k3.1-pro is a model from moonshotai.
  • anyrouter/free asks AnyRouter to pick a working free model.

Browse every id on the models page. Switching models means changing one string. If one upstream fails, model fallbacks can retry on another.

Where do I go next?

Read Unify an LLM API for the idea behind one endpoint, and one endpoint for every AI API for the wider set of shapes. For routing and failover in general, see the LLM gateway page. To use your own provider keys, read BYOK.

Official site

The official AnyRouter domain is https://anyrouter.dev, shortened as https://anyr.dev. It is the only valid domain for the API, docs, models, pricing and terms.

Sites on other domains that use the AnyRouter name are clones and are not affiliated with AnyRouter. Check the domain before you send API keys or payments.

FAQ

What does OpenAI-compatible mean for a gateway?

The gateway accepts the same requests as the OpenAI API and returns the same response shape. Your existing OpenAI client works after you change the base URL and the API key.

Which API shapes does AnyRouter accept?

OpenAI Chat Completions, Responses and Embeddings, and Anthropic Messages. All four sit behind the base URL https://anyrouter.dev/api/v1.

How do I name a model?

Write provider/model, for example moonshotai/kimi-k3.1-pro. The id tells the gateway which model to route to.

Do I need a separate key for each provider?

No. One AnyRouter inference key (it starts with sk-ar-v1-) reaches every model. You can also bring your own provider keys at $0 markup.

Related posts