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

# Authentication

> How to authenticate with the Auriko API

All API requests require authentication using a Bearer token.

## API Keys

API keys are prefixed with `ak_` and can be created in your [dashboard](https://auriko.ai/dashboard?tab=api-keys).

<Warning>
  Keep your API key secret. Do not share it or commit it to version control.
</Warning>

## Use your API key

Include your API key in the `Authorization` header:

```bash theme={null}
curl https://api.auriko.ai/v1/chat/completions \
  -H "Authorization: Bearer $AURIKO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "gpt-4o", "messages": [{"role": "user", "content": "Hello"}]}'
```

## SDK Authentication

<CodeGroup>
  ```python Python Auriko theme={null}
  import os
  from auriko import Client

  # Option 1: Pass via environment variable (recommended)
  client = Client(
      api_key=os.environ["AURIKO_API_KEY"],
      base_url="https://api.auriko.ai/v1"
  )

  # Option 2: Auto-detect from AURIKO_API_KEY env var
  client = Client(base_url="https://api.auriko.ai/v1")
  ```

  ```typescript TypeScript Auriko theme={null}
  import { Client } from "@auriko/sdk";

  // Option 1: Pass via environment variable (recommended)
  const client = new Client({
      apiKey: process.env.AURIKO_API_KEY,
      baseUrl: "https://api.auriko.ai/v1",
  });

  // Option 2: Auto-detect from AURIKO_API_KEY env var
  const client = new Client({
      baseUrl: "https://api.auriko.ai/v1",
  });
  ```
</CodeGroup>

## Environment Variables

Set your API key as an environment variable for security:

```bash theme={null}
export AURIKO_API_KEY=ak_your_api_key_here
```

Then use the SDK without passing the key directly:

<CodeGroup>
  ```python Python OpenAI theme={null}
  import os
  from openai import OpenAI

  client = OpenAI(
      api_key=os.environ["AURIKO_API_KEY"],
      base_url="https://api.auriko.ai/v1",
  )
  ```

  ```typescript TypeScript OpenAI theme={null}
  import OpenAI from "openai";

  const client = new OpenAI({
      apiKey: process.env.AURIKO_API_KEY,
      baseURL: "https://api.auriko.ai/v1",
  });
  ```

  ```python Python Auriko theme={null}
  from auriko import Client

  client = Client(base_url="https://api.auriko.ai/v1")
  ```

  ```typescript TypeScript Auriko theme={null}
  import { Client } from "@auriko/sdk";

  const client = new Client({ baseUrl: "https://api.auriko.ai/v1" });
  ```
</CodeGroup>

## Error Responses

| Status | Code              | Description                   |
| ------ | ----------------- | ----------------------------- |
| 401    | `invalid_api_key` | API key is invalid or missing |

```json 401 Response theme={null}
{
  "error": {
    "message": "API key is invalid.",
    "type": "authentication_error",
    "param": null,
    "code": "invalid_api_key",
    "doc_url": "https://docs.auriko.ai/errors/invalid_api_key"
  }
}
```

## Authentication summary

| Category                                                                                            | Auth method      | Token prefix |
| --------------------------------------------------------------------------------------------------- | ---------------- | ------------ |
| API key endpoints (`/v1/chat/completions`, `/v1/responses`, `/v1/messages`, `/v1/models`, `/v1/me`) | API key          | `ak_`        |
| Workspace management (`/v1/workspaces/{workspace_id}/*`)                                            | API key + scopes | `ak_`        |
| Public catalog (`/v1/registry/*`, `/v1/directory/*`, `/v1/byok/providers*`)                         | None required    | —            |
