AICredits logo
API

Audio

Convert text to lifelike speech and transcribe audio to text. OpenAI-compatible endpoints with support for Sarvam AI Indian language voices.

Use this page with an AI assistant

Opens a new chat with this docs URL and the correct AICredits base URLs.

Convert text to lifelike speech and transcribe audio to text using OpenAI-compatible endpoints. Both /audio/speech and /audio/transcriptions are available with costs charged in INR from your wallet.

Overview

EndpointMethodDescription
/audio/speechPOSTText-to-speech — returns raw audio bytes
/audio/transcriptionsPOSTSpeech-to-text — returns a transcript

Both endpoints are compatible with the OpenAI SDK. Point your client at https://api.aicredits.in/v1 and your existing audio code works without changes.

Text-to-Speech

Send text and receive an audio file. The response is raw audio bytes — write them directly to a file or stream them to a media player.

from pathlib import Path
from openai import OpenAI

client = OpenAI(
    base_url="https://api.aicredits.in/v1",
    api_key="sk-your-key-here",
)

response = client.audio.speech.create(
    model="openai/tts-1",
    voice="alloy",
    input="Hello! Welcome to AICredits, your unified LLM gateway.",
)

Path("speech.mp3").write_bytes(response.content)
import OpenAI from "openai";
import fs from "fs";

const client = new OpenAI({
  baseURL: "https://api.aicredits.in/v1",
  apiKey: "sk-your-key-here",
});

const response = await client.audio.speech.create({
  model: "openai/tts-1",
  voice: "alloy",
  input: "Hello! Welcome to AICredits, your unified LLM gateway.",
});

const buffer = Buffer.from(await response.arrayBuffer());
fs.writeFileSync("speech.mp3", buffer);
curl https://api.aicredits.in/v1/audio/speech \
  -H "Authorization: Bearer sk-your-key-here" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/tts-1",
    "voice": "alloy",
    "input": "Hello! Welcome to AICredits, your unified LLM gateway."
  }' \
  --output speech.mp3

TTS Parameters

ParameterTypeDescription
modelstring (required)openai/tts-1 for speed, openai/tts-1-hd for quality
inputstring (required)Text to synthesize. Maximum 4096 characters.
voicestring (required)One of: alloy, echo, fable, onyx, nova, shimmer
response_formatstringDefault: mp3. Also supports opus, aac, flac.

Voices

VoiceCharacter
alloyNeutral and balanced — good all-purpose default
echoClear and crisp — well-suited for narration
fableExpressive and warm — great for storytelling
onyxDeep and authoritative — strong, confident tone
novaFriendly and upbeat — energetic, conversational
shimmerSoft and gentle — calm, soothing delivery

Transcription

Transcribe audio files to text using Whisper:

from openai import OpenAI

client = OpenAI(
    base_url="https://api.aicredits.in/v1",
    api_key="sk-your-key-here",
)

response = client.audio.transcriptions.create(
    model="openai/whisper-1",
    file=("audio.mp3", open("audio.mp3", "rb"), "audio/mp3"),
)

print(response.text)
AUDIO_B64=$(base64 -i audio.mp3)

curl https://api.aicredits.in/v1/audio/transcriptions \
  -H "Authorization: Bearer sk-your-key-here" \
  -H "Content-Type: application/json" \
  -d "{
    \"model\": \"openai/whisper-1\",
    \"input_audio\": {
      \"data\": \"$AUDIO_B64\",
      \"format\": \"mp3\"
    }
  }"

Transcription Parameters

ParameterTypeDescription
modelstring (required)openai/whisper-1 is currently supported
input_audio.datastring (required)Base64-encoded audio content
input_audio.formatstring (required)mp3, mp4, mpeg, mpga, m4a, wav, webm
languagestringISO-639-1 code (e.g. en, hi). Auto-detected if omitted.

Sarvam AI — Indian Languages

Sarvam AI is an India-first voice provider specialising in Indian languages. AICredits routes sarvam/bulbul-v2 and sarvam/bulbul-v3 (TTS) and sarvam/saarika-v2 (STT) directly to the Sarvam API — no extra setup beyond your AICredits key.

Sarvam voices are called speakers and use Indian names (e.g. anushka, rahul). Pass the speaker name in the voice field — or use an OpenAI alias (alloy, nova, etc.) and AICredits maps it to a Sarvam speaker automatically.

Sarvam TTS

Hindi TTS with Sarvam
curl https://api.aicredits.in/v1/audio/speech \
  -H "Authorization: Bearer sk-your-key-here" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "sarvam/bulbul-v2",
    "input": "नमस्ते, आप कैसे हैं?",
    "voice": "anushka"
  }' \
  --output speech.wav

Sarvam STT

Hindi transcription with Sarvam
AUDIO_B64=$(base64 -i speech.wav)

curl https://api.aicredits.in/v1/audio/transcriptions \
  -H "Authorization: Bearer sk-your-key-here" \
  -H "Content-Type: application/json" \
  -d "{
    \"model\": \"sarvam/saarika-v2\",
    \"input_audio\": {
      \"data\": \"$AUDIO_B64\",
      \"format\": \"wav\"
    },
    \"language\": \"hi-IN\"
  }"

OpenAI Voice Alias Mapping

OpenAI AliasSarvam Speaker
alloyanushka
echoabhilash
fablearya
onyxkarun
novapriya
shimmershreya

All available Sarvam speakers: anushka, abhilash, manisha, vidya, arya, karun, hitesh, aditya, ritu, priya, neha, rahul, pooja, rohan, simran, kavya, amit, dev, ishita, shreya, ratan, varun, and more.

Language Codes

Pass a BCP-47 language code for Sarvam models. Defaults to hi-IN if omitted:

CodeLanguage
hi-INHindi
en-INEnglish (India)
bn-INBengali
gu-INGujarati
kn-INKannada
ml-INMalayalam
mr-INMarathi
pa-INPunjabi
ta-INTamil
te-INTelugu

Models

Use the right model for the right endpoint

TTS models only work with /audio/speech. Transcription models only work with /audio/transcriptions. Mixing them returns an error.

Text-to-Speech — use with /audio/speech:

Model IDBest For
openai/tts-1Low latency, real-time synthesis
openai/tts-1-hdHigher quality audio — podcasts, voiceovers
sarvam/bulbul-v2Indian language TTS — 12 languages, 44 speakers

Transcription — use with /audio/transcriptions:

Model IDBest For
openai/whisper-1Multilingual speech recognition and translation
sarvam/saarika-v2Indian language STT — optimised for Indian accents

Billing

ModelUnitRate (USD)
openai/tts-1Per 1K characters$0.015
openai/tts-1-hdPer 1K characters$0.030
openai/whisper-1Per minute of audio$0.006
sarvam/bulbul-v2Per requestINR-native pricing
sarvam/saarika-v2Per second of audioINR-native pricing

Error Handling

StatusCause
400Missing required field (model, input, or voice)
400Input exceeds 4096 characters
402Insufficient wallet balance
429Rate limit exceeded — audio requests count toward your RPM limit
502All upstream providers failed — retry with exponential backoff

On this page