---
title: "Quickstart"
description: "Send your first pirouter request in five steps: create an API key, add credit, send a request, stream it, and find it in the console logs. With an OpenAI, Anthropic or Google SDK, you only change the base URL and the API key."
canonical: "https://pirouter.ai/docs/quickstart"
last-updated: "2026-11-18"
lang: "en"
source: "content/docs/en/(start)/quickstart.mdx"
---

# Quickstart

Send your first pirouter request in five steps: create an API key, add credit, send a request, stream it, and find it in the console logs. With an OpenAI, Anthropic or Google SDK, you only change the base URL and the API key.

Your first request takes about five minutes: create an API key, add credit to your wallet, send a request with [cURL](https://curl.se), Python or TypeScript, and find it in the console logs.

Each of the five steps ends with something you can see before you move on.

![Quickstart takes about five minutes in five steps, each ending in something you can see: create a key, add credit, send a request and get a reply, stream it, and find the request in Logs.](https://pirouter.ai/docs/diagrams/quickstart-steps.en.svg)

1. **Create an API key**

   Open the [console](https://app.pirouter.ai) and sign in with GitHub, Google or an email code. Your first sign-in creates your account; there is no password to set.

   Open **API Keys**, click **Create key**, give it a name and confirm. The dialog shows a key that starts with `sk-pi-`. Store it in an environment variable:

   ```bash
   export PIROUTER_API_KEY="sk-pi-..."
   ```

   ![The Save your API key dialog in the console: the new key starts with sk-pi- and stays hidden until you choose Show key, with a copy button beside it](/docs/shots/key-created.en.webp)

   > **Warning:** The key is shown this one time and cannot be viewed again after you close the dialog. If it leaks, revoke it in the console and create a new one. Revocation takes effect immediately.

   Only workspace owners can create keys. Signing up creates a personal workspace with you as its owner, so on your own account you can.

2. **Add credit to your wallet**

   A new workspace has a balance of 0, and a request the balance cannot cover returns `402`, so add credit before you send one.

   Open **Credits** in the console and click **Add credit**. Only workspace owners can add credit.

   Choose an amount and a payment method, then pay. The minimum for one top-up is $10. You can pay by card, Alipay or WeChat Pay.

   ![The Buy credits page in the console: amounts from $10 to $500 or a custom amount, a payment summary in Hong Kong dollars, and WeChat Pay, Alipay and Card as payment methods](/docs/shots/top-up.en.webp)

   After payment you return to the console and the balance under **Credits** goes up.

   For the currency, the exchange rate and receipts, see [Pricing & billing](https://pirouter.ai/docs/guides/billing.md#add-credit).

3. **Send a request**

   > **Note:** This step uses the OpenAI protocol. Anthropic and Google SDKs use another base URL and request format; see [Anthropic protocol](https://pirouter.ai/docs/api/anthropic.md) and [Gemini protocol](https://pirouter.ai/docs/api/gemini.md).

   The Python and TypeScript versions use the [official OpenAI SDK](https://developers.openai.com/api/docs/libraries). Install it first: `pip install openai` or `npm install openai`.

   Model IDs are written as `vendor/model`; [Models & protocols](https://pirouter.ai/docs/models.md) lists the models you can call. The three versions below send the same request. Pick one and run it:

   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)
   ```

   On success you get status `200` and a JSON body, with the model's reply in `choices[0].message.content`.

   A `401` means the key was not sent or cannot be used; see [Authentication & API keys](https://pirouter.ai/docs/authentication.md#when-authentication-fails). A `402` means the balance is too low. [Errors](https://pirouter.ai/docs/api/errors.md) lists every error code and what to do about it.

4. **Stream the response**

   Add `"stream": true` to the request body, and pass `-N` to curl to turn off output buffering:

   ```bash
   curl -N 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",
       "stream": true,
       "messages": [{ "role": "user", "content": "Hello!" }]
     }'
   ```

   The response is a series of server-sent events, each line starting with `data: `. The last line is `data: [DONE]`.

   With an SDK, pass `stream=True` (TypeScript: `stream: true`) and read `choices[0].delta.content` from each chunk.

5. **See it in Logs**

   Open **Logs** in the console. The request you just sent is in the list, with its input and output tokens, cost and latency. A request takes a few seconds to appear.

   Every response carries an `X-Pi-Trace-Id` header; pass `-i` to curl to see it. Paste its value into **Search by trace ID** on the Logs page to go straight to that request.

## Next steps

- [How pirouter works](https://pirouter.ai/docs/how-it-works.md): How a request travels from your API key to a provider and back to your wallet.
- [Authentication & API keys](https://pirouter.ai/docs/authentication.md): Which header carries the key, and how keys expire and are revoked.
- [Models & protocols](https://pirouter.ai/docs/models.md): Which protocols each model accepts, and the address of each protocol.
- [Integrations](https://pirouter.ai/docs/integrations.md): Point the official SDKs and frameworks at pirouter.
