API
Speech
POST /audio/speech: text to speech, returned as audio bytes.
Request
`POST /audio/speech` takes `model` (a speech model id from `/models`), `input` (up to 4,096 characters), optional `voice` (a voice name or id the provider knows; omitted, the model's `default_voice` from `/models` speaks), `speed` and `response_format` (`mp3`, the default; each model lists the formats it takes on `/models`, out of `opus`, `aac`, `flac`, `wav` and `pcm`). The response body is the audio; the WIT charged, the model's `per_1k_chars` price times the started blocks of 1,000 characters, is in the `x-allwit-wit-charged` header. The input text is never stored.
from openai import OpenAI
client = OpenAI(
base_url="https://www.allwit.ai/api/v1",
api_key="aw_live_…", # from /app/account/api-keys
)
speech = client.audio.speech.create(
model="<a speech model id from GET /models>",
voice="alloy",
input="Welcome to Allwit. Every model, one wallet.",
response_format="mp3",
)
speech.write_to_file("welcome.mp3")import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://www.allwit.ai/api/v1",
apiKey: process.env.ALLWIT_API_KEY, // aw_live_…
});
const speech = await client.audio.speech.create({
model: "<a speech model id from GET /models>",
voice: "alloy",
input: "Welcome to Allwit. Every model, one wallet.",
response_format: "mp3",
});
await fs.promises.writeFile("welcome.mp3", Buffer.from(await speech.arrayBuffer()));curl https://www.allwit.ai/api/v1/audio/speech \
-H "Authorization: Bearer $ALLWIT_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "<speech model id>", "input": "Welcome to Allwit.", "response_format": "mp3"}' \
--output welcome.mp3