Getting Started
Authentication & API Keys
All requests authenticate with a Bearer token. 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. The
/health endpoint does not require authentication.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. |
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.
Authentication errors
python
from shunyalabs.exceptions import AuthenticationError
try:
result = await client.asr.transcribe("audio.wav", config=config)
except AuthenticationError:
print("Invalid or missing API key — check SHUNYALABS_API_KEY")