Audio

Text-to-speech and transcription (Whisper) endpoints for generating audio from text and converting audio files to text.

Tchavi supports two audio endpoints: text-to-speech (TTS) for generating audio from text, and transcription (Whisper) for converting audio files to text.

Text-to-Speech

POST/v1/audio/speech

Converts text to spoken audio. Returns raw audio bytes.

ParameterTypeRequiredDescription
modelstringYes"tts-1" (faster) or "tts-1-hd" (higher quality)
inputstringYesThe text to convert to speech (max 4096 characters)
voicestringYesalloy, ash, ballad, cedar, coral, echo, fable, marin, nova, onyx, sage, shimmer
response_formatstringNomp3, opus, aac, flac, wav, pcm. Default: mp3
speednumberNoPlayback speed 0.25–4.0. Default: 1.0
import Tchavi from '@tchavi/sdk';
import { writeFileSync } from 'fs';

const client = new Tchavi({ apiKey: 'YOUR_API_KEY' });

const response = await client.audio.speech.create({
  model: 'tts-1',
  input: 'Tchavi is the best AI API gateway in Africa.',
  voice: 'nova',
  response_format: 'mp3',
});

const buffer = Buffer.from(await response.arrayBuffer());
writeFileSync('speech.mp3', buffer);

Transcription (Whisper)

POST/v1/audio/transcriptions

Transcribes audio files to text. Send as multipart/form-data.

ParameterTypeRequiredDescription
modelstringYes"whisper-1"
filefileYesAudio file (mp3, wav, m4a, webm, ogg…). Max 25MB
languagestringNoISO-639-1 code (e.g. "fr", "en"). Auto-detected if omitted
response_formatstringNojson, text, srt, vtt, verbose_json. Default: json
promptstringNoOptional text to guide the model's style or continue a previous segment. Must match the audio language.
temperaturenumberNoSampling temperature 0–1. Higher values yield more varied transcriptions. Default: 0
import Tchavi from '@tchavi/sdk';
import { createReadStream } from 'fs';

const client = new Tchavi({ apiKey: 'YOUR_API_KEY' });

const result = await client.audio.transcriptions.create({
  model: 'whisper-1',
  file: createReadStream('audio.mp3'),
  language: 'fr',
});

console.log(result.text);
console.log('Duration:', result.tchavi.duration_minutes, 'min');
console.log('Credits used:', result.tchavi.credits_used);

On this page