> ## Documentation Index
> Fetch the complete documentation index at: https://docs.anyone.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Authenticate requests: Bearer, x-api-key, x-goog-api-key

> Anyone uses a single token for all endpoints. Pass it as a Bearer API key, x-api-key, or x-goog-api-key depending on the API format you are using.

Every request to Anyone must include an API key to identify your account and authorize access. You create tokens in the dashboard, and the same API key works across all endpoint formats — OpenAI, Anthropic Claude, and Google Gemini. The only difference is which header you use to send it.

## Get your API key

<Steps>
  <Step title="Open the dashboard">
    Navigate to Anyone in a browser, for example `https://anyone.ai`.
  </Step>

  <Step title="Go to API Keys">
    Click **API Keys** in the sidebar.
  </Step>

  <Step title="Create an API key">
    Click **Add API Key**, give it a name, configure any model restrictions or quota limits, then click **Submit**.
  </Step>

  <Step title="Copy the API key">
    Copy the API key value shown. Anyone only displays the full API key once, so save it somewhere secure.
  </Step>
</Steps>

## Authentication styles

Anyone supports three authentication styles to match the native format of each API family. All three use the same API key value — only the header name changes.

### OpenAI-compatible (most endpoints)

Pass your API key as a Bearer API key in the `Authorization` header. Use this style with all standard endpoints.

**Applies to:** `POST /v1/chat/completions`, `POST /v1/completions`, `POST /v1/responses`, `POST /v1/embeddings`, `POST /v1/audio/*`, `POST /v1/images/*`, `POST /v1/rerank`, `GET /v1/realtime`, `GET /v1/models`

<CodeGroup>
  ```bash cURL theme={null}
  curl https://api.anyone.ai/v1/chat/completions \
    -H "Authorization: Bearer YOUR_TOKEN" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "gpt-5.4",
      "messages": [{"role": "user", "content": "Hello"}]
    }'
  ```

  ```python Python theme={null}
  from openai import OpenAI

  client = OpenAI(
      api_key="YOUR_TOKEN",
      base_url="https://api.anyone.ai/v1"
  )

  response = client.chat.completions.create(
      model="gpt-5.4",
      messages=[{"role": "user", "content": "Hello"}]
  )
  ```

  ```javascript JavaScript theme={null}
  import OpenAI from "openai";

  const client = new OpenAI({
    apiKey: "YOUR_TOKEN",
    baseURL: "https://api.anyone.ai/v1",
  });

  const response = await client.chat.completions.create({
    model: "gpt-5.4",
    messages: [{ role: "user", content: "Hello" }],
  });
  ```
</CodeGroup>

### Anthropic Claude

Pass your API key in the `x-api-key` header and include the `anthropic-version` header. Anyone uses these headers to identify requests that should be handled in Claude Messages format.

**Applies to:** `POST /v1/messages`

<CodeGroup>
  ```bash cURL theme={null}
  curl https://api.anyone.ai/v1/messages \
    -H "x-api-key: YOUR_TOKEN" \
    -H "anthropic-version: 2023-06-01" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "claude-sonnet-4-6",
      "max_tokens": 1024,
      "messages": [{"role": "user", "content": "Hello"}]
    }'
  ```

  ```python Python theme={null}
  import anthropic

  client = anthropic.Anthropic(
      api_key="YOUR_TOKEN",
      base_url="https://api.anyone.ai",
  )

  message = client.messages.create(
      model="claude-sonnet-4-6",
      max_tokens=1024,
      messages=[{"role": "user", "content": "Hello"}],
  )
  ```

  ```javascript JavaScript theme={null}
  import Anthropic from "@anthropic-ai/sdk";

  const client = new Anthropic({
    apiKey: "YOUR_TOKEN",
    baseURL: "https://api.anyone.ai",
  });

  const message = await client.messages.create({
    model: "claude-sonnet-4-6",
    max_tokens: 1024,
    messages: [{ role: "user", content: "Hello" }],
  });
  ```
</CodeGroup>

### Google Gemini

Pass your API key in the `x-goog-api-key` header, or as a `key` query parameter. Both are equivalent.

**Applies to:** `POST /v1beta/models/{model}:generateContent`

<CodeGroup>
  ```bash cURL (header) theme={null}
  curl "https://api.anyone.ai/v1beta/models/gemini-3.1-pro-preview:generateContent" \
    -H "x-goog-api-key: YOUR_TOKEN" \
    -H "Content-Type: application/json" \
    -d '{
      "contents": [{"parts": [{"text": "Hello"}]}]
    }'
  ```

  ```bash cURL (query parameter) theme={null}
  curl "https://api.anyone.ai/v1beta/models/gemini-3.1-pro-preview:generateContent?key=YOUR_TOKEN" \
    -H "Content-Type: application/json" \
    -d '{
      "contents": [{"parts": [{"text": "Hello"}]}]
    }'
  ```

  ```python Python theme={null}
  import google.generativeai as genai

  genai.configure(
      api_key="YOUR_TOKEN",
      client_options={"api_endpoint": "https://api.anyone.ai"},
  )

  model = genai.GenerativeModel("gemini-3.1-pro-preview")
  response = model.generate_content("Hello")
  ```
</CodeGroup>

## Authentication errors

| Code               | Cause                                                           | Fix                                                                                   |
| ------------------ | --------------------------------------------------------------- | ------------------------------------------------------------------------------------- |
| `401 Unauthorized` | API key is missing, malformed, or has been deleted.             | Check that you are sending the correct header and that the API key value is complete. |
| `403 Forbidden`    | API key exists but does not have access to the requested model. | In the dashboard, edit the API key and check its allowed models list.                 |

## Security

<Warning>
  Never include your API key in client-side code, browser JavaScript, or public repositories. If an API key is exposed, delete it immediately in the dashboard and create a new one.
</Warning>

Store API keys in environment variables or a secrets manager, and pass them to your application at runtime. On the server side, treat your Anyone API key with the same care as any other API credential.
