---
title: "How pirouter works"
description: "How a pirouter request travels: the API key picks the workspace and wallet, the model ID picks the candidate providers, the gateway forwards to one deployment and fails over on errors, and the wallet is charged for actual usage. With the glossary of the docs."
canonical: "https://pirouter.ai/docs/how-it-works"
last-updated: "2026-11-18"
lang: "en"
source: "content/docs/en/(start)/how-it-works.mdx"
---

# How pirouter works

How a pirouter request travels: the API key picks the workspace and wallet, the model ID picks the candidate providers, the gateway forwards to one deployment and fails over on errors, and the wallet is charged for actual usage. With the glossary of the docs.

A request finds its workspace and wallet through the API key, and the providers that serve its model through the model ID. The gateway forwards it to one deployment, fails over to the next provider on errors, and charges the wallet for the actual usage when the request ends.

## Seven objects

| Object     | What it is                                                                                                 | Example                                         |
| ---------- | ---------------------------------------------------------------------------------------------------------- | ----------------------------------------------- |
| Workspace  | The unit of an account. API keys, the wallet, routing settings, usage and logs all belong to one workspace | The personal workspace created when you sign up |
| API key    | The credential for calling the API. It belongs to one workspace and starts with `sk-pi-`                   | `$PIROUTER_API_KEY`                             |
| Wallet     | The workspace's prepaid balance; every request is charged to it                                            | **Credits** in the console                      |
| Vendor     | The company that makes the model; the first half of the model ID                                           | `openai`, `anthropic`, `google`                 |
| Model      | The `vendor/model` you write in the request                                                                | `openai/gpt-6.2-astra`                          |
| Provider   | The service that runs the model and answers the request                                                    | `anthropic`, `azure`                            |
| Deployment | One instance of a model at a provider, with its own per-minute quota                                       | One deployment of a provider in one region      |

A vendor and a provider can share a name without being the same layer: the vendor of `anthropic/claude-…` is [Anthropic](https://www.anthropic.com), and the provider serving it can be `anthropic` or `azure`.

A request carries two things: the API key finds your workspace, and the model ID finds the providers that run the model.

![A request carries an API key and a model ID: the key finds your workspace, which holds the wallet, routing settings and usage, and the model ID finds the providers that run that model, such as Anthropic and Azure for claude-opus-5.5.](https://pirouter.ai/docs/diagrams/object-model.en.svg)

## How a request travels

A request enters the nearest cloud CDN edge and goes from there straight to a provider; when one provider is down, it switches to another. pirouter only reads the token usage off a side path on the way back, so requests never pass through pirouter's servers.

![A request enters the nearest cloud CDN edge and goes from there straight to a provider, switching to another one when a provider is down; pirouter only reads the token usage off a side path on the way back, so requests never pass through pirouter's servers.](https://pirouter.ai/docs/diagrams/request-route.en.svg)

1. **Authenticate**: the gateway reads the API key in `Authorization: Bearer` and finds the workspace.
2. **Find candidates**: it finds the providers that serve the model ID, then narrows them with the request's `provider` field and the workspace's routing settings.
3. **Pick one**: by default it picks among the candidates by weight; the workspace can switch to price first or its own order.
4. **Forward**: it sends the request to the chosen provider. On a failure it moves to the next provider (failover); when every provider has failed and fallback models are set (`models` in the request, or the workspace's fallback models), it moves to the next model (model fallback).

Before forwarding, the gateway also checks quota and balance: a deployment whose per-minute quota is used up answers `429`, and a balance that is too low answers `402`. When the request ends, it is charged for the actual usage.

Each step has its own page: [Authentication & API keys](https://pirouter.ai/docs/authentication.md), [Pricing & billing](https://pirouter.ai/docs/guides/billing.md), [Provider routing](https://pirouter.ai/docs/guides/routing.md), [Rate limits](https://pirouter.ai/docs/api/rate-limits.md) and [Model fallbacks](https://pirouter.ai/docs/guides/fallbacks.md).

## Glossary

The docs use one word for each concept:

| Term                      | Meaning                                                                     | Not used           |
| ------------------------- | --------------------------------------------------------------------------- | ------------------ |
| Vendor                    | The company that makes a model                                              | —                  |
| Provider                  | The service that serves a model                                             | supplier, upstream |
| Deployment                | One instance of a model at a provider                                       | —                  |
| Failover                  | Moving the same model to another provider                                   | —                  |
| Model fallback            | Moving to the next model in `models`                                        | backup model       |
| API key                   | The credential                                                              | secret, token      |
| Zero data retention (ZDR) | The provider keeps no prompts or responses                                  | —                  |
| Trace ID                  | The `X-Pi-Trace-Id` of every response; include it when you report a problem | request ID         |
| Endpoint                  | One API path, such as `/v1/chat/completions`                                | —                  |

## Console labels

Where the docs quote the console, they use its labels in bold:

| Console label                | Term in the docs |
| ---------------------------- | ---------------- |
| **Providers**                | provider         |
| **Create key**, **API keys** | API key          |
| **Credits**                  | wallet           |
| **Trace ID**                 | trace ID         |

## Next steps

- [Quickstart](https://pirouter.ai/docs/quickstart.md): Create a key, top up, and call a model.
- [Provider routing](https://pirouter.ai/docs/guides/routing.md): How a provider is picked, and how to change it.
