Developer

AC Labs API

Tạo audio tiếng Việt bằng cùng quota và accounting với AC Labs Studio.

API Beta · Cập nhật 27/07/2026

Tạo API token trong trang Tài khoản. Raw token chỉ hiển thị một lần; không đưa token vào frontend hoặc repository.

Authentication

Authorization: Bearer ac_live_… Content-Type: application/json Idempotency-Key: UUID-v4

Scope cần thiết: tts:generate. Tái sử dụng cùng idempotency key khi retry cùng một yêu cầu để tránh double-charge.

POST/api/tts

Tạo audio đồng bộ. Mỗi API request tối đa 500 ký tự; Studio tự chia tối đa 450 ký tự/chunk cho nội dung dài.

Request body

FieldLoạiMô tả
textstring1–500 ký tự.
voicestringan-nhien, minh-khang, ha-lam, gia-han, quoc-bao, mai-anh, duc-anh, bao-ngoc.
stylestringnatural, emotional hoặc short.
outputFormatstringmp3 hoặc wav; mặc định wav.

JavaScript

const response = await fetch('https://aclabs.app/api/tts', { method: 'POST', headers: { 'Authorization': `Bearer ${AC_LABS_TOKEN}`, 'Content-Type': 'application/json', 'Idempotency-Key': crypto.randomUUID() }, body: JSON.stringify({ text: 'Xin chào từ AC Labs.', voice: 'an-nhien', style: 'natural', outputFormat: 'mp3' }) }); if (!response.ok) throw new Error(`TTS failed: ${response.status}`); const audio = await response.arrayBuffer();

Response và lỗi

Thành công trả binary audio/mpeg hoặc audio/wav. Mã lỗi: 400 input sai; 401 token sai/hết hạn; 402 thiếu credits; 403 thiếu scope; 409 idempotency conflict; 429 rate limit; 502/503 dịch vụ audio tạm lỗi và được refund nếu đã reserve.

Dự án nội dung dài

Project API dành cho authenticated web session, không nằm trong scope tts:generate. Dùng Studio để tạo project, retry chunk và đóng gói ZIP trên thiết bị.