Get an API key
Create keys from the API Keys page in your workspace: click Create API Key, name it, and copy the key (formatbai-xxxx). New to Boson AI? Follow Set up your account for the full checklist — account, key, and free trial credit.
Building a browser or mobile Realtime client? Your trusted server must exchange its long-lived key for a short-lived client secret.
Store keys safely
Read the key from an environment variable, secret manager, or deployment config. Recommended patterns:-
Quick local test: set the key in your shell for the current session:
-
Local development: use a
.envfile loaded bydirenv,dotenv, or your shell. Add.envto.gitignore. - Servers: inject through your platform’s secret store (AWS Secrets Manager, GCP Secret Manager, Vercel env vars, Fly secrets, Kubernetes Secrets).
- CI: store as a masked CI secret. Avoid printing the value in build logs.
Sending a server-side request
From a trusted server, pass the key in theAuthorization header on every API request. Browser and mobile Realtime clients must use a short-lived client secret instead.
Common errors
The API returns401 Unauthorized with error.type: "authentication_error" and error.code: "invalid_api_key" when there is a problem with your API key — missing, malformed, or revoked. Check the Authorization: Bearer header and the key in your workspace.
A 429 with insufficient_quota is a billing problem, not a key problem — the key is fine but the account has no available balance. Claim your free trial credit or add credits in workspace billing. See Common error types for the full reference.