Qwen3-TTS OpenAI-Compatible API

February 1, 2026 ยท View on GitHub

Fork with Enhancements: This version adds 28 custom cloned voices, VRAM auto-unload for multi-GPU-app setups (Ollama, Kokoro TTS, etc.), and optimizations for NVIDIA RTX 50-series Blackwell GPUs.
See INTEGRATION_GUIDE.md for detailed usage.

An OpenAI-compatible FastAPI server for Qwen3-TTS, enabling drop-in replacement for OpenAI's TTS API. Built on the powerful Qwen3-TTS model by Alibaba Cloud.

Features

FeatureDescription
OpenAI API CompatibleDrop-in replacement for POST /v1/audio/speech
28 Custom VoicesPre-cloned voices for narration, audiobooks, assistants
VRAM Auto-UnloadFree GPU memory after inactivity for other apps
Voice CloningAdd your own voices with 3-10 second samples
10+ LanguagesEnglish, Chinese, Japanese, Korean, German, French, Spanish, Russian, Portuguese, Italian
Multiple FormatsMP3, Opus, AAC, FLAC, WAV, PCM
GPU OptimizedFlash Attention 2, torch.compile, TF32, BFloat16

Quick Start

Using OpenAI Python Client

from openai import OpenAI

client = OpenAI(
    base_url="http://localhost:8881/v1",
    api_key="not-needed"
)

response = client.audio.speech.create(
    model="tts-1",
    voice="Jarvis",  # Or any of the 28 custom voices
    input="Hello! This is your local TTS server speaking.",
    response_format="mp3"
)

response.stream_to_file("output.mp3")

Available Voices

Male: Jarvis, Paddington, Professor, Josh, John, Mark, Adam, Russell, Curt, Eustis, General_Joe, Grandpa, Nigel, Richard, Valentino, Wildebeest

Female: Lucy, Carmen, Caroline, Joanne, Victoria, Natasha, Bianca, Cecile, Emmaline, Monika, Tally, Villain

Deployment

# Clone and start
git clone https://github.com/YOUR_USERNAME/Qwen3-TTS-Openai-Fastapi.git
cd Qwen3-TTS-Openai-Fastapi

# Build and run with GPU
docker compose up -d qwen3-tts-gpu

# View logs
docker compose logs -f qwen3-tts-gpu

Environment Variables

VariableDefaultDescription
PORT8881Server port
TTS_BACKENDofficialBackend engine
TTS_MODEL_NAMEQwen/Qwen3-TTS-12Hz-1.7B-BaseModel to use
TTS_INACTIVITY_TIMEOUT_MINUTES15Auto-unload after idle (0=disabled)
VOICE_SAMPLES_DIR/app/voice-samplesCustom voice samples path

VRAM Management

The model uses ~4.5GB VRAM. Auto-unload frees memory when idle:

# Check status (shows idle time, countdown)
curl http://localhost:8881/health

# Manually free VRAM
curl -X POST http://localhost:8881/admin/unload

# Pre-load model
curl -X POST http://localhost:8881/admin/reload

API Endpoints

EndpointDescription
POST /v1/audio/speechGenerate speech (OpenAI-compatible)
GET /v1/modelsList available models
GET /v1/voicesList available voices
GET /healthHealth check with VRAM status
POST /admin/unloadManually unload model
POST /admin/reloadManually reload model
GET /docsSwagger UI documentation

Adding Custom Voices

  1. Prepare a 3-10 second clear audio sample (.wav)
  2. Name it VoiceName.wav and copy to sample-voices-xtts/
  3. Restart the container
  4. Use with voice="VoiceName"

Documentation

Credits

This project is built on the incredible work of the Qwen Team at Alibaba Cloud:

Citation

@article{Qwen3-TTS,
  title={Qwen3-TTS Technical Report},
  author={Hangrui Hu and Xinfa Zhu and Ting He and Dake Guo and Bin Zhang and Xiong Wang and Zhifang Guo and Ziyue Jiang and Hongkun Hao and Zishan Guo and Xinyu Zhang and Pei Zhang and Baosong Yang and Jin Xu and Jingren Zhou and Junyang Lin},
  journal={arXiv preprint arXiv:2601.15621},
  year={2026}
}

License

Apache 2.0 - See LICENSE