# Authentication

> Authenticate LLMoxy API calls using tokens and compatible request headers.

LLMoxy Relay endpoints require a user API Token. Tokens can be created in **Console -> Tokens**, and usually start with `sk-`.

## Bearer Token

The standard header is recommended:

```http
Authorization: Bearer <LLMOXY_API_KEY>
```

Example:

```bash
curl https://llmoxy.com/v1/models \
  -H "Authorization: Bearer <LLMOXY_API_KEY>"
```

## LLMOXY-API-KEY Header

When a request has no `Authorization`, LLMoxy also accepts:

```http
LLMOXY-API-KEY: <LLMOXY_API_KEY>
```

Prefer `Authorization: Bearer`. The custom header is mainly for integration scenarios where setting the standard auth header is inconvenient.

## Claude Compatible Requests

For `/v1/messages` and `/v1/models`, Anthropic-style clients can use:

```http
x-api-key: <LLMOXY_API_KEY>
anthropic-version: 2023-06-01
```

LLMoxy maps `x-api-key` to the same token authentication flow.

## Gemini Compatible Requests

For Gemini-compatible routes such as `/v1beta/models/{model}:generateContent`, LLMoxy accepts:

```http
x-goog-api-key: <LLMOXY_API_KEY>
```

It also supports `?key=<LLMOXY_API_KEY>` for Gemini client compatibility. For server-side integrations, use headers to avoid keys entering URLs or logs.

## Realtime WebSocket

Server-side WebSocket clients can use standard auth headers during the handshake. Browser-style OpenAI Realtime clients can pass the key via subprotocol:

```txt
realtime, openai-insecure-api-key.<LLMOXY_API_KEY>, openai-beta.realtime-v1
```

## Token Controls

Tokens may be restricted by remaining balance, expiration time, available models, groups, and IP allowlists. When a token expires, runs out of balance, is disabled, or the IP is not allowed, Relay returns an OpenAI-style error response.

This is the markdown version of https://en.llmoxy.com/docs/api-reference/authentication.
