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

# API Keys

> Create and manage your AudioPod AI API keys

## Create Your First Key

<Tabs>
  <Tab title="CLI (Recommended)">
    Already have an API key? Create more via cURL:

    ```bash theme={null}
    curl -X POST "https://api.audiopod.ai/api/v1/auth/api-keys" \
      -H "X-API-Key: $AUDIOPOD_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{"name": "production-key", "scopes": ["*"]}'
    ```

    **First time?** Follow the [Quick Start](/quickstart) to register and get your first key.
  </Tab>

  <Tab title="Dashboard">
    1. Go to [API Keys](https://www.audiopod.ai/dashboard/account/api-keys)
    2. Click **Create New API Key**
    3. Copy and save your key immediately

    <Warning>Keys are only shown once. Save it securely!</Warning>
  </Tab>
</Tabs>

***

## Using Your API Key

### Environment Variable (Recommended)

```bash theme={null}
export AUDIOPOD_API_KEY="ap_your_key_here"
```

### SDK Usage

<Tabs>
  <Tab title="Python">
    ```python theme={null}
    from audiopod import AudioPod

    # Auto-reads from AUDIOPOD_API_KEY env var
    client = AudioPod()

    # Or pass explicitly
    client = AudioPod(api_key="ap_your_key_here")
    ```
  </Tab>

  <Tab title="Node.js">
    ```typescript theme={null}
    import AudioPod from 'audiopod';

    // Auto-reads from AUDIOPOD_API_KEY env var
    const client = new AudioPod();

    // Or pass explicitly
    const client = new AudioPod({ apiKey: 'ap_your_key_here' });
    ```
  </Tab>

  <Tab title="cURL">
    ```bash theme={null}
    curl -X POST "https://api.audiopod.ai/api/v1/stem-extraction/api/extract" \
      -H "X-API-Key: $AUDIOPOD_API_KEY" \
      -F "url=https://youtube.com/watch?v=VIDEO_ID" \
      -F "mode=six"
    ```
  </Tab>
</Tabs>

***

## Manage Keys via API

```bash theme={null}
# List all keys
curl -s "https://api.audiopod.ai/api/v1/auth/api-keys" \
  -H "X-API-Key: $AUDIOPOD_API_KEY" | jq .

# Create new key
curl -X POST "https://api.audiopod.ai/api/v1/auth/api-keys" \
  -H "X-API-Key: $AUDIOPOD_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "staging-key",
    "scopes": ["*"],
    "expires_in_days": 90
  }'

# Revoke a key
curl -X DELETE "https://api.audiopod.ai/api/v1/auth/api-keys/KEY_ID" \
  -H "X-API-Key: $AUDIOPOD_API_KEY"
```

***

## Best Practices

<AccordionGroup>
  <Accordion title="Use separate keys per environment">
    ```bash theme={null}
    # Development
    AUDIOPOD_API_KEY_DEV=ap_dev_...

    # Production
    AUDIOPOD_API_KEY_PROD=ap_prod_...
    ```
  </Accordion>

  <Accordion title="Never expose keys in client-side code">
    API keys should only be used server-side. Create a backend proxy if you need client-side access.
  </Accordion>

  <Accordion title="Rotate keys regularly">
    Create a new key → Update your apps → Revoke the old key.
  </Accordion>

  <Accordion title="Use expiring keys for temporary access">
    ```bash theme={null}
    curl -X POST "https://api.audiopod.ai/api/v1/auth/api-keys" \
      -H "X-API-Key: $AUDIOPOD_API_KEY" \
      -d '{"name": "temp-key", "expires_in_days": 7}'
    ```
  </Accordion>
</AccordionGroup>

***

## Troubleshooting

| Error              | Cause                  | Fix                      |
| ------------------ | ---------------------- | ------------------------ |
| `401 Unauthorized` | Invalid or missing key | Check `X-API-Key` header |
| `403 Forbidden`    | Key revoked or expired | Create a new key         |

Test your key:

```bash theme={null}
curl -s "https://api.audiopod.ai/api/v1/api-wallet/balance" \
  -H "X-API-Key: $AUDIOPOD_API_KEY" | jq .balance_usd
```

***

## Next Steps

<Columns cols={2}>
  <Card title="Add Funds" icon="wallet" href="/account/api-wallet">
    Top up your wallet to start making API calls
  </Card>

  <Card title="Quick Start" icon="rocket" href="/quickstart">
    Make your first API call
  </Card>
</Columns>
