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

Header
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

PartExampleMeaning
ay_live_ay_live_Prefix of a live key. The dashboard issues live keys only.
kid10 characters, a-z and 2-7Public key ID. It is shown in the dashboard and is safe to log.
secretAbout 43 characters, base62The 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.

ScopeEndpoint
translitPOST /v1/translit
asrPOST /v1/audio/transcriptions
ttsPOST /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

StatusCodeWhen
400key_in_queryThe key was sent in the query string.
401invalid_api_keyNo key, a malformed key, or a key that is unknown, revoked or expired.
403account_suspendedThe account is suspended. Contact support.
403scope_not_allowedThe key does not have the scope this endpoint needs.
401 Unauthorized
{
  "error": {
    "message": "invalid or missing API key",
    "type": "authentication_error",
    "code": "invalid_api_key"
  }
}