bitHuman uses a single shared credential per account that authenticates every SDK and the REST API. There are two equivalent ways to refer to it depending on which SDK you’re using:Documentation Index
Fetch the complete documentation index at: https://docs.bithuman.ai/llms.txt
Use this file to discover all available pages before exploring further.
BITHUMAN_API_SECRET— used by Python SDK, REST API, and LiveKit plugin (everything server-side).BITHUMAN_API_KEY— used by the Swift SDK on Apple Silicon. Same value, different env var name to match Apple-platform conventions.
1. Get a key
Sign in
Sign in at bithuman.ai (free tier — no credit card).
Open Developer → API Keys
Create a key
Click Create new key, name it (e.g. “production-mac”), and copy the value. You won’t be able to view it again — store it somewhere durable.
2. Set it for your SDK
Python SDK
api_secret parameter:
LiveKit Plugin (livekit-plugins-bithuman)
Same env var as the Python SDK:
REST API
Pass theapi-secret header on every request:
Swift SDK (bitHumanKit)
Either env var or config:
BITHUMAN_API_KEY via Product → Scheme → Edit Scheme → Run → Arguments → Environment Variables. Never hardcode the key in source.
For production:
- DMG distribution — bundle the key into your
.app’s Info.plist via a build script that runssedon a placeholder. Source stays clean; only the compiled artifact has the key. See the Mac reference app’sbuild-mac-app.shfor the canonical pattern. - App Store — fetch from your own backend via Keychain on first launch. Don’t bundle.
bithuman-cli (Homebrew)
3. Audio-only Swift mode is unmetered
If you only want on-device voice chat (no lip-synced avatar), skip the API key entirely:How the auth flow works
- Your code provides the API secret to the SDK / REST request.
- The SDK exchanges it for a short-lived runtime token at
https://api.bithuman.ai/v1/runtime-tokens/request. - That token authenticates the actual avatar engine (heartbeat + frame production).
- Tokens auto-renew every minute via the heartbeat.
- Bad keys fail at step 2 — fast — before any user-visible work.
BITHUMAN_API_SECRET itself is never sent to the avatar process or any third party. It only ever travels to api.bithuman.ai over TLS to mint tokens.
Common errors
| Error | Cause | Fix |
|---|---|---|
Authentication failed (Python) | Wrong / missing BITHUMAN_API_SECRET | Verify with the curl /v1/validate recipe above. |
VoiceChatError.missingAPIKey (Swift) | Avatar mode without apiKey set | Set config.apiKey or export BITHUMAN_API_KEY. |
VoiceChatError.authenticationFailed (Swift) | Avatar mode with bad key | Confirm the key is valid; check it hasn’t been rotated. |
| 401 from REST API | Missing api-secret header | Add header on every request. |
| Heartbeat goes silent after 5 minutes | Network dropped on-device | Reconnect; the SDK pauses the avatar after the 5-min grace window and resumes when heartbeats succeed. |
Rotating keys
Keys can be rotated from the Developer dashboard. Rotation invalidates the old key immediately. Live sessions using the old key will fail their next heartbeat (within ~60 s) and pause; restart with the new key to resume. There’s no overlap window — rotate during a maintenance window if you have running production sessions.Next
- Pricing & credits — what each authenticated minute costs
- Quickstart — Python SDK in 5 minutes
- Swift SDK quickstart — on-device in 10 minutes
- REST API overview — every endpoint with examples
