← Về Studio

API Reference

REST API chuyển văn bản thành giọng nói — hỗ trợ đa ngôn ngữ. Base URL: https://iclever-tts.yez.vn

Mỗi request trả về JSON. Audio file được serve qua URL trong response. Không cần giải mã binary.

Xác thực

Mọi endpoint tạo hoặc truy xuất dữ liệu riêng tư đều yêu cầu xác thực. Với tích hợp server-to-server, dùng API Key trong header X-API-Key. Với ứng dụng có người dùng, đăng nhập để lấy Bearer access token.

HTTP Header
X-API-Key: ick_your_api_key_here

API Key được cấp qua endpoint Admin hoặc giao diện quản trị. Giữ key như mật khẩu: chỉ lưu ở biến môi trường, không nhúng vào app web/client.

Đăng ký, đăng nhập và làm mới token

Access token có hạn dùng 24 giờ; refresh token có hạn dùng 30 ngày. API Key phù hợp hơn cho worker/bot chạy dài hạn.

Đăng ký
curl -X POST https://iclever-tts.yez.vn/api/v1/auth/register \
  -H 'Content-Type: application/json' \
  -d '{"email":"[email protected]","password":"mật-khẩu-từ-6-ký-tự","name":"Tên của bạn"}'

# Login: POST /api/v1/auth/login với email và password.
# Refresh: POST /api/v1/auth/refresh, header Authorization: Bearer <refresh_token>.
# Current user/quota: GET /api/v1/auth/me, header Authorization: Bearer <access_token>.

Ngôn ngữ hỗ trợ

iClever TTS hỗ trợ 14 ngôn ngữ thông qua các model khác nhau. Dùng tham số language trong mọi request tổng hợp.

🇻🇳 Tiếng Việt vi
🇬🇧 English en
🇨🇳 中文 zh
🇯🇵 日本語 ja
🇰🇷 한국어 ko
🇫🇷 Français fr
🇩🇪 Deutsch de
🇪🇸 Español es
🇧🇷 Português pt
🇷🇺 Русский ru
🇸🇦 العربية ar
🇮🇳 हिन्दी hi
🇹🇭 ภาษาไทย th
🇮🇩 Indonesia id

Model theo ngôn ngữ

ModelNgôn ngữGhi chú
vieneu vi Tiếng Việt bản địa — GPU inference, 10 giọng Nam miền, hỗ trợ cảm xúc & voice cloning
edge vi, en, zh, ja, ko, fr, de, es, pt, ru, ar, hi, th, id Microsoft Neural TTS — miễn phí, không cần GPU, 50+ giọng đọc, tất cả 14 ngôn ngữ
xtts en, zh, ja, ko, fr, de, es, pt, ru, ar, hi, it, nl, pl, cs, hu, tr Coqui XTTS v2 — voice cloning từ 6s mẫu âm thanh. Không hỗ trợ tiếng Việt.
vbee vi Vbee API — tiếng Việt 3 miền, cần cấu hình App ID & Token

Mã lỗi

CodeMeaningGhi chú
200OKThành công
400Bad RequestTham số không hợp lệ (language code sai, model không tương thích…)
401UnauthorizedAPI key sai hoặc hết hạn mức
403ForbiddenThiếu Admin Key
429Too Many RequestsĐã hết quota phút/tháng của gói — cần nâng cấp
500Internal ErrorLỗi model / server

POST /api/v1/synthesize

Tạo giọng nói từ văn bản. Hỗ trợ đa ngôn ngữ, cảm xúc, tốc độ và chọn model/giọng đọc.

Request Body

Tham sốKiểuRequiredMô tả
text string Required Văn bản cần đọc (tối đa 3.000 ký tự mỗi request). Với nội dung dài, tách theo câu và ghép audio ở phía client.
language string New Mã ngôn ngữ ISO 639-1: vi | en | zh | ja | ko | fr | de | es | pt | ru | ar | hi | th | id. Mặc định: vi
voice_id string Optional ID giọng đọc — xem /api/v1/voices?lang=<code>. Mặc định: giọng đầu tiên của ngôn ngữ
model string Optional Override model. Danh sách model/trạng thái thật lấy từ GET /api/v1/models; hiện gồm vieneu, edge, omnivoice, valtec, supertonic, piper, mms_vi, voxcpm và model đang được bật. Mặc định: model active.
emotion string Optional natural | happy | sad | angry | fearful. Mặc định: natural. Chỉ có tác dụng với model vieneu.
speed float Optional Tốc độ đọc 0.52.0. Mặc định: 1.0
format string Optional wav hoặc mp3. Mặc định: wav

Response

JSON Response
{
  "job_id":      "a1b2c3d4e5f6",
  "audio_url":   "/outputs/a1b2c3d4e5f6.wav",
  "format":      "wav",
  "model":       "edge",
  "voice_id":    "en-US-JennyNeural",
  "characters":  42,
  "duration_ms": 1843
}
Tham số emotion chỉ hoạt động với model vieneu (tiếng Việt). Với edge, xtts, vbee tham số này bị bỏ qua. Model xtts không hỗ trợ tiếng Việt — dùng edge hoặc vieneu cho language: "vi".

POST /api/v1/clone

Clone giọng nói từ file audio mẫu 3–10 giây. Hỗ trợ VieNeu TTS (tiếng Việt) và XTTS v2 (các ngôn ngữ khác).

Request (multipart/form-data)

FieldKiểuRequiredMô tả
textstringRequiredVăn bản cần đọc bằng giọng clone
ref_audiofileRequiredFile WAV/MP3 mẫu giọng đọc (3–10 giây, rõ ràng, không có tiếng ồn)
languagestringNewNgôn ngữ của văn bản. Mặc định: vi. Dùng en, zh… để dùng XTTS v2.
modelstringOptionalvieneu (vi) hoặc xtts (en/zh/ja…)

GET /api/v1/voices

Lấy danh sách giọng đọc. Dùng tham số lang để lọc theo ngôn ngữ.

Query ParamKiểuMô tả
lang string NewMã ngôn ngữ: vi | en | zh | ja | ko | … Mặc định: vi
model string Override model để lọc voices: vieneu | edge | xtts | vbee
Response — Tiếng Việt (vi)
{
  "model":    "vieneu",
  "language": "vi",
  "count":    13,
  "voices": [
    {
      "id":           "Ngọc Lan",
      "name":         "Ngọc Lan",
      "gender":       "female",
      "region":       "south",
      "region_label": "Miền Nam",
      "provider":     "vieneu"
    },
    {
      "id":           "vi-VN-HoaiMyNeural",
      "name":         "Hoài My",
      "gender":       "female",
      "region":       "north",
      "region_label": "Miền Bắc",
      "provider":     "edge"
    }
  ]
}
Response — English (/voices?lang=en)
{
  "model":    "edge",
  "language": "en",
  "count":    14,
  "voices": [
    {
      "id":       "en-US-JennyNeural",
      "name":     "Jenny",
      "gender":   "female",
      "accent":   "en-US",
      "provider": "edge",
      "language": "en"
    },
    {
      "id":          "xtts_en_female",
      "name":        "Female (English)",
      "gender":      "female",
      "provider":    "xtts",
      "clone_voice": true
    }
  ]
}

GET /api/v1/languages New

Lấy danh sách ngôn ngữ được hỗ trợ cùng các model khả dụng cho mỗi ngôn ngữ.

Response
{
  "languages": [
    { "code": "vi", "name": "Tiếng Việt", "flag": "🇻🇳", "models": ["vieneu", "edge", "vbee"] },
    { "code": "en", "name": "English",    "flag": "🇬🇧", "models": ["edge", "xtts"] },
    { "code": "zh", "name": "中文",        "flag": "🇨🇳", "models": ["edge", "xtts"] },
    // … 11 more languages
  ]
}

GET /api/v1/models

Liệt kê các model TTS có sẵn, trạng thái cài đặt và model đang active.

Response
{
  "active_model": "edge",
  "models": [
    { "id": "vieneu",    "status": "active",      "is_active": false },
    { "id": "edge",      "status": "active",      "is_active": true  },
    { "id": "xtts",      "status": "active",      "is_active": false },
    { "id": "cosyvoice2", "status": "coming_soon", "is_active": false }
  ]
}

GET /health

Kiểm tra trạng thái server và model.

Response
{
  "status":       "ok",
  "active_model": "edge",
  "vieneu_ready": true,
  "timestamp":    "2026-06-20T10:30:00"
}

History, hồ sơ và cấu hình người dùng

Các endpoint dưới đây yêu cầu Authorization: Bearer <access_token>; dữ liệu chỉ trả về cho tài khoản hiện tại.

MethodEndpointMục đích
GET/api/v1/historyLịch sử audio của tài khoản.
GET/api/v1/history/{job_id}Metadata của một job audio.
DELETE/api/v1/history/{job_id}Xóa bản ghi/lưu trữ audio của chính bạn.
GET/api/v1/profileThông tin hồ sơ, plan và quota.
PUT/api/v1/profile/settingsCập nhật tuỳ chọn người dùng.
PUT/api/v1/profile/passwordĐổi mật khẩu.
PUT/api/v1/profile/change-planYêu cầu đổi plan.
GET/api/v1/ref-voicesDanh sách audio mẫu để clone.
POST/api/v1/ref-voicesLưu audio mẫu multipart (name, ref_audio).
DELETE/api/v1/ref-voices/{ref_id}Xóa audio mẫu của chính bạn.

ASR — speech to text

ASR nhận file audio multipart, giới hạn 100 MB. Có thể dùng Bearer token hoặc API Key.

Transcribe
curl -X POST https://iclever-tts.yez.vn/api/v1/asr/transcribe \
  -H 'X-API-Key: YOUR_API_KEY' \
  -F '[email protected]' -F 'language=vi'

# Status/model: GET /api/v1/asr/status

Danh mục endpoint đầy đủ

NhómEndpointsQuyền
Public/health, /api/v1/languages, /api/v1/models, /api/v1/plans, /api/v1/docs, /openapi.jsonKhông cần
AuthPOST /api/v1/auth/register, /login, /refresh; GET /meToken cho /me
TTSPOST /api/v1/synthesize, /clone; GET /voices, /ref-voicesAPI Key hoặc Bearer
ASRGET /api/v1/asr/status, POST /api/v1/asr/transcribeAPI Key hoặc Bearer
User/history, /profile, /profile/settings, /profile/password, /profile/change-planBearer
Admin/api/v1/keys, /api/v1/settings, /api/v1/model-profiles, /api/v1/admin/users, /api/v1/admin/stats, /api/v1/admin/history, /api/v1/admin/plansAdmin credential

POST /api/v1/keys Admin

Tạo API key mới. Cần header X-Admin-Key.

FieldKiểuRequiredMô tả
namestringRequiredTên ứng dụng / người dùng
emailstringOptionalEmail liên hệ
daily_limitintOptionalGiới hạn requests/ngày. Mặc định: 1000

PUT /api/v1/settings Admin

Thay đổi model active hoặc cấu hình Vbee. Cần header X-Admin-Key.

Switch active model
{
  "active_model": "edge"   // vieneu | edge | xtts | vbee
}
Cấu hình Vbee
{
  "vbee_config": {
    "app_id": "app_xxxx",
    "token": "eyJhbGci..."
  }
}

Ví dụ — Python

Python — Tiếng Việt (VieNeu)
import requests

API_BASE = "https://iclever-tts.yez.vn"
API_KEY  = "ick_your_key"
HEADERS  = {"X-API-Key": API_KEY, "Content-Type": "application/json"}

def synthesize(text, language="vi", voice_id=None, model=None):
    payload = {
        "text":     text,
        "language": language,   # "vi" | "en" | "zh" | "ja" | …
        "voice_id": voice_id,
        "model":    model,       # None = use active model
        "format":   "wav",
    }
    r = requests.post(f"{API_BASE}/api/v1/synthesize", json=payload, headers=HEADERS)
    r.raise_for_status()
    data = r.json()
    audio = requests.get(f"{API_BASE}{data['audio_url']}")
    with open("output.wav", "wb") as f:
        f.write(audio.content)
    return data

# Tiếng Việt — giọng Miền Bắc (Microsoft Neural)
synthesize("Xin chào, đây là iClever TTS.", language="vi", voice_id="vi-VN-HoaiMyNeural", model="edge")

# English — Jenny (American)
synthesize("Hello, this is iClever TTS.", language="en", voice_id="en-US-JennyNeural")

# Tiếng Trung — Phổ thông
synthesize("你好,这是 iClever TTS。", language="zh", voice_id="zh-CN-XiaoxiaoNeural")

# Lấy danh sách giọng cho tiếng Anh
r = requests.get(f"{API_BASE}/api/v1/voices", params={"lang": "en"}, headers=HEADERS)
voices = r.json()["voices"]

Ví dụ — JavaScript

JavaScript (fetch)
const API_BASE = 'https://iclever-tts.yez.vn';
const API_KEY  = 'ick_your_key';
const headers  = { 'Content-Type': 'application/json', 'X-API-Key': API_KEY };

async function synthesize({ text, language = 'vi', voiceId = null, model = null }) {
  const res = await fetch(`${API_BASE}/api/v1/synthesize`, {
    method: 'POST', headers,
    body: JSON.stringify({
      text,
      language,            // 'vi' | 'en' | 'zh' | 'ja' | 'ko' | …
      voice_id: voiceId,
      model,
      format: 'wav',
    }),
  });
  const data = await res.json();
  new Audio(`${API_BASE}${data.audio_url}`).play();
  return data;
}

// Tiếng Việt — giọng Nam Minh (Miền Bắc)
await synthesize({ text: 'Xin chào!', language: 'vi', voiceId: 'vi-VN-NamMinhNeural' });

// English — British male
await synthesize({ text: 'Hello from London.', language: 'en', voiceId: 'en-GB-RyanNeural' });

// 日本語
await synthesize({ text: 'こんにちは!', language: 'ja', voiceId: 'ja-JP-NanamiNeural' });

// Fetch English voices
const { voices } = await fetch(`${API_BASE}/api/v1/voices?lang=en`, { headers }).then(r => r.json());

Ví dụ — cURL

cURL — Tiếng Việt
curl -X POST https://iclever-tts.yez.vn/api/v1/synthesize \
  -H "Content-Type: application/json" \
  -H "X-API-Key: ick_your_key" \
  -d '{
    "text":     "Xin chào, đây là iClever TTS.",
    "language": "vi",
    "voice_id": "vi-VN-HoaiMyNeural",
    "model":    "edge",
    "format":   "wav"
  }'
cURL — English
curl -X POST https://iclever-tts.yez.vn/api/v1/synthesize \
  -H "Content-Type: application/json" \
  -H "X-API-Key: ick_your_key" \
  -d '{
    "text":     "Hello, this is iClever TTS.",
    "language": "en",
    "voice_id": "en-US-JennyNeural",
    "model":    "edge"
  }'
cURL — List voices by language
curl "https://iclever-tts.yez.vn/api/v1/voices?lang=zh" \
  -H "X-API-Key: ick_your_key"
cURL — Voice Cloning (English, XTTS v2)
curl -X POST https://iclever-tts.yez.vn/api/v1/clone \
  -H "X-API-Key: ick_your_key" \
  -F "text=This voice is cloned from a 6-second sample." \
  -F "language=en" \
  -F "model=xtts" \
  -F "ref_audio=@/path/to/sample.wav"