Text to speech API (audio/speech)
Narrate Persian and English text with POST /v1/audio/speech and the OpenAI SDK: voices, mp3 or wav, speed, Persian-capable auto model, per-character price.
Updated: 4 Oct 2026
POST /v1/audio/speech has OpenAI's shape and returns the audio file itself, so client.audio.speech.create works unchanged.
Python
from openai import OpenAI
client = OpenAI(base_url="https://api.uttapen.ir/v1", api_key="sk-up-...")
audio = client.audio.speech.create(
model="uttapen/auto-speech", # Persian text goes to a model that reads Persian correctly
voice="", # empty: the default voice of whichever model is picked
input="سلام! به یوتاپن خوش آمدید.",
)
audio.write_to_file("hello.mp3")
Node
import OpenAI from "openai";
import { writeFile } from "node:fs/promises";
const client = new OpenAI({ baseURL: "https://api.uttapen.ir/v1", apiKey: "sk-up-..." });
const res = await client.audio.speech.create({ model: "uttapen/auto-speech", voice: "", input: "Hello from uttapen." });
await writeFile("hello.mp3", Buffer.from(await res.arrayBuffer()));
Fields
| Field | Meaning |
|---|---|
model | a model id or uttapen/auto-speech |
input | the text, up to 5,000 characters |
voice | one of that model's voices (listed on its page). Empty means the default; leave it empty with automatic picking, since you do not know the model in advance |
response_format | mp3 (default), wav, opus, aac, flac, pcm |
speed | 0.25 to 4 |
An unknown voice answers 400 with param: "voice" and a few valid examples.
Answer
The body is the audio file. Cost and a link come in headers:
| Header | Value |
|---|---|
X-Uttapen-Cost-Toman | the cost of this request |
X-Uttapen-Balance-Toman | the balance after the charge |
X-Uttapen-Media-Url | a signed 24-hour link to the same file (kept 30 days) |
X-Uttapen-Media-Id | the job id, for GET /v1/uttapen/media/{id} |
If a run takes more than a few minutes, you get 202 with the job object instead of the file; fetch the result later by its id.
Price
Unlike images and video, speech makers do not report a cost per request. The charge is therefore the model's published price × characters (with a fixed audio-tokens-per-character estimate for models that price their audio output in tokens). The price per 1,000 characters is listed under speech models, and that same figure is held before the run. Failed requests are free. More in the media overview.
Sign up with a phone number, top up your wallet from 100,000 toman and create a key. Free models work without a top-up — up to 50 requests a day. Create an API key →