---
title: "API overview"
description: "The pirouter API serves inference endpoints for the OpenAI, Anthropic and Gemini protocols and four public model catalog endpoints from one host, https://api.pirouter.ai, and one API key works on every endpoint that needs one."
canonical: "https://pirouter.ai/docs/api"
last-updated: "2026-11-19"
lang: "en"
source: "content/docs/en/api/index.mdx"
---

# API overview

The pirouter API serves inference endpoints for the OpenAI, Anthropic and Gemini protocols and four public model catalog endpoints from one host, https://api.pirouter.ai, and one API key works on every endpoint that needs one.

The pirouter API serves inference endpoints for three protocols and four public model catalog endpoints from one host. The path decides the protocol, one API key works on every endpoint that needs one, and errors are handled by `error.code`.

## Server

Every endpoint is served from one host:

`Base URL`:

```text
https://api.pirouter.ai
```

A model is served only on the protocols it is registered for. The gateway does one protocol translation: OpenAI GPT text models also accept the Anthropic protocol, see [GPT models also accept the Anthropic protocol](https://pirouter.ai/docs/models.md#gpt-models-also-accept-the-anthropic-protocol). [Models & protocols](https://pirouter.ai/docs/models.md) lists which model accepts which. How to use each protocol is in [OpenAI protocol](https://pirouter.ai/docs/api/openai.md), [Anthropic protocol](https://pirouter.ai/docs/api/anthropic.md) and [Gemini protocol](https://pirouter.ai/docs/api/gemini.md).

Image generation on the Gemini protocol goes through `generateContent` too; there is no separate endpoint. See [Generate and edit images](https://pirouter.ai/docs/guides/images.md).

## Authentication

Send your key in one of two headers. Both carry the same key, and `Authorization` wins when a request has both.

`As a bearer token`:

```http
Authorization: Bearer $PIROUTER_API_KEY
```

`Or in X-Api-Key`:

```http
X-Api-Key: $PIROUTER_API_KEY
```

The four model catalog endpoints are public: they need no key and read none.

> **Warning:** Never ship a key in browser code or a mobile app. Call pirouter from your server and keep the key in an environment variable.

## Errors

An error body comes in one of two shapes, depending on which family the endpoint belongs to.

The inference endpoints (chat completions, responses, messages, the two Gemini endpoints and images) return errors in this shape, whichever protocol they speak. `message` and `type` are always there; `code` is nearly always there, missing only on the three statuses listed in [Errors without a code](https://pirouter.ai/docs/api/errors.md#errors-without-a-code):

```json
{
  "error": {
    "message": "No such model. Model names are vendor-qualified (vendor/model), so a name copied from a provider's own docs needs its vendor prefix added. Call GET /v1/models for the slugs this gateway serves.",
    "type": "not_found_error",
    "code": "model_not_found"
  }
}
```

The four model catalog endpoints return a code and a message, and no `type`:

```json
{
  "error": {
    "code": "model_not_found",
    "message": "string"
  }
}
```

Branch on `error.code`, which is a stable string, and fall back to `error.type` where a response has no code. Do not match on the text of `message`. Each endpoint page lists the codes that endpoint can return and shows its error body; [Errors](https://pirouter.ai/docs/api/errors.md) explains every code and whether to retry it.

An error the provider itself returned is passed on with its own status and body, not rewritten into these shapes.

## Endpoints

| Protocol  | Endpoint                                                                           | Method | Path                                           |
| --------- | ---------------------------------------------------------------------------------- | ------ | ---------------------------------------------- |
| OpenAI    | [Create chat completion](https://pirouter.ai/docs/api/chat-completions.md)         | `POST` | `/v1/chat/completions`                         |
| OpenAI    | [Create response](https://pirouter.ai/docs/api/responses.md)                       | `POST` | `/v1/responses`                                |
| OpenAI    | [Create image](https://pirouter.ai/docs/api/images.md)                             | `POST` | `/v1/images/generations`                       |
| OpenAI    | [Edit image](https://pirouter.ai/docs/api/image-edits.md)                          | `POST` | `/v1/images/edits`                             |
| Anthropic | [Create message](https://pirouter.ai/docs/api/messages.md)                         | `POST` | `/v1/messages`                                 |
| Gemini    | [Generate content](https://pirouter.ai/docs/api/generate-content.md)               | `POST` | `/v1beta/models/{model}:generateContent`       |
| Gemini    | [Stream generate content](https://pirouter.ai/docs/api/stream-generate-content.md) | `POST` | `/v1beta/models/{model}:streamGenerateContent` |
| Catalog   | [List models](https://pirouter.ai/docs/api/list-models.md)                         | `GET`  | `/v1/models`                                   |
| Catalog   | [List models by vendor](https://pirouter.ai/docs/api/list-models-by-vendor.md)     | `GET`  | `/v1/models/{vendor}`                          |
| Catalog   | [Get model](https://pirouter.ai/docs/api/get-model.md)                             | `GET`  | `/v1/models/{vendor}/{model}`                  |
| Catalog   | [List model endpoints](https://pirouter.ai/docs/api/list-model-endpoints.md)       | `GET`  | `/v1/models/{vendor}/{model}/endpoints`        |

A path or method outside this list returns `404` with the error code `not_found`; see [`not_found`](https://pirouter.ai/docs/api/errors.md#not_found).

## OpenAPI specification

The endpoint pages match the OpenAPI 3.1 specification of the API. Download it to generate a client or to load it into your own tools: [openapi.json](https://pirouter.ai/docs/api/openapi.json).

## Next steps

- [Quickstart](https://pirouter.ai/docs/quickstart.md): Create a key, top up, and call a model.
- [Errors](https://pirouter.ai/docs/api/errors.md): What each error code means and how to handle it.
