Endpoint
POST https://api.samuraiapi.in/v1/audio/speech
Parameters
| Parameter | Type | Required | Description |
|---|
model | string | ✅ | tts-1 or tts-1-hd |
input | string | ✅ | Text to convert (max 4096 chars) |
voice | string | ✅ | Voice preset (see below) |
response_format | string | — | mp3 (default), opus, aac, flac, wav |
speed | number | — | Speed: 0.25–4.0. Default: 1.0 |
Available Voices
| Voice | Character |
|---|
alloy | Neutral, versatile |
echo | Male, authoritative |
fable | British, storytelling |
onyx | Deep, powerful |
nova | Female, friendly |
shimmer | Female, soft |
Code Examples
from openai import OpenAI
from pathlib import Path
client = OpenAI(
api_key="sk-samurai-YOUR_KEY",
base_url="https://api.samuraiapi.in/v1"
)
response = client.audio.speech.create(
model="tts-1-hd",
voice="nova",
input="The way of the samurai is found in death. Meditation on inevitable death...",
speed=0.9
)
response.stream_to_file(Path("output.mp3"))
print("Saved to output.mp3")
Models
| Model | Quality | Latency | Price |
|---|
tts-1 | Standard | Lower | $7.50/1M chars |
tts-1-hd | High fidelity | Higher | $15/1M chars |
Samurai AI prices are 50% off. tts-1 is $3.75/1M characters.