Skills for AI/ML API, one API for 10,000+ AI models and tools: choosing models, chat on any protocol, images, video and audio jobs, speech, decision models, webhooks, batches, errors, costs and sandbox testing
93%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
Medium
Suggest reviewing before use
Text-to-speech is one synchronous call, POST /v1/tts. Speech-to-text is a job: POST /v1/stt/create answers with a generation_id, and you poll GET /v1/stt/<generation_id> for the transcript.
response.json(), or a transcription that stays generatingcurl -s 'https://api.aimlapi.com/v1/models?type=internal/text-to-speech&include=pricing'
curl -s 'https://api.aimlapi.com/v1/models?type=internal/speech-to-text/submit&include=pricing'Then read the model's info.docsJson (with aimlapi-models: models.py params openai/tts-1). Field names change between families: the TTS text is script for VibeVoice, the voice is voice, voice_id or voice_setting, the STT file field is file or audio. Maps: references/tts.md, references/stt.md.
python3 scripts/speech.py tts --out speech.mp3 --body '{
"model": "openai/tts-1",
"text": "Your order has shipped.",
"voice": "alloy",
"response_format": "mp3"
}'The answer is JSON with a link:
{ "audio": { "url": "https://…/speech.mp3" }, "meta": { "usage": { "credits_used": 0, "usd_spent": 0 } } }audio.url; the link does not last. The published schema shows audio as a string, so accept that too."stream": true the body is the audio itself, labelled audio/wav whatever the format, with no cost in it (GET /v2/logs has it).stream to true (Deepgram and ElevenLabs on 2026-11-23): leave it out and you get bytes. Read stream in the schema; send "stream": false for JSON.python3 scripts/speech.py stt --model deepgram/nova-3 --url https://example.com/meeting.mp3
python3 scripts/speech.py stt --model openai/gpt-4o-mini-transcribe --file meeting.mp3 --out answer.jsonThe script submits (JSON with url, or a multipart upload in the file field the model's schema names), polls, and prints the transcript; --out keeps the whole answer; more fields go in --body '{"language": "en"}'.
The final poll is {"generation_id": …, "status": "completed", "result": …}. result is the provider's own answer: result.text for most models, result.results.channels[0].alternatives[0].transcript for Deepgram. Shapes and a full Python loop: references/stt.md.
Instead of polling, add "webhook_url" to the submit (not in sandbox): aimlapi-webhooks.
speech.py0 done; 1 job failed (status: "error") or no audio in the answer; 2 still running at --timeout or polls kept failing (resume: python3 scripts/speech.py poll <generation_id>); 3 HTTP or network error; 4 audio generated and charged but not saved (fetch the printed URL again). --sandbox makes any command free.
input is not the TTS text field here: input alone is 400.Content-Type before parsing. application/json carries audio.url; anything else is the audio.maxLength; split long text at sentence ends.generation_id as soon as the submit answers. After a restart, poll it; never resubmit (a second, billed job).queued and generating mean wait, error is final. Save the result: transcripts are kept for one hour.temperature) was refused in sandbox mode. For numeric fields, send the audio by url in JSON.pricing in the catalogue (per character, token or second, depending on the model), never from memory.| When | Response | Do |
|---|---|---|
| TTS or STT submit | 400 "Validation failed", error.details[] | fix each path from docsJson; "One of url or file is required" names the file field the model wants |
TTS stream: true, sandbox | 400 sandbox_unsupported | test streaming with a small live call |
| TTS | 200 but response.json() fails | it is the binary answer: send "stream": false, or save the bytes |
| any | 403, 429, 5xx | aimlapi-errors; for 429 wait Retry-After |
| poll | 404 "Inference not found" | wrong id, or the result is older than its retention |
| poll | status: "error" with error.message | the job failed; fix the audio or try another model |
python3 scripts/speech.py tts --sandbox --out t.mp3 --body '…' and python3 scripts/speech.py stt --sandbox --model <id> --file <audio> succeed with your real body and model (free, checked against the schema).stream; STT code stores the generation_id and reads the transcript for its model family.stream defaults, fields per family