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
- Log in to your dashboard
- Navigate to Settings > API Keys
- Click Create New API Key
- 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:
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
Never share your API key or commit it to version control. Treat it like a password.
- 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:
- Go to Settings > API Keys
- Find the key in the list
- 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
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
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
$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
{
"error": "Invalid API key",
"statusCode": 401
}
Missing API Key
{
"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.