Learn how to securely authenticate with the Freddy API using API keys and manage your authentication workflow.
Freddy uses API key authentication for all requests. Your API key identifies your account and provides access to your resources.
- Log in to the Freddy Hub
- Navigate to Settings → API Keys
- Click "Create New API Key"
- Name your key (e.g., "Production App", "Development")
- Copy the key immediately (it won't be shown again)
All Freddy API keys follow this format:
ak_1234567890abcdef1234567890abcdef12345678- Prefix:
ak_(identifies it as an API key) - Length: 42 characters total
- Characters: Alphanumeric (a-z, A-Z, 0-9)
Include your API key in the api-key header:
curl -X GET "https://api.freddy.ai/v2/models" \
-H "api-key: ak_your_api_key_here" \
-H "Content-Type: application/json"import requests
# Set up authentication
api_key = "ak_your_api_key_here"
headers = {
"api-key": api_key,
"Content-Type": "application/json"
}
# Make authenticated request
response = requests.get(
"https://api.freddy.ai/v2/models",
headers=headers
)
if response.status_code == 200:
print("Success:", response.json())
else:
print("Error:", response.status_code, response.text)const apiKey = "ak_your_api_key_here";
const headers = {
"api-key": apiKey,
"Content-Type": "application/json"
};
fetch("https://api.freddy.ai/v2/models", {
method: "GET",
headers: headers
})
.then(response => {
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
return response.json();
})
.then(data => console.log("Success:", data))
.catch(error => console.error("Error:", error));<?php
$api_key = "ak_your_api_key_here";
$url = "https://api.freddy.ai/v2/models";
$headers = [
"api-key: " . $api_key,
"Content-Type: application/json"
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($http_code == 200) {
$data = json_decode($response, true);
print_r($data);
} else {
echo "Error: " . $http_code . " - " . $response;
}
?>✅ DO:
- Store API keys in environment variables
- Use secure key management systems
- Rotate keys regularly
- Use different keys for different environments
❌ DON'T:
- Commit API keys to version control
- Share keys in chat or email
- Use production keys in development
- Hardcode keys in your application
Store your API key securely:
# .env file
FREDDY_API_KEY=ak_your_api_key_here# Python
import os
api_key = os.getenv('FREDDY_API_KEY')// Node.js
const apiKey = process.env.FREDDY_API_KEY;Regularly rotate your API keys:
- Create a new key in the Hub
- Update your applications to use the new key
- Test thoroughly in staging environment
- Deploy to production
- Delete the old key after confirming everything works
{
"detail": "Invalid API key",
"status_code": 401,
"error_type": "AuthenticationError"
}Causes:
- Missing API key header
- Invalid or expired API key
- Malformed API key
{
"detail": "Insufficient permissions",
"status_code": 403,
"error_type": "PermissionError"
}Causes:
- API key doesn't have required permissions
- Account limitations or restrictions
- Resource access denied
import requests
def make_authenticated_request(endpoint, api_key):
headers = {"api-key": api_key}
try:
response = requests.get(f"https://api.freddy.ai/v2/{endpoint}", headers=headers)
if response.status_code == 401:
print("Authentication failed. Check your API key.")
return None
elif response.status_code == 403:
print("Permission denied. Check your account permissions.")
return None
elif response.status_code == 200:
return response.json()
else:
print(f"Unexpected error: {response.status_code}")
return None
except requests.exceptions.RequestException as e:
print(f"Request failed: {e}")
return NoneAPI keys are subject to rate limits based on your plan:
- Standard: 100 requests/minute
- Premium: 1,000 requests/minute
- Enterprise: Custom limits
Rate limit headers are included in responses:
X-RateLimit-Limit: 100
X-RateLimit-Remaining: 95
X-RateLimit-Reset: 1640995200Track your API usage in the Freddy Hub:
- Go to Settings → API Keys
- View Usage Statistics for each key
- Monitor Rate Limit Status
- Set up Usage Alerts
- Check the format - Should start with
ak_ - Verify in Hub - Ensure key exists and is active
- Check headers - Use
api-keyheader name - Test with cURL - Isolate the issue
- 📖 Getting Started - Basic setup guide
- 🔌 API Reference - Detailed endpoint docs
- 🌐 Hub - Manage your keys
- 📧 Support - Contact our team
Secure authentication is the foundation of a great API experience! 🔐