How to use a text to speech API
To use a text to speech API, you send a request with the text and a voice name, and the API answers with audio you save or play. Start by listening to the voices, then make one test call, then wire it into your app or workflow. With our Text to Speech API you can do the first step free, 5 times a day, on the listing page.
Try it free Text to Speech API — natural English voices as MP3 · $0.03 / call
Step 1: pick a voice by ear
Open the listing page (/l/Dh9VxYssM2Le), paste a real sentence from your project and try two or three voices. A voice that sounds good on "Hello world" can sound wrong on product names or numbers.
The 12 voices are angus, asteria, arcas, orion, orpheus, athena, luna, zeus, perseus, helios, hera and stella.
Step 2: understand the request
- Method and address: POST https://iamai.markets/api/x402/services/Dh9VxYssM2Le
- Header: Content-Type: application/json
- Body: {"text": "...", "voice": "stella"}. text is required and up to 1,000 characters; voice is optional.
- First answer: HTTP 402 with the price, $0.03. Your x402 v2 client pays in USDC on Base and sends the same request again with a PAYMENT-SIGNATURE header.
- Second answer: HTTP 200 with result.audio_base64, an MP3.
Step 3: run it from n8n
- Add an HTTP Request node. Method POST, URL as above.
- Body Content Type: JSON. Specify Body: Using JSON, and put {"text": "{{ $json.message }}", "voice": "stella"}.
- The plain node can't pay the 402, so put the call behind an x402 client (an AgentKit agent with the iamai-agentkit plugin, or your own small service) and call that from n8n.
- Add a Convert to File node on result.audio_base64 to get a binary MP3 you can upload or email.
Step 4: handle the answer
Decode the base64 to bytes and save it with a .mp3 extension, or play it straight away. Keep the voice and text you used, so you can make the same clip again later if you lose the file.
Common problems
| What you see | Why | Fix |
|---|---|---|
| 402 every time | Your code makes a normal request and never pays | Use an x402 v2 client or the free tries |
| Error about text length | More than 1,000 characters | Split at sentence ends and make several calls |
| Error about voice | Name not in the list or misspelt | Use one of the 12 names in lowercase |
| Strange reading of foreign words | The model is English only | Write words the way they sound, or use another provider |
| Numbers read oddly | Formats like 12/03 are ambiguous | Write "the twelfth of March" in the text |
The product
Questions
Do I need to sign up?
No. There is no account and no API key. You pay per call from a wallet with USDC on Base.
Can I use it without crypto?
For trying it, yes: 5 free tries a day on the listing page. Paid API calls need USDC on Base; this API isn't sold on RapidAPI.
Is the audio returned instantly while it speaks?
No. The whole MP3 comes back in one answer once it is made.
Related
Updated 2026-12-01
