Skip to content

Text-to-speech (OpenAI-compatible)

$0.06 per callUSDC via x402POST /v1/audio/speech

AI-generated voice: tell listeners so.

Category: LLM gatewayTags: tts text-to-speech speech audio voice llm ai inference

Try in playground →

Details

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. Served by Voxtral Mini TTS behind a five-model failover chain (xAI Grok Voice, Kokoro, MAI-Voice-2.1 Flash, MAI-Voice-2.1), 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.

Parameters

NameTypeRequiredDescription
inputstringyesText to speak (up to 2,000 chars) Also accepted as text, data, str, string, body, content. Up to 2000 characters. The example sends Agent402 serves 500+ tools, paid per call..
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) The example sends alloy.
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 500+ tools, paid per call.","voice":"alloy"}'

Watch a call get paid

RequestPOST /v1/audio/speech
402$0.06 USDC
SignPAYMENT-SIGNATURE
Settleon 14 chains
Answer200 OK
ReceiptAgent402-ReceiptEd25519

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 500+ tools, paid per call.",
    "voice": "alloy"
  }
}

Hosted connector (https://agent402.tools/mcp): paid in the call. Stdio package (npx -y agent402-mcp@0.17.2): pays from a wallet or an AGENT402_CREDITS_KEY issued earlier.

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?.({ maxAmountPerPayment: "$0.06" }); // refuse any quote above this tool's price
registerExactEvmScheme(client, { signer: privateKeyToAccount(process.env.AGENT_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 500+ tools, paid per call.",
    "voice": "alloy"
  }),
});

Get a wallet or run npx -y agent402-mcp@0.17.2 wallet new.

The quote (Python)

import base64, json, urllib.error, urllib.request

req = urllib.request.Request("https://agent402.tools/v1/audio/speech", method="POST", data="{\"input\":\"Agent402 serves 500+ tools, paid per call.\",\"voice\":\"alloy\"}".encode(), headers={"Content-Type": "application/json"})
try:
    urllib.request.urlopen(req)
except urllib.error.HTTPError as e:
    quote = json.loads(base64.b64decode(e.headers["PAYMENT-REQUIRED"]))
    print(e.code, [(a["network"], a["amount"]) for a in quote["accepts"]])  # the price, per chain, in base units

Related tools