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.

Base service URLs
ChannelBase URL
Host Base URL (REST HTTP)https://b2bapi.chatbucket.chat
WebSocket Streaming URLwss://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 header
x-api-key: <YOUR_API_KEY>

Or using Bearer authentication:

Authorization header
Authorization: Bearer <TOKEN>

1.2 Creating and Managing Keys

Customer API keys are created and managed via the dashboard API key endpoints:

POSThttps://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

GET/stt/languages

Headers: x-api-key: <API_KEY>

Request (cURL)
curl -s -X GET "https://b2bapi.chatbucket.chat/stt/languages" \
  -H "x-api-key: <API_KEY>"
Response (HTTP 200 OK)
{
  "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

POST/stt/transcribe
STT transcribe request headers & form parameters
Parameter / HeaderTypeDescription
x-api-keyHeaderYour API key (<API_KEY>).
Content-TypeHeadermultipart/form-data
audioForm file (required)Audio file binary to transcribe.
languageForm fieldLanguage code (e.g. en, hi, te, ta, etc.). Default: en.
Request (cURL)
curl -s -X POST "https://b2bapi.chatbucket.chat/stt/transcribe" \
  -H "x-api-key: <API_KEY>" \
  -F "audio=@sample.wav" \
  -F "language=hi"
Response (HTTP 200 OK)
{
  "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

GET/tts/languages
Request (cURL)
curl -s -X GET "https://b2bapi.chatbucket.chat/tts/languages" \
  -H "x-api-key: <API_KEY>"

Get Voices

GET/tts/voices
Request (cURL)
curl -s -X GET "https://b2bapi.chatbucket.chat/tts/voices" \
  -H "x-api-key: <API_KEY>"
Response (HTTP 200 OK)
{
  "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.

POST/tts/stream

Headers: Content-Type: application/json, x-api-key: <API_KEY>

Request (cURL)
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.mp3
Response Headers
HTTP/1.1 200 OK
Content-Type: audio/mpeg
Transfer-Encoding: chunked

3.3 Synthesize Speech File

Generates audio and uploads the file to object storage, returning an audio URL.

POST/tts/generate

Headers: Content-Type: application/json, x-api-key: <API_KEY>

Request (cURL)
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"
  }'
Response (HTTP 200 OK)
{
  "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

GET/translation/languages

Headers: x-api-key: <API_KEY>

Request (cURL)
curl -s -X GET "https://b2bapi.chatbucket.chat/translation/languages" \
  -H "x-api-key: <API_KEY>"

4.2 Translate Text

POST/translation/translate
Translation request fields
FieldTypeDescription
textstringInput text string to translate.
source_languagestringSource language code (e.g. en).
target_languagestringTarget language code (e.g. hi).
Request (cURL)
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"
  }'
Response (HTTP 200 OK)
{
  "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

GET / POST/v1/ai-model/agent/human-agents

Headers: x-api-key: <API_KEY> (Legacy alias /v1/ai-model/agent/manual-agents also supported)

Request (cURL)
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"
  }'
Response (HTTP 200 OK)
{
  "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

POST/v1/ai-model/usage
Usage settlement payload fields
FieldExampleDescription
agent_id6aeced1ba8c775486649d425Target voice/AI agent identifier.
amount2.50Usage cost to deduct from account balance.
servicevoice_agentService category identifier.
quantity90Measured consumption quantity.
unitsecondsUnit of measurement.
session_idcall_12345Associated call or conversation session ID.
Request (cURL)
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"
  }'
Response (HTTP 200 OK)
{
  "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

WSSwss://b2bapi.chatbucket.chat/stt/stream
STT stream query parameters
Query ParameterValues / ExampleDescription
api_key<YOUR_API_KEY>Your ChatBucket API key.
languageen, hi, te, etc.Target speech recognition language code.
interim_resultstrue or falseWhether 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

WSSwss://b2bapi.chatbucket.chat/v1/voice/webrtc/stream
WebRTC stream query parameters
Query ParameterValues / ExampleDescription
roleuser or agentParticipant role on the stream bridge.
user_idVisitor IDUnique identifier of the connecting visitor.
human_agent_idHuman Agent IDAssigned human support teammate identifier (legacy alias: agent_id).
voice_agent_idVoice Agent IDTarget AI voice agent / widget identifier.
call_idActive Call Session IDCall session identifier returned by signaling.

Bridges bi-directional raw audio packets and WebRTC signaling frames directly between the visitor and the assigned manual agent.