ChatBucket / Public API Documentation
ChatBucket AI Services API Documentation
This API reference covers the dedicated AI services hosted and routed via apiApp.ts (/stt, /tts, /translation, and /v1/ai-model), alongside real-time audio WebSocket streams.
| Channel | Base URL |
|---|---|
| Host Base URL (REST HTTP) | https://b2bapi.chatbucket.chat |
| WebSocket Streaming URL | wss://b2bapi.chatbucket.chat |
1. Authentication & API Key Usage
All endpoints exposed by apiApp.ts authenticate requests via HTTP header using either a Customer API Key, an AI Model Master Key, or a Bearer Token.
1.1 Authentication Header
Pass your API key in either of the following headers:
x-api-key: <YOUR_API_KEY>Or using Bearer authentication:
Authorization: Bearer <TOKEN>1.2 Creating and Managing Keys
Customer API keys are created and managed via the dashboard API key endpoints:
https://b2bapi.chatbucket.chat/api-keys/Returns the key formatted as cb_live_<hash> (with plaintext shown only once). You can also generate and revoke keys in API Keys.
2. Speech-to-Text Services (/stt)
Provides speech recognition for both global and regional Indian languages.
2.1 Get Supported STT Languages
/stt/languagesHeaders: x-api-key: <API_KEY>
curl -s -X GET "https://b2bapi.chatbucket.chat/stt/languages" \
-H "x-api-key: <API_KEY>"{
"status": true,
"data": [
{ "code": "en", "name": "English" },
{ "code": "hi", "name": "Hindi" },
{ "code": "te", "name": "Telugu" },
{ "code": "ta", "name": "Tamil" },
{ "code": "ml", "name": "Malayalam" },
{ "code": "kn", "name": "Kannada" },
{ "code": "mr", "name": "Marathi" },
{ "code": "gu", "name": "Gujarati" },
{ "code": "bn", "name": "Bengali" },
{ "code": "es", "name": "Spanish" },
{ "code": "fr", "name": "French" },
{ "code": "de", "name": "German" }
]
}2.2 Transcribe Audio File
/stt/transcribe| Parameter / Header | Type | Description |
|---|---|---|
x-api-key | Header | Your API key (<API_KEY>). |
Content-Type | Header | multipart/form-data |
audio | Form file (required) | Audio file binary to transcribe. |
language | Form field | Language code (e.g. en, hi, te, ta, etc.). Default: en. |
curl -s -X POST "https://b2bapi.chatbucket.chat/stt/transcribe" \
-H "x-api-key: <API_KEY>" \
-F "audio=@sample.wav" \
-F "language=hi"{
"status": true,
"data": {
"transcript": "नमस्ते, मैं आपकी क्या सहायता कर सकता हूँ?",
"confidence": 0.985,
"words": [
{ "word": "नमस्ते", "start": 0.12, "end": 0.65, "confidence": 0.99 },
{ "word": "मैं", "start": 0.70, "end": 0.90, "confidence": 0.98 },
{ "word": "आपकी", "start": 0.95, "end": 1.25, "confidence": 0.98 }
],
"duration_seconds": 3.4
}
}3. Text-to-Speech Services (/tts)
Provides conversational neural speech synthesis and streaming audio generation.
3.1 Get Supported TTS Languages & Voices
Get Languages
/tts/languagescurl -s -X GET "https://b2bapi.chatbucket.chat/tts/languages" \
-H "x-api-key: <API_KEY>"Get Voices
/tts/voicescurl -s -X GET "https://b2bapi.chatbucket.chat/tts/voices" \
-H "x-api-key: <API_KEY>"{
"status": true,
"data": [
{
"voiceId": "en-US-marcus",
"displayName": "Marcus",
"gender": "male",
"locale": "en-US",
"styles": ["Conversational", "News"]
},
{
"voiceId": "hi-IN-aditi",
"displayName": "Aditi",
"gender": "female",
"locale": "hi-IN",
"styles": ["Conversational"]
}
]
}3.2 Synthesize Speech Stream
Streams real-time MP3 chunks directly in the response body for immediate audio playback.
/tts/streamHeaders: Content-Type: application/json, x-api-key: <API_KEY>
curl -s -X POST "https://b2bapi.chatbucket.chat/tts/stream" \
-H "Content-Type: application/json" \
-H "x-api-key: <API_KEY>" \
-d '{
"text": "Hello, welcome to ChatBucket intelligent voice support.",
"voiceId": "en-US-marcus",
"language": "en-US",
"pitch": 0,
"rate": 0
}' --output audio_stream.mp3HTTP/1.1 200 OK
Content-Type: audio/mpeg
Transfer-Encoding: chunked3.3 Synthesize Speech File
Generates audio and uploads the file to object storage, returning an audio URL.
/tts/generateHeaders: Content-Type: application/json, x-api-key: <API_KEY>
curl -s -X POST "https://b2bapi.chatbucket.chat/tts/generate" \
-H "Content-Type: application/json" \
-H "x-api-key: <API_KEY>" \
-d '{
"text": "Thank you for reaching out. Your order has been placed.",
"voiceId": "hi-IN-aditi",
"language": "hi-IN"
}'{
"status": true,
"data": {
"audioUrl": "https://chatbucketcdn.lon1.digitaloceanspaces.com/audio/tts_generated_672f01a9b.mp3",
"duration_seconds": 3.8
}
}4. Translation Services (/translation)
High-performance neural text translation between Indic and global languages.
4.1 Get Supported Translation Languages
/translation/languagesHeaders: x-api-key: <API_KEY>
curl -s -X GET "https://b2bapi.chatbucket.chat/translation/languages" \
-H "x-api-key: <API_KEY>"4.2 Translate Text
/translation/translate| Field | Type | Description |
|---|---|---|
text | string | Input text string to translate. |
source_language | string | Source language code (e.g. en). |
target_language | string | Target language code (e.g. hi). |
curl -s -X POST "https://b2bapi.chatbucket.chat/translation/translate" \
-H "Content-Type: application/json" \
-H "x-api-key: <API_KEY>" \
-d '{
"text": "Hello, how can I help you today?",
"source_language": "en",
"target_language": "hi"
}'{
"status": true,
"data": {
"translated_text": "नमस्ते, आज मैं आपकी क्या सहायता कर सकता हूँ?",
"source_language": "en",
"target_language": "hi",
"character_count": 32
}
}5. AI Model Orchestration Services (/v1/ai-model)
Internal and edge gateway services for voice agents, manual agent inspection, and usage settlement.
5.1 Inspect Human Agents & Live Call Diversion
/v1/ai-model/agent/human-agentsHeaders: x-api-key: <API_KEY> (Legacy alias /v1/ai-model/agent/manual-agents also supported)
curl -s -X POST "https://b2bapi.chatbucket.chat/v1/ai-model/agent/human-agents" \
-H "Content-Type: application/json" \
-H "x-api-key: <API_KEY>" \
-d '{
"agent_id": "6aeced1ba8c775486649d425"
}'{
"status": "success",
"widget_id": "6aeced1ba8c775486649d425",
"agent_id": "6aeced1ba8c775486649d425",
"human_agents_count": 1,
"available_agents_count": 1,
"available_for_call_count": 1,
"human_agents": [
{
"human_agent_id": "6aee05284b712c98d0ef11aa",
"member_id": "6aee05284b712c98d0ef11aa",
"user_id": "6aee05284b712c98d0ef11ab",
"name": "Priya Sharma",
"display_name": "Priya Sharma",
"phone": "+919876543210",
"role": "agent",
"department_id": "dep_billing",
"department_name": "Billing",
"status": "active",
"is_available": true,
"can_take_call": true,
"active_chats": 1,
"active_calls": 0,
"max_concurrent": 4
}
]
}5.2 Report AI Usage & Deduct Balance
/v1/ai-model/usage| Field | Example | Description |
|---|---|---|
agent_id | 6aeced1ba8c775486649d425 | Target voice/AI agent identifier. |
amount | 2.50 | Usage cost to deduct from account balance. |
service | voice_agent | Service category identifier. |
quantity | 90 | Measured consumption quantity. |
unit | seconds | Unit of measurement. |
session_id | call_12345 | Associated call or conversation session ID. |
curl -s -X POST "https://b2bapi.chatbucket.chat/v1/ai-model/usage" \
-H "Content-Type: application/json" \
-H "x-api-key: <API_KEY>" \
-d '{
"agent_id": "6aeced1ba8c775486649d425",
"amount": 2.50,
"service": "voice_agent",
"quantity": 90,
"unit": "seconds",
"session_id": "call_12345"
}'{
"status": "success",
"message": "Usage recorded and balance deducted successfully",
"deducted_amount": 2.50,
"remaining_balance": 97.50
}6. Real-Time WebSocket Streaming
Mounted to the same HTTP server alongside apiApp.ts for low-latency audio streaming and call signaling.
6.1 Real-Time STT Microphone Stream
wss://b2bapi.chatbucket.chat/stt/stream| Query Parameter | Values / Example | Description |
|---|---|---|
api_key | <YOUR_API_KEY> | Your ChatBucket API key. |
language | en, hi, te, etc. | Target speech recognition language code. |
interim_results | true or false | Whether to emit partial interim transcription frames while speaking. |
Clients stream raw audio binary buffers (e.g., 16kHz 16-bit PCM) over this WebSocket and receive real-time transcription frames.
6.2 Voice WebRTC Stream Bridging
wss://b2bapi.chatbucket.chat/v1/voice/webrtc/stream| Query Parameter | Values / Example | Description |
|---|---|---|
role | user or agent | Participant role on the stream bridge. |
user_id | Visitor ID | Unique identifier of the connecting visitor. |
human_agent_id | Human Agent ID | Assigned human support teammate identifier (legacy alias: agent_id). |
voice_agent_id | Voice Agent ID | Target AI voice agent / widget identifier. |
call_id | Active Call Session ID | Call session identifier returned by signaling. |
Bridges bi-directional raw audio packets and WebRTC signaling frames directly between the visitor and the assigned manual agent.