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

# API Keys

> Managing your API keys for authentication

## Overview

The Distylia API uses API key authentication. Each request must include your API key in the `x-api-key` header.

## Getting Your API Key

1. Log in to your dashboard
2. Navigate to **Settings** > **API Keys**
3. Click **Create New API Key**
4. Copy and save your API key securely (it won't be shown again)

## Using Your API Key

Include the API key in the `x-api-key` header of every request:

```bash theme={null}
curl -X POST https://api.distylia.com/api/v1/process-text-async \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "text": "Your content here",
    "format": "image"
  }'
```

## Security Best Practices

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

* Store API keys in environment variables
* Use different keys for development and production
* Rotate keys regularly
* Revoke compromised keys immediately

## Managing API Keys

### Create New Key

Generate additional API keys for different applications or environments.

### Revoke Key

If a key is compromised or no longer needed:

1. Go to **Settings** > **API Keys**
2. Find the key in the list
3. Click **Revoke**

Revoked keys are immediately invalidated and cannot be used.

### Key Limits

* Maximum 10 active API keys per account
* Keys do not expire but can be manually revoked
* Each key has the same permissions as your account

## Example Usage in Code

### JavaScript/Node.js

```javascript theme={null}
const apiKey = process.env.API_KEY;

const response = await fetch('https://api.distylia.com/api/v1/process-text-async', {
  method: 'POST',
  headers: {
    'x-api-key': apiKey,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    text: 'Your content here',
    format: 'image',
  }),
});

const result = await response.json();
```

### Python

```python theme={null}
import os
import requests

api_key = os.environ.get('API_KEY')

response = requests.post(
    'https://api.distylia.com/api/v1/process-text-async',
    headers={
        'x-api-key': api_key,
        'Content-Type': 'application/json',
    },
    json={
        'text': 'Your content here',
        'format': 'image',
    }
)

result = response.json()
```

### PHP

```php theme={null}
<?php
$apiKey = getenv('API_KEY');

$ch = curl_init('https://api.distylia.com/api/v1/process-text-async');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'x-api-key: ' . $apiKey,
    'Content-Type: application/json',
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
    'text' => 'Your content here',
    'format' => 'image',
]));

$response = curl_exec($ch);
$result = json_decode($response, true);
curl_close($ch);
?>
```

## Error Responses

### Invalid API Key

```json theme={null}
{
  "error": "Invalid API key",
  "statusCode": 401
}
```

### Missing API Key

```json theme={null}
{
  "error": "API key is required",
  "statusCode": 401
}
```

## Rate Limits

API keys are subject to rate limits based on your account plan:

| Plan       | Requests/Hour | Concurrent Jobs |
| ---------- | ------------- | --------------- |
| Free       | 10            | 1               |
| Pro        | 100           | 5               |
| Enterprise | Custom        | Custom          |

Exceeding rate limits will result in `429 Too Many Requests` responses.
