Guides

Vietnamese text-to-speech API

Send text to POST https://yangopen.com/api/v1/tts with an API key and get an MP3 back. It reads with 195 Vietnamese Plus voices, Northern, Central and Southern, and about 2,200 voices in 19 languages. The price is the site's: 25 credits per 1,000 characters, charged only once the MP3 exists.

Start in three steps

  1. Create a key Sign in to Yangopen, open Voice API and press Create key. It looks like yo_live_… and is shown only once: copy it and keep it safe.
  2. Pick a voice Open https://yangopen.com/api/v1/voices?language=vi for the voice ids. For example yo-vn0001 is Hoài My, a Northern female voice.
  3. Call the API Send POST /api/v1/tts with the header Authorization: Bearer YOUR_KEY and the JSON body {"text": "Xin chào", "voice": "yo-vn0001"}. The answer is an MP3 file.

Code samples: curl, Python, JavaScript

Put the key in the environment variable YANGOPEN_KEY, then run one of the three samples below. Each writes the MP3 to a file as it arrives, so it works for short and long text alike.

# curl
curl https://yangopen.com/api/v1/tts \
  -H "Authorization: Bearer $YANGOPEN_KEY" \
  -H "Content-Type: application/json" \
  -d '{"text": "Xin chào", "voice": "yo-vn0001"}' \
  -o voice.mp3
# Python · pip install requests
import os
import requests

res = requests.post(
    "https://yangopen.com/api/v1/tts",
    headers={"Authorization": f"Bearer {os.environ['YANGOPEN_KEY']}"},
    json={"text": "Xin chào", "voice": "yo-vn0001"},
    stream=True,
    timeout=120,
)
if not res.ok:
    raise SystemExit(res.json()["error"]["message"])
with open("voice.mp3", "wb") as f:
    for chunk in res.iter_content(65536):
        f.write(chunk)
// JavaScript · Node.js 18+
import { createWriteStream } from "node:fs";
import { Readable } from "node:stream";
import { pipeline } from "node:stream/promises";

const res = await fetch("https://yangopen.com/api/v1/tts", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.YANGOPEN_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ text: "Xin chào", voice: "yo-vn0001" }),
});
if (!res.ok) throw new Error((await res.json()).error.message);
await pipeline(Readable.fromWeb(res.body), createWriteStream("voice.mp3"));

Parameters and the answer

  • text (required): what to read, up to 5,000 characters a call with Vietnamese voices and 2,000 with other languages. Long text is cut at sentence ends for you.
  • voice (required): a voice id from /api/v1/voices. Filter with language (vi, en, zh…), gender (female, male) or q (words in the name or style).
  • speed (optional): from 0.5 to 2, 1 by default.
  • Success: status 200 and the MP3 as the body. The headers X-Yangopen-Credits-Charged and X-Yangopen-Credits-Balance give the credits charged and the balance. Short text also has X-Yangopen-Duration-Seconds, the audio length.
  • Long text (over 1,000 Vietnamese characters, or 400 in other languages) is streamed: the first part arrives after about 10 seconds and the rest follows. Your app can start playing at once.
  • The balance: GET /api/v1/balance with the same key.

Errors

Errors are JSON: {"error": {"code": "…", "message": "…"}}. No error costs credit.

  • 401 missing_key, invalid_key: no key, a wrong key, or a revoked one.
  • 402 insufficient_credit: not enough credit. Top up on Pricing.
  • 404 unknown_voice and 400 ambiguous_voice: a wrong voice id, or a name two voices share.
  • 413 text_too_long: the text is over the voice's limit.
  • 429 rate_limited, daily_limit: too many calls a minute (about 30 from one address), or the account's daily allowance is used (see Limits).
  • 503 busy: the voice engine is busy. Wait about half a minute and try again.
  • A long text our side cannot finish: the connection is cut and nothing is charged. If your app hangs up mid-way, only what it received is charged.

Keep the key safe

  • Call the API from your server. Browsers are not allowed to call it, so never put the key in a web page's code or an app people download.
  • An account holds up to 5 keys. One key per app lets you revoke one without stopping the others.
  • If a key leaks, open Voice API and press Revoke. It stops working at once.
  • Yangopen stores only a hash of the key, never the key. The text is not stored; the account history records the voice, the characters and the credits, marked “API”.

Cost

  • 25 credits per 1,000 characters, rounded up to whole credits: the same as Plus voices on the site and in Claude.
  • A new account gets 500 credits, about 20,000 characters. Current prices are on Pricing.
  • Waiting time: about 30–40 seconds per 1,000 Vietnamese characters, about 3 minutes for 5,000 (measured 22 October 2026). Give your app’s request a timeout of at least 120 seconds.
  • The API has the Plus voices only. The site's free voices come from an outside service that cannot be resold through an API.

Frequently asked questions

Does Yangopen have a Vietnamese text-to-speech API?

Yes. Create a key on the Voice API page of your account, then send text to POST https://yangopen.com/api/v1/tts. The answer is an MP3 file.

Are there Northern and Central Vietnamese voices?

Yes. The 195 Vietnamese Plus voices cover Northern, Central and Southern accents. Filter with /api/v1/voices?language=vi.

Do I have to split long text myself?

No. Send up to 5,000 characters in one call. It is cut at sentence ends, read in order and streamed back, so your app can play the first part while the rest is read.

Can I call it from a browser?

No. Call it from your server so the key stays secret: your page calls your server, and your server calls Yangopen.

Does a failed call cost credit?

No. Credit is charged only once the MP3 exists. Every error says “Nothing was charged”.

Updated: