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

# Authentication

> Authenticate your API requests with a ShuttleAI API key.

Every request to the ShuttleAI API requires a valid API key. Keys are prefixed with `shuttle-` and sent as a Bearer token in the `Authorization` header.

## Getting your API key

1. Log in to the [ShuttleAI Dashboard](https://shuttleai.com/dashboard)
2. Navigate to [API Keys](https://shuttleai.com/keys)
3. Copy your master key, or create a sub-key for specific use cases

<Warning>
  Never share your API key or commit it to version control. Treat it like a password.
</Warning>

## Using your key

Include your API key in the `Authorization` header of every request:

```bash theme={null}
Authorization: Bearer shuttle-xxxxxxxxxxxxx
```

### With the OpenAI SDK

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

  client = OpenAI(
      api_key="shuttle-xxx",
      base_url="https://api.shuttleai.com/v1"
  )
  ```

  ```javascript Node.js theme={null}
  import OpenAI from "openai";

  const client = new OpenAI({
    apiKey: "shuttle-xxx",
    baseURL: "https://api.shuttleai.com/v1",
  });
  ```
</CodeGroup>

### With cURL

```bash theme={null}
curl https://api.shuttleai.com/v1/chat/completions \
  -H "Authorization: Bearer shuttle-xxx" \
  -H "Content-Type: application/json" \
  -d '{"model": "shuttleai/auto", "messages": [{"role": "user", "content": "Hi"}]}'
```

## Environment variables

Store your key in an environment variable to keep it out of your code:

<CodeGroup>
  ```bash Linux / macOS theme={null}
  export SHUTTLEAI_API_KEY="shuttle-xxx"
  ```

  ```powershell Windows (PowerShell) theme={null}
  $env:SHUTTLEAI_API_KEY = "shuttle-xxx"
  ```

  ```cmd Windows (CMD) theme={null}
  set SHUTTLEAI_API_KEY=shuttle-xxx
  ```
</CodeGroup>

Then reference it in your code:

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

  client = OpenAI(
      api_key=os.environ["SHUTTLEAI_API_KEY"],
      base_url="https://api.shuttleai.com/v1"
  )
  ```

  ```javascript Node.js theme={null}
  import OpenAI from "openai";

  const client = new OpenAI({
    apiKey: process.env.SHUTTLEAI_API_KEY,
    baseURL: "https://api.shuttleai.com/v1",
  });
  ```
</CodeGroup>

## Sub-keys

Sub-keys let you create scoped API keys for different applications or team members. You can create up to **10 sub-keys** per account.

Manage sub-keys from the [API Keys page](https://shuttleai.com/keys) in the dashboard. Each sub-key can be individually renamed or revoked without affecting your master key.

<Info>
  See [API Keys](/dashboard/api-keys) for a full guide on managing your keys.
</Info>
