Endpoints

Speech synthesis

Turn Crimean Tatar text into speech. The request follows OpenAI’s audio/speech; the response is the audio file itself.

POSThttps://api.ana-yurt.dev/v1/audio/speech

Bearer key with the tts scope. Runs on the GPU machine.

#Request body

JSON, Content-Type: application/json.

Request body
NameTypeDescription
inputrequiredstring

Text to speak, in Latin or Cyrillic. Up to 500 characters.

Longer text gets 413 payload_too_large; empty or blank text gets 400 invalid_request.

voicerequiredstring

servin (male) or sevil (female). The current list is at GET /v1/audio/voices. OpenAI voice names such as alloy are refused.

response_formatoptionalstring

mp3, wav or opus.

Default: mp3

modeloptionalstring

Ignored. Accepted so OpenAI clients that always send it keep working.

Other OpenAI fields, such as speed or instructions, are ignored.

#Response

The body is the audio. Save it as a file or stream it to a player.

response_formatContent-Type
mp3audio/mpeg
wavaudio/wav
opusaudio/ogg; codecs=opus

#Response headers

  • X-AY-Audio-Seconds: seconds billed for this request.
  • X-Quota-Remaining-seconds: synthesis seconds left in the current window.
  • X-AY-Model: omnivoice-crh. X-AY-Model-Version: the served checkpoint, e.g. omnivoice-crh-lora-v8b/checkpoint-5850.
  • The rate limit headers and X-Request-Id.

#Limits and billing

  • Billed in seconds of generated audio, rounded up, against the plan’s synthesis quota.
  • Before the call the API reserves 0.1 s per input character plus 2 s. If that does not fit in what is left, the request gets 429 quota_exceeded and nothing is charged.
  • One synthesis request per account at a time. The GPU machine runs one synthesis at a time for the whole API.
  • A short sentence takes about 2 to 3 seconds. The API waits up to 90 seconds, then answers 504 timeout.
  • When the synthesis slot or the GPU is busy, the request waits up to 20 seconds (inside the same 90 seconds) before it answers 503 service_busy.

#Errors

StatusCodeWhen
400invalid_requestBody not JSON, empty input, unknown voice or response_format.
401invalid_api_keyMissing, unknown, revoked or expired key.
403scope_not_allowedThe key has no tts scope. Also account_suspended.
403voice_not_allowedThe key is limited to other voices.
413payload_too_largeInput over 500 characters.
429concurrent_requestA synthesis request of this account is already running.
429rate_limitedThe per-minute limit is reached.
429quota_exceededNot enough synthesis seconds left.
502upstream_errorThe speech server failed. Retry.
503service_busyThe synthesis slot or the GPU stayed busy for 20 s. Retry after Retry-After.
503service_unavailableThe GPU machine is offline (Retry-After 300 s) or the model is not loaded (Retry-After 60 s, see status).
504timeoutThe model did not finish within 90 seconds.
400 Bad Request
{
  "error": {
    "message": "voice must be one of servin, sevil",
    "type": "invalid_request_error",
    "code": "invalid_request"
  }
}

Longer text

Split text at sentence boundaries into parts of up to 500 characters, synthesise them one after the other, and join the audio with a tool such as ffmpeg.

Use of synthetic speech

Do not present generated speech as a real person’s recording (API Terms, section 4).

Request
curl https://api.ana-yurt.dev/v1/audio/speech \
  -H "Authorization: Bearer $AY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"input": "Selâm! Bugün hava pek güzel.", "voice": "servin", "response_format": "mp3"}' \
  -o speech.mp3
Response 200
HTTP/2 200
content-type: audio/mpeg
content-length: 19437
ratelimit-limit: 20
ratelimit-remaining: 19
ratelimit-reset: 3
x-ay-model: omnivoice-crh
x-ay-audio-seconds: 3
x-quota-remaining-seconds: 297
x-request-id: 31d841c3d06548fb988a420914a3a10a

<binary MP3, 24 kHz mono>