Agent recipes
Deterministic workflows for Claude, Codex, and other coding agents.
Use these recipes when an agent needs to integrate the API without guessing. Set the environment first, use the OpenAPI contract for exact schemas, and treat the verification step as part of the task.
export SAWTAK_API_BASE_URL="https://api.sawtakarabi.ai/v1"
export SAWTAK_API_KEY="<API_KEY>"Generate a WAV file
Goal: create a playable Arabic WAV file from text.
curl --fail --show-error "$SAWTAK_API_BASE_URL/audio/speech" \
-H "Authorization: Bearer $SAWTAK_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"arabic-tts-1","input":"مرحباً بك","response_format":"wav"}' \
--output speech.wav
file speech.wavDone when: the request exits successfully and file speech.wav identifies a WAV audio file. Do not retry 400, 401, 402, or 403 unchanged. For 429 and transient 5xx responses, follow Request limits.
Transcribe an audio file
Goal: print an Arabic transcript from a local audio file.
curl --fail --show-error "$SAWTAK_API_BASE_URL/audio/transcriptions" \
-H "Authorization: Bearer $SAWTAK_API_KEY" \
-F model="arabic asr" \
-F [email protected] \
-F response_format=jsonDone when: the JSON response contains text. Keep the original file unchanged so a failed upload can be diagnosed or retried safely.
Clone a voice and wait for it
Goal: obtain a ready private voice ID for later synthesis.
- Send the multipart request in Voice cloning. It requires one reference file, a name, and JSON
labelscontainingdialect. - Save the returned
id. - Poll
GET /v1/voices/{id}with the same Bearer key untilstatusisready. - Use that ID as
voicein the text-to-speech request.
Done when: the voice response reports status: "ready". Never substitute a different voice when cloning is still processing or fails.
Diagnose a failed request
Goal: choose the next safe action from an API failure.
- Read the HTTP status and
error.code. - Save
request_idif present. - Correct client input for
400, replace credentials for401, add balance for402, and use a key with the required scope for403. - For
429, wait forRetry-Afterand use bounded exponential backoff with jitter. - Retry only idempotent work after a transient
5xx; avoid duplicating a voice-creation request.
The canonical machine schema is OpenAPI v1. Use it over inferred fields or values.