> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs-dev.ltx.io/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs-dev.ltx.io/_mcp/server.

# Authentication

> Understand how to securely authenticate with the LTX API. Follow step-by-step instructions for generating and managing API keys safely.

All LTX API requests require authentication using API keys. API keys are associated with your account and provide access to the API endpoints.

## Getting Your API Key

Sign in to the Developer Console to create your API key.

Create API Key

## Using Your API Key

Include your API key in the `Authorization` header of every request using the Bearer token format:

```bash
Authorization: Bearer YOUR_API_KEY
```

## Example Request

#### cURL

```bash
curl -X POST https://api.ltx.io/v2/text-to-video \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "A majestic eagle soaring through clouds",
    "model": "ltx-2-5-pro",
    "duration": 8,
    "resolution": "1920x1080"
  }'
```

#### Python

```python
import requests

headers = {
    "Authorization": "Bearer YOUR_API_KEY",
    "Content-Type": "application/json"
}

response = requests.post(
    "https://api.ltx.io/v2/text-to-video",
    headers=headers,
    json={
        "prompt": "A majestic eagle soaring through clouds",
        "model": "ltx-2-5-pro",
        "duration": 8,
        "resolution": "1920x1080"
    }
)
```

The response contains a job ID that you use to check the status and download the video. See [Async Jobs](/async-jobs).

## Security Best Practices

> **Warning**
>
> **Keep your API key secure:**
>
> * Never commit API keys to version control
> * Don't expose keys in client-side code
> * Use environment variables to store keys
> * Rotate keys periodically

### Environment Variables

Store your API key in environment variables:

**Bash:**

```bash
export LTXV_API_KEY="your_api_key_here"
```

**Python:**

```python
import os

api_key = os.environ.get("LTXV_API_KEY")
```

**Node.js:**

```javascript
const apiKey = process.env.LTXV_API_KEY;
```

## Authentication Errors

If authentication fails, you'll receive a `401 Unauthorized` response:

```json
{
  "type": "error",
  "error": {
    "type": "authentication_error",
    "message": "Invalid API key"
  }
}
```

Common authentication issues:

| Error                        | Cause                       | Solution                         |
| ---------------------------- | --------------------------- | -------------------------------- |
| Missing authorization header | No `Authorization` header   | Add the header to your request   |
| Invalid API key              | Key is incorrect or expired | Verify your API key              |
| Malformed header             | Incorrect format            | Use `Bearer YOUR_API_KEY` format |

## Rate Limits

API keys are subject to rate limits based on your plan. If you exceed your rate limit, you'll receive a `429 Too Many Requests` response.

Contact our team to discuss rate limit increases for your use case.