India's Universal Voice AI - Developer Documentation
Get started with SWAYAM in under a minute.
<script src="https://swayam.digimitra.guru/swayam-widget.js"
data-persona="swayam"
data-language="hi">
</script>
npm install @swayam/sdk
// JavaScript/TypeScript
import { Swayam } from '@swayam/sdk';
const swayam = new Swayam({
persona: 'wowtruck',
language: 'hi'
});
swayam.on('response', (text, audio) => {
console.log('AI:', text);
});
await swayam.connect();
await swayam.send('Delhi से Mumbai का route बताओ');
const ws = new WebSocket('wss://swayam.digimitra.guru/swayam');
ws.onopen = () => {
ws.send(JSON.stringify({
type: 'join',
sessionId: 'my_session',
userId: 'user_123',
language: 'hi',
persona: 'swayam'
}));
};
ws.onmessage = (event) => {
const msg = JSON.parse(event.data);
console.log('Response:', msg);
};
// Send text
ws.send(JSON.stringify({ type: 'text', text: 'नमस्ते' }));
Real-time bidirectional communication with voice AI.
| Type | Direction | Description |
|---|---|---|
join | Client → Server | Join session with language/persona |
text | Client → Server | Send text message |
audio | Client → Server | Send audio (Base64) |
tool | Client → Server | Execute MCP tool |
response | Server → Client | AI response with audio |
transcript | Server → Client | STT transcription |
tool_result | Server → Client | Tool execution result |
audio_chunk | Server → Client | Streaming TTS chunk |
{
"type": "join",
"sessionId": "unique_session_id",
"userId": "user_123",
"language": "hi", // See Languages section
"persona": "swayam", // See Personas section
"wakeWord": false, // Enable wake word detection
"streaming": true // Enable streaming TTS
}
Check service health and version.
Text-to-Speech synthesis.
// Request
{ "text": "नमस्ते", "language": "hi", "voice": "anushka" }
// Response
{ "audio": "base64...", "duration": 1.5, "voice": "anushka" }
List all available MCP tools.
Execute a specific MCP tool.
// Request
{ "tool": "gst_calc", "params": { "amount": 10000, "rate": 18 } }
// Response
{ "success": true, "result": { "totalAmount": "11800.00" } }
Get learning analytics and patterns.
Prometheus-compatible metrics.
8 specialized AI assistants for different use cases.
11 Indian languages with TTS and STT support.
Integrated tools for compliance, logistics, finance, and more.
gst_calc gst_verify hsn_lookup tds_calc income_tax pan_verify
emi_calc sip_calc calculator upi_send upi_verify
logistics_search logistics_route logistics_compliance distance_calc toll_estimate
fleet_vehicles vehicle_position drivers trips container_track
vehicle_verify fastag pm_kisan epf_balance pincode_info
npm install @swayam/sdk
import { useSwayam, SwayamWidget } from '@swayam/sdk/react';
function App() {
const { send, response, isConnected } = useSwayam({
persona: 'wowtruck',
language: 'hi'
});
return (
<div>
<p>{response}</p>
<button onClick={() => send('Hello')}>Send</button>
<SwayamWidget persona="swayam" language="hi" />
</div>
);
}
<script src="https://swayam.digimitra.guru/swayam-widget.js"></script>
<script>
SwayamWidget.open();
SwayamWidget.send('नमस्ते');
</script>