Speech
POST /v1/audio/speech turns text into spoken audio. It follows the OpenAI text-to-speech format, so client.audio.speech.create works with the base URL changed. Speech models are listed on the models page — among them tts-1, tts-1-hd, eleven-multilingual-v2, eleven-v3 and gemini-2.5-flash-preview-tts.
Generate audio
curl https://api.cloakray.com/v1/audio/speech \
-H "Authorization: Bearer $CLOAKRAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "tts-1",
"input": "Your order has shipped and will arrive on Thursday.",
"voice": "alloy",
"response_format": "mp3"
}' \
--output speech.mp3
import fs from "node:fs";
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://api.cloakray.com/v1", apiKey: process.env.CLOAKRAY_API_KEY });
const audio = await client.audio.speech.create({
model: "tts-1",
input: "Your order has shipped and will arrive on Thursday.",
voice: "alloy",
});
fs.writeFileSync("speech.mp3", Buffer.from(await audio.arrayBuffer()));
The response body is the audio file itself, not JSON. Save the bytes.
Parameters
| Parameter | What it does |
|---|---|
model | Required. A speech model. |
input | Required. The text to speak. |
voice | The voice. Each model family has its own voices; without one, the model's default is used. |
response_format | mp3, wav, opus, aac, flac or pcm, where the model supports it. Defaults depend on the model. |
speed | Playback speed, on models that support it. |
instructions | A style direction such as "speak warmly and slowly", on models that take one. |
Pricing
Speech is priced per character of input (or per token on some models), shown on each model's page. A long text costs proportionally more, so trim markup and boilerplate before sending it.
Not offered
The response is buffered and returned in one piece; streaming audio as it is generated is not offered. For live, two-way voice, realtime sessions are not offered yet.