---
title: "Introduction"
description: "The pirouter docs: one API key calls models from every vendor over the OpenAI, Anthropic and Gemini protocols, with each request spread across the providers that serve its model and failed over automatically."
canonical: "https://pirouter.ai/docs"
last-updated: "2026-10-18"
lang: "en"
source: "content/docs/en/(start)/index.mdx"
---

# The Best Router for LLMs

pirouter is an LLM router: one API to access models from OpenAI, Anthropic, Google and more, with every request routed to the best upstream. One key works across the OpenAI, Anthropic and Gemini protocols.

By default a request is spread by weight across the providers that serve its model and fails over when one fails. You can sort providers by price, set an order, or keep to providers that meet your data policy; see [Provider routing](https://pirouter.ai/docs/guides/routing.md).

- [Quickstart](https://pirouter.ai/docs/quickstart.md)
- [API reference](https://pirouter.ai/docs/api.md)

cURL:

```bash
curl https://api.pirouter.ai/v1/chat/completions \
  -H "Authorization: Bearer $PIROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/gpt-6.2-astra",
    "messages": [{ "role": "user", "content": "Hello!" }]
  }'
```

Python:

```python
import os
from openai import OpenAI

client = OpenAI(
    base_url="https://api.pirouter.ai/v1",
    api_key=os.environ["PIROUTER_API_KEY"],
)

completion = client.chat.completions.create(
    model="openai/gpt-6.2-astra",
    messages=[{"role": "user", "content": "Hello!"}],
)
print(completion.choices[0].message.content)
```

TypeScript:

```ts
import OpenAI from 'openai'

const client = new OpenAI({
  baseURL: 'https://api.pirouter.ai/v1',
  apiKey: process.env.PIROUTER_API_KEY,
})

const completion = await client.chat.completions.create({
  model: 'openai/gpt-6.2-astra',
  messages: [{ role: 'user', content: 'Hello!' }],
})
console.log(completion.choices[0].message.content)
```

## SDK base URLs

- OpenAI: `https://api.pirouter.ai/v1`
- Anthropic: `https://api.pirouter.ai`
- Gemini: `https://api.pirouter.ai`

If you already use one of the three official SDKs, change two things: the base URL above and your pirouter API key. One key works on all three protocols.

For the full paths when you send HTTP requests directly, see [The three protocols](https://pirouter.ai/docs/models.md#the-three-protocols).

## Start here

- [Make your first request](https://pirouter.ai/docs/quickstart.md): Create a key, add credit and call a model.
- [Learn how it works](https://pirouter.ai/docs/how-it-works.md): How API keys, models, providers and deployments fit together.
- [Connect your tools](https://pirouter.ai/docs/integrations.md): Point the official SDKs and frameworks at pirouter.

## Find by task

- [Stay available](https://pirouter.ai/docs/guides/fallbacks.md): Fall back to the next model when yours is unavailable.
- [Control cost](https://pirouter.ai/docs/guides/routing.md): Sort providers by price, or set your own order.
- [Debug a failure](https://pirouter.ai/docs/guides/logs.md): Find a request by its trace ID and see each attempt.
- [Review data handling](https://pirouter.ai/docs/guides/data-policy.md): What metadata is recorded, and how to use zero data retention providers only.
- [Handle error codes](https://pirouter.ai/docs/api/errors.md): What each error code means, and which ones to retry.
- [Let AI coding tools read the docs](https://pirouter.ai/docs/build-with-ai.md): llms.txt, Markdown pages and the docs MCP server.

## Before you integrate

- [Authentication & API keys](https://pirouter.ai/docs/authentication.md): Which header carries the key, and how keys are created, expire and are revoked.
- [Models & protocols](https://pirouter.ai/docs/models.md): How model IDs are written and which protocols each model accepts.
- [Pricing & billing](https://pirouter.ai/docs/guides/billing.md): How the prepaid wallet is charged, how to add credit, and what happens when it runs out.
