API Authentication
Learn how to authenticate your requests to the AltTextAI API.
API Keys
All requests to the AltTextAI API must include an API key. Your API key carries many privileges, so be sure to keep it secure. Don't share your API key in publicly accessible areas such as GitHub, client-side code, or blog posts.
Never share your API keys and always use environment variables to store them in your applications.
Getting Your API Key
- Log in to your AltTextAI account
- Navigate to the API Keys section in your dashboard
- Click "Generate New API Key"
- Give your API key a name (e.g., "Production API Key")
- Copy and securely store your API key
Using Your API Key
Authentication is performed via the HTTP Authorization header with a Bearer token:
Authorization: Bearer YOUR_API_KEY
Example Request
curl -X POST https://autoalt.app/api/v1/generate \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"image": "base64_encoded_image_data"}'
API Key Best Practices
- Store API keys in environment variables or secure configuration files
- Never commit API keys to version control
- Rotate API keys periodically for enhanced security
- Use different API keys for development and production environments
- Restrict API key access to only the necessary IP addresses when possible
Verifying Your API Key
You can verify your API key is working correctly by making a request to the verify endpoint:
curl -X POST https://autoalt.app/api/v1/verify-api-key \
-H "Authorization: Bearer YOUR_API_KEY"
Successful response:
{
"valid": true,
"user_id": "your_user_id",
"credits_remaining": 100
}
Rate Limits and Credits
API requests are limited by your available credits. Each image processing request consumes 1 credit from your account. You can check your remaining credits using the credits endpoint:
curl https://autoalt.app/api/v1/credits \
-H "Authorization: Bearer YOUR_API_KEY"
Response:
{
"credits": 100,
"user_id": "your_user_id"
}
Next Steps
Now that you understand how to authenticate your requests, learn about our available endpoints: