Getting Started
Authentication & API Keys
All requests use Bearer token authentication. Every HTTP request and WebSocket handshake must include an Authorization header.
How it works
Every API request must include an Authorization header:
terminal
Authorization: Bearer <your-api-key>This applies to both HTTP batch requests and WebSocket streaming connections.
Getting your API key
- Sign in to the ShunyaLabs dashboard.
- Navigate to API Keys.
- Click Create New Key.
- Copy and store the key securely — it will not be shown again.
Configuring the SDK
Option 1 — Environment variable (recommended)
terminal
export SHUNYALABS_API_KEY="your-api-key"python
from shunyalabs import AsyncShunyaClient
# SDK reads SHUNYALABS_API_KEY automatically
client = AsyncShunyaClient()Option 2 — Pass directly to the client
python
client = AsyncShunyaClient(api_key="your-api-key")Environment variables
| Variable | Description |
|---|---|
| SHUNYALABS_API_KEY | API key for authentication. |
| SHUNYALABS_TTS_URL | Override the TTS batch API base URL. |
| SHUNYALABS_TTS_WS_URL | Override the TTS streaming WebSocket URL. |
Security best practices
- Never hardcode API keys in source code.
- Use
.envfiles locally and a secrets manager (AWS Secrets Manager, GCP Secret Manager) in production. - Add
.envto.gitignoreto prevent accidental commits. - Rotate keys immediately if compromised — generate a new key from the dashboard.