Developer Reference

REST API Documentation

Complete developer specifications for integrating Sonu AI native Hindi text-to-speech synthesis into web applications, mobile apps, and automated pipelines.

1. Authentication

All API requests to the voice synthesis endpoint and account management services require an authenticated API Key or JWT Bearer token in the request header.

Authorization: Bearer YOUR_API_KEY

You can generate and revoke API keys anytime from your Sonu AI Dashboard.

2. Unified Voice Endpoint

Synthesize Hindi and Devanagari text into crystal-clear 24kHz uncompressed audio.

POST https://sonuai.technoparticles.com/api/tts

Request Headers

HeaderTypeDescription
Authorization String Bearer token with your API Key (e.g., Bearer sonu_live_...)
Content-Type String Must be application/json
Accept String Optional. Defaults to audio/wav

Request Body Parameters

ParameterTypeRequiredDescription
text String Yes The Hindi or Devanagari script to synthesize (up to 5,000 characters per request).
speaker String Yes Voice model identifier: yash (Male) or charu (Female).

cURL Example

curl -X POST https://sonuai.technoparticles.com/api/tts \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "text": "नमस्ते! सोनू एआई में आपका स्वागत है।", "speaker": "yash" }' \ --output voice_sample.wav

Python (requests) Example

import requests url = "https://sonuai.technoparticles.com/api/tts" headers = { "Authorization": "Bearer YOUR_API_KEY", "Content-Type": "application/json" } payload = { "text": "नमस्ते! सोनू एआई में आपका स्वागत है।", "speaker": "charu" } response = requests.post(url, json=payload, headers=headers) if response.status_code == 200: with open("hindi_speech.wav", "wb") as f: f.write(response.content) print("Voice generated successfully!") else: print("Error:", response.json())

Node.js / JavaScript Example

const fs = require('fs'); async function generateSpeech() { const res = await fetch('https://sonuai.technoparticles.com/api/tts', { method: 'POST', headers: { 'Authorization': 'Bearer YOUR_API_KEY', 'Content-Type': 'application/json' }, body: JSON.stringify({ text: 'नमस्ते! सोनू एआई में आपका स्वागत है।', speaker: 'yash' }) }); if (!res.ok) { throw new Error(await res.text()); } const arrayBuffer = await res.arrayBuffer(); fs.writeFileSync('speech.wav', Buffer.from(arrayBuffer)); console.log('Audio file saved to speech.wav'); } generateSpeech();

3. Account & Management Endpoints

Manage programmatic credentials and query character quotas via the REST API.

MethodEndpointDescription
POST /auth/register Create a new user account with email and password
POST /auth/login Authenticate user credentials and receive a JWT
GET /api/v1/keys List all generated API keys for the authenticated account
POST /api/v1/keys Generate a new secret API key
DELETE /api/v1/keys/:id Revoke an existing API key immediately
GET /api/v1/usage Retrieve real-time character quota and consumption statistics

4. Error Codes & Rate Limits

Sonu AI returns standard HTTP response codes accompanied by a descriptive JSON payload when errors occur:

HTTP CodeConditionSolution
400 Bad Request Missing text or speaker parameter. Verify request JSON payload schema.
401 Unauthorized Invalid or missing API key in Authorization header. Verify your API key in the dashboard.
429 Too Many Requests Exceeded concurrent connection or character limits. Upgrade your plan or contact support for higher limits.
502 / 503 Gateway Voice AI synthesis model is temporarily unavailable. Retry with exponential backoff.