Chat API Documentation
Overview
The Chat API facilitates the retrieval of chatbots and enables users to interact with them by posting messages.
Base URL
https://app.openspokenai.com/api
Authentication
Clients must authenticate with a Basic Authorization header for each request:
Authorization: Basic {authString}
Where {authString} is the base64-encoded string of the format username:password.
Example usage:
curl -X GET “https://app.openspokenai.com/api/chat” -H “Authorization: Basic {authString}”
Endpoints
GET /chat
Retrieve a list of active chats available for interaction.
Query Parameters:
group (optional): Filter chats by a specified group.
Successful Response:
{
“message”: “success”,
“data”: [
{
“name”: “string”,
“chat_code”: “string”,
“description”: “string”,
“group”: “string”
}
]
}
No Content Found:
{
“message”: “error”,
“data”: {
“message”: “No chatbot found for the specified group.”
}
}
POST /chat
Send a message to a specific chat and receive a response.
Headers:
Content-Type: application/json
Authorization: Basic {authString}
Required Payload:
prompt: (string) The input text for the chat response.
request_id: (string) A unique ID to track the request.
webhook_url (optional): (URL) The endpoint to which the response should be sent via webhook.
Successful Response:
{
“message”: “success”,
“data”: {
“request_id”: “string”,
“message”: “string”
}
}
Error Responses:
Insufficient credits:
{
“message”: “error”,
“data”: {
“message”: “You have run out of credits to generate words. Please top up and try again.”
}
}
Chatbot not found:
{
“message”: “error”,
“data”: {
“message”: “Chatbot not found.”
}
}
Webhook failure:
{
“message”: “error”,
“data”: {
“message”: “Failed to send response to webhook.”
}
}