Get started
Authentication
Every endpoint except /v1/status, /v1/audio/voices and /v1/openapi.json needs an API key, sent as a Bearer token.
#Send the key
Authorization: Bearer ay_live_<kid>_<secret>curl https://api.ana-yurt.dev/v1/translit \
-H "Authorization: Bearer $AY_API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "Selâm"}'A key in the query string (?api_key= or ?key=) is refused with 400 key_in_query, even when the header is also present, so keys do not end up in proxy logs and browser history.
#Key format
| Part | Example | Meaning |
|---|---|---|
ay_live_ | ay_live_ | Prefix of a live key. The dashboard issues live keys only. |
kid | 10 characters, a-z and 2-7 | Public key ID. It is shown in the dashboard and is safe to log. |
secret | About 43 characters, base62 | The secret. It is shown once, when the key is created or rolled. |
We store only a keyed hash of the secret, so a lost key cannot be shown again: roll it or create a new one.
#Scopes
A scope allows a key to call an endpoint. Keys from the dashboard carry all three.
| Scope | Endpoint |
|---|---|
translit | POST /v1/translit |
asr | POST /v1/audio/transcriptions |
tts | POST /v1/audio/speech |
#Managing keys
- Create in the dashboard. Each plan allows a number of active keys: Free 2, Pro 5, Business 20. Revoked keys do not count.
- Roll replaces the secret and keeps the key ID. The old secret stops working at once, so deploy the new one right away.
- Revoke disables a key for good. The API refuses it within 30 seconds.
- Limits and quotas belong to the account, not the key. A new key does not reset them.
Keep keys secret
Call the API from your server and keep the key in an environment variable or a secret store. A key in a web page or a mobile app can be copied by anyone who has it. If a key leaks, roll or revoke it in the dashboard.
#Authentication errors
| Status | Code | When |
|---|---|---|
| 400 | key_in_query | The key was sent in the query string. |
| 401 | invalid_api_key | No key, a malformed key, or a key that is unknown, revoked or expired. |
| 403 | account_suspended | The account is suspended. Contact support. |
| 403 | scope_not_allowed | The key does not have the scope this endpoint needs. |
{
"error": {
"message": "invalid or missing API key",
"type": "authentication_error",
"code": "invalid_api_key"
}
}