Authentication
Authenticate API requests using your Cleanvoice API key.
All requests to the Cleanvoice API must be authenticated with an API key passed as the X-API-Key request header.
Getting your API key
- Log in to the Cleanvoice dashboard
- Navigate to Settings → API Keys
- Click Generate new key and copy it immediately — it is only shown once
Keep your API key secret. Do not expose it in client-side code, public repositories, or logs.
Using your API key
Pass your key in the X-API-Key header on every request:
curl https://api.cleanvoice.ai/v1/account \
-H "X-API-Key: YOUR_API_KEY"from cleanvoice import Cleanvoice
# Pass directly
client = Cleanvoice(api_key="YOUR_API_KEY")
# Or read from environment variable CLEANVOICE_API_KEY
client = Cleanvoice.from_env()import { Cleanvoice } from '@cleanvoice/cleanvoice-sdk';
const client = new Cleanvoice({ apiKey: 'YOUR_API_KEY' });Verify authentication
You can verify your key is working with the account check endpoint. The auth check currently lives on /v1/account, even though editing requests use /v2/...:
curl https://api.cleanvoice.ai/v1/account \
-H "X-API-Key: YOUR_API_KEY"account = client.check_auth()
print(account["credit"]["total"])
print(account["meta"])const account = await client.checkAuth();
console.log(account.credit.total);The Python SDK returns the current /v1/account payload, including credit and meta. The JavaScript SDK currently exposes the public credit balances only.
Using environment variables
Store your key in an environment variable to avoid hardcoding it:
# .env
CLEANVOICE_API_KEY=your_api_key_here# Python — reads CLEANVOICE_API_KEY automatically
client = Cleanvoice.from_env()Error responses
| Status | Meaning |
|---|---|
401 Unauthorized | Missing or invalid API key |