Text-to-speech (OpenAI-compatible)

$0.060 per call · USDC via x402 · POST /v1/audio/speech

OpenAI-compatible text-to-speech over x402 - point any OpenAI SDK's audio.speech.create() at base_url https://agent402.tools/v1 and pay $0.06 per call in USDC, no API key, no signup. Send POST /v1/audio/speech with the required field input and pay $0.060 per call over x402 or MPP (there is no free tier). It returns raw bytes, not JSON, with Content-Type audio/mpeg or audio/pcm.

Served by Voxtral Mini TTS behind a five-model failover chain (xAI Grok Voice, Kokoro, MAI-Voice-2 Flash, MAI-Voice-2), every link proven by a real paid canary - a provider outage never becomes your failure. Up to 2,000 chars in, raw mp3 (default) or pcm bytes out - the same wire shape as OpenAI's endpoint. OpenAI voice names (alloy, nova, …) map per-model; native voice ids (e.g. en_paul_cheerful) work too. zdr:true routes only to zero-data-retention providers.

Category: LLM gateway · Tags: tts text-to-speech speech audio voice llm ai inference

TRY IN PLAYGROUND →

Parameters

NameTypeRequiredDescription
inputstringyesText to speak (up to 2,000 chars) Also accepted as text, data, str, string, body, content.
voicestringnoOpenAI voice name - alloy (default), ash, ballad, coral, echo, fable, onyx, nova, sage, shimmer, verse - or a native voice id from GET /v1/models (e.g. en_paul_cheerful)
response_formatstringno"mp3" (default) or "pcm"
modelstringnoOptional - pin a chain model (e.g. mistralai/voxtral-mini-tts-2603); the rest stay as fallbacks
speednumbernoOptional 0.25–4 playback speed (providers that don't support it ignore it)
zdrbooleannoOptional - true routes only to zero-data-retention providers

Example request

curl -i -X POST https://agent402.tools/v1/audio/speech \
  -H "Content-Type: application/json" \
  -d '{"input":"Agent402 serves fourteen hundred tools, paid per call.","voice":"alloy"}'

Without payment this returns HTTP 402 Payment Required with the exact price for v1-audio-speech; any x402 v2 or MPP client pays it and retries.

Example response

A 200 carries raw bytes, not JSON, with Content-Type audio/mpeg or audio/pcm: the file itself.

From an MCP client

catalog.call {
  "slug": "v1-audio-speech",
  "params": {
    "input": "Agent402 serves fourteen hundred tools, paid per call.",
    "voice": "alloy"
  }
}

The hosted connector at https://agent402.tools/mcp needs a payment for v1-audio-speech; the stdio package pays it from a wallet or from AGENT402_CREDITS_KEY. Local install: npx -y agent402-mcp.

Errors and behavior

Paid call (JavaScript agent)

import { wrapFetchWithPayment } from "@x402/fetch";
import { x402Client } from "@x402/core/client";
import { registerExactEvmScheme } from "@x402/evm/exact/client";
import { privateKeyToAccount } from "viem/accounts";

const client = new x402Client();
client.setSpendControls?.(false); // keep your own spending ceiling in code
registerExactEvmScheme(client, { signer: privateKeyToAccount(KEY) });
const payFetch = wrapFetchWithPayment(fetch, client);

const res = await payFetch("https://agent402.tools/v1/audio/speech", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    "input": "Agent402 serves fourteen hundred tools, paid per call.",
    "voice": "alloy"
  }),
});

Related tools

Chat completions (OpenAI-compatible)

$0.02 · POST /v1/chat/completions

OpenAI-compatible chat completions, base tier: point any OpenAI SDK at base_url https://agent402.tools/v1 and pay per ca…

Chat completions - auto tier (eval-ranked routing)

$0.01 · POST /v1/auto/chat/completions

OpenAI-compatible chat completions with server-side model choice: omit "model" (or send "auto") and the gateway routes t…

Grounded chat (web search, OpenAI-compatible)

$0.03 · POST /v1/grounded/chat/completions

OpenAI-compatible chat completions GROUNDED in a live web search on every call: the gateway runs an Exa search (up to 5 …

Chat completions - metered (pay what the call costs)

$0.001 · POST /v1/metered/chat/completions

OpenAI-compatible chat completions billed per request from what the call costs: the 402 quotes exact-BPE input plus your…

Chat completions - nano tier

$0.003 · POST /v1/nano/chat/completions

OpenAI-compatible chat completions, nano tier: gpt-6-luna (the default), gpt-5.6-luna, gpt-5-nano, gemini flash-lite, sm…

Chat completions - premium tier

$0.50 · POST /v1/premium/chat/completions

OpenAI-compatible chat completions, premium tier: gpt-5, gpt-6 astra, o3 and o4-mini, claude opus, claude fable 5.1 - pa…