> For the complete documentation index, see [llms.txt](https://docs.avis.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.avis.xyz/api-reference/introduction/authentication.md).

# Authentication

Every request to any of the three API surfaces requires authentication, except the `HEAD` connectivity probes (`HEAD /api/openai`, `HEAD /api/anthropic`, `HEAD /api/gemini`).

Accepted auth on protected routes:

* `x-api-key: <api-key>`
* `Authorization: Bearer <api-key>`

### Creating an API key

1. Sign in at [avis.xyz](https://avis.xyz).
2. Go to **Settings → API Keys**.
3. Click **Create key**, give it a name, and save it somewhere safe — the raw key is only shown once at creation time (it can be revealed again later from the same page).

A single account may have a limit on the number of API keys. Creating past the limit returns `403 Forbidden`.

### Header format

Send the key on every request using the `x-api-key` header — this is the same header name across all three surfaces:

```
x-api-key: <your-api-key>
```

`Authorization: Bearer <your-api-key>` is also accepted as an alternative on all three surfaces (useful for tools that only let you configure a bearer token, e.g. Codex CLI). Do not send both headers with different values — `x-api-key` wins if both are present.

```
Authorization: Bearer <your-api-key>
```

**Anthropic surface only** — these additional (non-auth) headers are forwarded to the upstream provider when present:

| Header              | Purpose                        |
| ------------------- | ------------------------------ |
| `anthropic-version` | API version, e.g. `2023-06-01` |
| `anthropic-beta`    | Beta feature flags             |

### When does a request get a 401?

| Situation                                         | Response                                   |
| ------------------------------------------------- | ------------------------------------------ |
| No valid auth credentials provided                | `401`                                      |
| Key doesn't exist, was revoked, or is disabled    | `401` (API key validation failure)         |
| Key is valid, but the account balance is depleted | This is **not** a 401 — see Errors (`403`) |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.avis.xyz/api-reference/introduction/authentication.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
