allmodels.ioDocs
API ReferenceOpenAI SDK

OpenAI SDK-compatible speech

POST/oai/audio/speech

Generates 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
AuthorizationBearer <token>

Tenant key supplied as the Authorization Bearer token.

In: header

Query Parameters

provider_order?array<string>

Comma-separated or repeated provider IDs in preferred order. Providers not listed remain eligible.

provider_only?array<string>

Comma-separated or repeated provider IDs. Only these providers may serve the request.

provider_ignore?array<string>

Comma-separated or repeated provider IDs that must not serve the request.

allow_fallbacks?boolean

Set to false to prevent fallback to another provider. Automatic provider retries are not currently supported.

provider_options?||||||||||||||

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

Client
Language
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()));
"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"  }}