Skip to main content

Endpoint

POST https://api.samuraiapi.in/v1/audio/speech

Parameters

ParameterTypeRequiredDescription
modelstringtts-1 or tts-1-hd
inputstringText to convert (max 4096 chars)
voicestringVoice preset (see below)
response_formatstringmp3 (default), opus, aac, flac, wav
speednumberSpeed: 0.25–4.0. Default: 1.0

Available Voices

VoiceCharacter
alloyNeutral, versatile
echoMale, authoritative
fableBritish, storytelling
onyxDeep, powerful
novaFemale, friendly
shimmerFemale, 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

ModelQualityLatencyPrice
tts-1StandardLower$7.50/1M chars
tts-1-hdHigh fidelityHigher$15/1M chars
Samurai AI prices are 50% off. tts-1 is $3.75/1M characters.