API v1.0 is now available! Check out the new voice cloning features.
SpeechgenSpeechgen

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

  1. Sign up for a Speechgen account
  2. Navigate to your Dashboard
  3. Click on "API Keys" in the sidebar
  4. Click "Generate New Key"
  5. 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_KEY

Example Request

curl -X GET https://api.speechgen.com/v1/voices \
  -H "Authorization: Bearer sk_live_abc123xyz..."

API Key Types

TypePrefixUse Case
Livesk_live_Production applications
Testsk_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

  1. Rotate keys regularly: Generate new keys periodically and revoke old ones
  2. Use environment variables: Store keys in SPEECHGEN_API_KEY environment variable
  3. Monitor usage: Check your dashboard for unusual activity
  4. 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;

Frequently Asked Questions