OpenAI SDK-compatible speech
/oai/audio/speechGenerates speech with the official OpenAI SDK. Set the client's base URL to https://api.allmodels.io/oai and use your AllModels API key. Use stream_format=audio for audio bytes or stream_format=sse for OpenAI speech events.
Use provider_options for provider-specific settings. You can also pass
supported options directly as query parameters. If both forms set the same
option, provider_options[<name>]=<value> takes precedence. Recognized enum
and boolean option values are case-insensitive and are normalized to each
provider's wire spelling; free-form values such as prompts, keyterms, and voice
IDs retain their original case.
Authorization
BearerAuth Tenant key supplied as the Authorization Bearer token.
In: header
Query Parameters
Comma-separated or repeated provider IDs in preferred order. Providers not listed remain eligible.
Comma-separated or repeated provider IDs. Only these providers may serve the request.
Comma-separated or repeated provider IDs that must not serve the request.
Set to false to prevent fallback to another provider. Automatic provider retries are not currently supported.
Provider-specific options in bracket notation, such as provider_options[encoding]=linear16. You can also pass supported options directly as query parameters. If both forms set the same option, the bracketed value takes precedence.
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
application/json
application/json
application/json
application/json
application/json
application/json
import { writeFile } from "node:fs/promises";import OpenAI from "openai";const client = new OpenAI({ apiKey: process.env.ALLMODELS_API_KEY, baseURL: "https://api.allmodels.io/oai"});const response = await client.audio.speech.create({ model: "elevenlabs/eleven-turbo-v2-5", voice: "pNInz6obpgDQGcFmaJgB", input: "Hello from AllModels", response_format: "mp3"});await writeFile("speech.mp3", Buffer.from(await response.arrayBuffer()));import osfrom openai import OpenAIclient = OpenAI( api_key=os.environ["ALLMODELS_API_KEY"], base_url="https://api.allmodels.io/oai",)with client.audio.speech.with_streaming_response.create( model="elevenlabs/eleven-turbo-v2-5", voice="pNInz6obpgDQGcFmaJgB", input="Hello from AllModels", response_format="mp3",) as response: response.stream_to_file("speech.mp3")"string"{ "error": { "message": "string", "type": "string", "param": "string", "code": "string" }}{ "error": { "message": "string", "type": "string", "param": "string", "code": "string" }}{ "error": { "message": "string", "type": "string", "param": "string", "code": "string" }}{ "error": { "message": "string", "type": "string", "param": "string", "code": "string" }}{ "error": { "message": "string", "type": "string", "param": "string", "code": "string" }}{ "error": { "message": "string", "type": "string", "param": "string", "code": "string" }}Native streaming STT (WebSocket) GET
Opens a WebSocket and emits normalized streaming speech-to-text events. The request must include `Upgrade: websocket`.
OpenAI SDK-compatible transcription POST
Transcribes an uploaded audio file with the official OpenAI JavaScript or Python SDK. Set `stream=true` only when the selected model supports streaming transcription.
