---
title: "Headers"
description: "Authentication, attribution and Anthropic request headers, the host header on every response, and the cost header on every non-streamed response."
---

# Headers

## Host and paths

The API host is `https://api.plaingateway.com`. Every API path is served under both `/api/v1` and `/v1`, so `https://api.plaingateway.com/api/v1/models` and `https://api.plaingateway.com/v1/models` are the same.
`GET /healthz` is the one exception: it answers at the root only, `https://api.plaingateway.com/healthz`.
The site host, `plaingateway.com`, serves no API.

## Request headers

| Header | Use |
|---|---|
| `Authorization: Bearer sk-pg-v1-...` | Your key. |
| `X-Api-Key: sk-pg-v1-...` | Your key, as Anthropic SDKs and Claude Code send it. Used when there is no `Authorization` header. |
| `HTTP-Referer` | Your app's URL, for [app attribution](../features/app-attribution.md). |
| `X-OpenRouter-Title` or `X-Title` | Your app's name, for app attribution. |
| `Anthropic-Version`, `Anthropic-Beta` | Passed to Anthropic hosts on `/messages`. Without `Anthropic-Version` the gateway sends `2023-06-01`. |

`GET /models`, `GET /models/{author}/{slug}/endpoints` and `GET /healthz` need no key.
Browsers can call the API directly: every response allows any origin (CORS).

## Response headers

| Header | Meaning |
|---|---|
| `X-PG-Host` | The host that served the request, or `none`. |
| `X-PG-Cost-USD` | The charge in USD, on a non-streamed answer. On a stream, read `usage.cost` in the final usage chunk. |
| `X-Generation-Id` | The generation id. Pass it to [GET /generation](generation.md). |
| `X-PG-Request-Id` | The same value as `X-Generation-Id`. |
| `Retry-After` | Passed through when the host sent it, usually on 429. |

The `id` of a chat, completions or Responses answer is the generation id too. A `/messages` answer keeps a `msg_` id, so read the header there.

## Example

### Request

```sh
curl -i https://api.plaingateway.com/api/v1/chat/completions \
  -H "Authorization: Bearer $PLAINGATEWAY_API_KEY" \
  -H "Content-Type: application/json" \
  -H "HTTP-Referer: https://example.com" \
  -H "X-Title: Example app" \
  -d '{"model": "openai/gpt-5.6-luna", "messages": [{"role": "user", "content": "Say hello in five words."}], "max_tokens": 32}'
```

### Response headers

```http
HTTP/1.1 200
Content-Type: application/json
X-Generation-Id: gen-6f2d0c5e9a1b4c7d8e3f2a10
X-PG-Request-Id: gen-6f2d0c5e9a1b4c7d8e3f2a10
X-PG-Host: OpenAI
X-PG-Cost-USD: 0.0000156
Access-Control-Allow-Origin: *
```
