Authentication
Learn how to authenticate your API requests
Authentication
All API requests require authentication using a Bearer token. Your API key identifies your account and determines your rate limits and permissions.
Getting Your API Key
- Sign up for a Speechgen account
- Navigate to your Dashboard
- Click on "API Keys" in the sidebar
- Click "Generate New Key"
- Copy and securely store your API key
Security Warning: Never expose your API key in client-side code or public repositories. Always use environment variables or secure key management systems.
Using Your API Key
Include your API key in the Authorization header of every request:
Authorization: Bearer YOUR_API_KEYExample Request
curl -X GET https://api.speechgen.com/v1/voices \
-H "Authorization: Bearer sk_live_abc123xyz..."API Key Types
| Type | Prefix | Use Case |
|---|---|---|
| Live | sk_live_ | Production applications |
| Test | sk_test_ | Development and testing |
Test keys have reduced rate limits but don't count against your monthly usage quota.
Error Responses
Invalid API Key
{
"error": {
"code": "invalid_api_key",
"message": "The API key provided is invalid or has been revoked."
}
}Missing API Key
{
"error": {
"code": "missing_api_key",
"message": "No API key was provided. Include your key in the Authorization header."
}
}Best Practices
- Rotate keys regularly: Generate new keys periodically and revoke old ones
- Use environment variables: Store keys in
SPEECHGEN_API_KEYenvironment variable - Monitor usage: Check your dashboard for unusual activity
- Set up alerts: Configure notifications for rate limit warnings
# Store in environment variable
export SPEECHGEN_API_KEY="sk_live_your_key_here"// Access in Node.js
const apiKey = process.env.SPEECHGEN_API_KEY;