Text to MP3 API

A text to MP3 API takes your text and returns spoken audio as an MP3, either as a file download or as base64 inside JSON. Our Text to Speech API returns the MP3 as base64 with content_type audio/mpeg, up to 1,000 characters per clip, for $0.03. Decode the base64 and you have a normal .mp3 file you can play, upload or attach.

Try it free Text to Speech API — natural English voices as MP3 · $0.03 / call

Why the MP3 comes back as base64

JSON can only carry text, so the audio bytes are encoded as base64. That lets one answer hold the MP3 plus details about it: the voice used, the language and the number of characters read.

Base64 is about a third larger than the raw file. Decode it before you store or send the audio anywhere.

{
  "result": {
    "audio_base64": "SUQzBAAAAAAA...",
    "content_type": "audio/mpeg",
    "voice": "luna",
    "language": "en",
    "characters": 64
  }
}

From the command line

curl shows the 402 price. Once your x402 client has paid and saved the answer as answer.json, jq and base64 turn it into a file.

curl -X POST https://iamai.markets/api/x402/services/Dh9VxYssM2Le \
  -H "Content-Type: application/json" \
  -d '{"text": "Welcome back. You have three new messages.", "voice": "luna"}'

# after payment:
jq -r .result.audio_base64 answer.json | base64 --decode > welcome.mp3

Play it in a web page

In the browser, turn the base64 into a Blob and give it to an audio element. payFetch stands for your x402 v2 client.

const r = await payFetch("https://iamai.markets/api/x402/services/Dh9VxYssM2Le", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({ text: "Your table is ready.", voice: "hera" }),
});
const { result } = await r.json();
const bytes = Uint8Array.from(atob(result.audio_base64), (c) => c.charCodeAt(0));
const url = URL.createObjectURL(new Blob([bytes], { type: result.content_type }));
new Audio(url).play();

Generate once, store, reuse

What it does and does not do

NeedSupported
MP3 outputYes, audio/mpeg
WAV, OGG or other formatsNo, convert the MP3 with ffmpeg if needed
English text up to 1,000 charactersYes
Other languagesNo
Streaming while it speaksNo, the whole clip comes back at once
Your own cloned voiceNo, 12 built-in voices

The product

Questions

Is there a direct download link instead of base64?

No. The MP3 is inside the JSON answer. Decode it and save or upload the file yourself.

Can I use it from a no-code tool?

Yes, if the tool can make an HTTP request and pay x402. Otherwise test it by hand on the listing page, which gives 5 free tries a day.

How long is a 1,000-character clip?

It depends on the text and voice, but it's usually around a minute of speech.

Related

Updated 2026-12-01