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

  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.

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.

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")