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

  1. Sign in to the ShunyaLabs dashboard.
  2. Navigate to API Keys.
  3. Click Create New Key.
  4. 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

VariableDescription
SHUNYALABS_API_KEYAPI key for authentication.
SHUNYALABS_TTS_URLOverride the TTS batch API base URL.
SHUNYALABS_TTS_WS_URLOverride the TTS streaming WebSocket URL.

Security best practices

  • Never hardcode API keys in source code.
  • Use .env files locally and a secrets manager (AWS Secrets Manager, GCP Secret Manager) in production.
  • Add .env to .gitignore to prevent accidental commits.
  • Rotate keys immediately if compromised — generate a new key from the dashboard.