Overview
AudioPod AI uses API key authentication for all requests. This guide covers how to obtain, use, and manage your API keys securely.
Getting Your API Key
1. Create an Account
First, sign up for an AudioPod AI account:
Sign Up for AudioPod AI Create your free account and get $5 in credits
2. Generate API Key
Log into the AudioPod AI account
Navigate to API Keys in the sidebar
Click Create New API Key
Give your key a descriptive name (e.g., “Production App”, “Development”)
Copy the generated key immediately (you won’t see it again)
Store your API key securely. It won’t be shown again after creation. If you
lose it, you’ll need to generate a new one.
Using Your API Key
Include your API key in the Authorization header of every request:
Authorization: Bearer your_api_key_here
SDK Authentication (Recommended)
The easiest way to authenticate is using our official SDKs:
Python
Node.js
Raw HTTP
cURL
import os
from audiopod import Client
# Method 1: Environment variable (recommended)
os.environ[ 'AUDIOPOD_API_KEY' ] = 'your_api_key_here'
client = Client() # Automatically uses AUDIOPOD_API_KEY
# Method 2: Direct initialization
client = Client( api_key = 'your_api_key_here' )
# Method 3: Using configuration
client = Client(
api_key = os.getenv( 'AUDIOPOD_API_KEY' ),
base_url = 'https://api.audiopod.ai' , # Optional: custom base URL
timeout = 30 , # Optional: request timeout
max_retries = 3 # Optional: retry attempts
)
# Test authentication
try :
user_info = client.get_user_info()
print ( f "Authenticated as: { user_info[ 'email' ] } " )
except Exception as e:
print ( f "Authentication failed: { e } " )
Environment Setup
Set up your environment for secure API key management:
# requirements.txt
audiopod - client >= 1.0 .0
python - dotenv >= 0.19 .0
# .env file (never commit this!)
AUDIOPOD_API_KEY = ak_live_your_actual_key_here
# main.py
import os
from dotenv import load_dotenv
from audiopod import Client
# Load environment variables
load_dotenv()
# Verify API key is loaded
api_key = os.getenv( 'AUDIOPOD_API_KEY' )
if not api_key:
raise ValueError ( "AUDIOPOD_API_KEY environment variable not set" )
# Initialize client
client = Client()
# Use the client
credits = client.credits.get_credit_balance()
print ( f "Available credits: { credits .balance } " )
API Key Management
Multiple API Keys
You can create multiple API keys for different purposes:
Development : For testing and development environments
Production : For your live application
Staging : For your staging/testing environment
Mobile App : Separate key for mobile applications
Programmatic API Key Management
You can manage API keys programmatically using the Auth API:
import requests
import os
# Use your existing API key to manage other keys
headers = {
"Authorization" : f "Bearer { os.getenv( 'AUDIOPOD_API_KEY' ) } "
}
# Create a new API key
create_response = requests.post(
"https://api.audiopod.ai/api/v1/auth/api-keys" ,
headers = headers,
json = {
"name" : "Production API Key" ,
"description" : "Key for production environment"
}
)
if create_response.status_code == 201 :
new_key = create_response.json()
print ( f "Created API key: { new_key[ 'key' ] } " )
print ( f "Key ID: { new_key[ 'id' ] } " )
# List all API keys
list_response = requests.get(
"https://api.audiopod.ai/api/v1/auth/api-keys" ,
headers = headers,
params = { "status" : "active" }
)
if list_response.status_code == 200 :
keys = list_response.json()
for key in keys:
print ( f "Key: { key[ 'name' ] } (ID: { key[ 'id' ] } ) - Status: { key[ 'status' ] } " )
# Revoke an API key
key_id = "key_id_to_revoke"
revoke_response = requests.delete(
f "https://api.audiopod.ai/api/v1/auth/api-keys/ { key_id } " ,
headers = headers
)
if revoke_response.status_code == 200 :
print ( f "API key { key_id } revoked successfully" )
Key Permissions
Currently, all API keys have full access to your account. We recommend:
Using separate keys for different environments
Rotating keys regularly
Revoking unused keys immediately
Dashboard Management
You can also manage API keys through the dashboard:
Go to the API Keys page
Find the key you want to revoke
Click Revoke next to the key
Confirm the action
Revoking an API key immediately stops all requests using that key. Make sure
to update your applications before revoking.
Security Best Practices
Environment Variables
Always store API keys in environment variables, never in your source code:
# .env file
AUDIOPOD_API_KEY = your_api_key_here
Server-Side Only
Never expose your API key in client-side code such as:
Frontend JavaScript
Mobile app source code
Public repositories
If you need client-side audio generation, create a backend endpoint that proxies requests to AudioPod AI.
HTTPS Only
Always use HTTPS when making requests to prevent API key interception.
Key Rotation
Regularly rotate your API keys:
Generate a new API key
Update your applications to use the new key
Test thoroughly
Revoke the old key
Rate Limiting
AudioPod AI implements rate limiting to ensure fair usage:
Free Plan : 100 requests per minute
Pro Plan : 1,000 requests per minute
Enterprise : Custom limits
Rate limit information is included in response headers:
X-RateLimit-Limit: 100
X-RateLimit-Remaining: 95
X-RateLimit-Reset: 1640995200
Error Handling
Common Authentication Errors
Cause : Missing or invalid API keySolutions :
Check that you’re including the Authorization header
Verify your API key is correct
Ensure the key hasn’t been revoked
{
"error" : {
"code" : "unauthorized" ,
"message" : "Invalid API key provided"
}
}
Cause : API key doesn’t have permission for this resourceSolutions :
Check if your account has access to this feature
Verify your subscription plan includes this endpoint
{
"error" : {
"code" : "forbidden" ,
"message" : "Your plan doesn't include access to this feature"
}
}
Cause : Rate limit exceededSolutions :
Implement exponential backoff
Reduce request frequency
Upgrade your plan for higher limits
{
"error" : {
"code" : "rate_limit_exceeded" ,
"message" : "Rate limit exceeded. Please try again later."
}
}
Handling Errors in Code
from audiopod import Client
from audiopod.exceptions import (
AuthenticationError,
RateLimitError,
APIError,
InsufficientCreditsError
)
import time
client = Client()
def safe_api_call_with_retry ( func , * args , ** kwargs ):
"""Helper function to handle API calls with retry logic"""
max_retries = 3
retry_delay = 1 # seconds
for attempt in range (max_retries):
try :
return func( * args, ** kwargs)
except AuthenticationError as e:
print ( f "Authentication error: { e } " )
# Don't retry authentication errors
raise
except RateLimitError as e:
print ( f "Rate limit exceeded: { e } " )
if attempt < max_retries - 1 :
retry_after = getattr (e, 'retry_after' , retry_delay)
print ( f "Waiting { retry_after } seconds before retry..." )
time.sleep(retry_after)
retry_delay *= 2 # Exponential backoff
else :
raise
except InsufficientCreditsError as e:
print ( f "Insufficient credits: { e } " )
print ( f "Credits needed: { e.credits_needed } " )
print ( f "Credits available: { e.credits_available } " )
# Don't retry credit errors
raise
except APIError as e:
print ( f "API error: { e } " )
if e.status_code >= 500 : # Server errors - retry
if attempt < max_retries - 1 :
print ( f "Server error, retrying in { retry_delay } seconds..." )
time.sleep(retry_delay)
retry_delay *= 2
else :
raise
else : # Client errors - don't retry
raise
except Exception as e:
print ( f "Unexpected error: { e } " )
raise
# Example usage
try :
# Generate speech with error handling
result = safe_api_call_with_retry(
client.voice.generate_speech,
voice_id = "aura" ,
text = "Hello, world!" ,
wait_for_completion = True
)
print ( f "Success: { result.output_url } " )
except Exception as e:
print ( f "Failed after all retries: { e } " )
Next Steps