POST
request. This API is available for users subscribed to a paid plan and provides a way to communicate with your chatbot programmatically.
Authorization: Bearer <Your-Secret-Key>
- The secret key for authenticating the API request.Content-Type: application/json
- The content type of the request payload.messages
(array, required): An array containing the ALL the messages between the user and the assistant. Each message object should have content
and role
properties. The content
field represents the text content of the message, and the role
field can be either “user” or “assistant” to indicate the sender of the message.
chatbotId
(string, required): Refers to the ID of the chatbot you want to interact with (found on the chatbot settings page).
stream
(boolean, optional, defaults to false): A boolean value indicating whether to stream back partial progress or wait for the full response. If set to true
, words will be sent back as data-only server-sent events as they become available, with the stream terminated by a data: [DONE]
message. If set to false
, the full response will be returned once it’s ready.
temperature
(number, optional, defaults to 0): What sampling temperature to use, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.
conversationId
(string, optional): This refers to the ID of the current conversation. Its sole purpose is to save the conversation to the chatbot dashboard. If it’s not provided, the conversation won’t be saved. You should generate this ID on your end. Use a unique ID for each conversation, and make sure to reuse the same ID for all requests within the same conversation. Each time you send a message using a specific chatbotId, the last message in the messages array and the response will be appended to that conversation.
model
(string, optional): If this is added to the body, it takes precedence over the model set in the chatbot settings. If not set, the model set in the chatbot settings is used. The option for ‘gpt-4 | gpt-4-turbo’ only works on the Standard and the Unlimited plans.
o4-mini
| o3
| gpt-4.1
| gpt-4.1-mini
| gpt-4.1-nano
| gpt-4.5
| gpt-4o
| gpt-4o-mini
| gpt-4-turbo
| gpt-4
| o3-mini
claude-sonnet-4
| claude-opus-4
|claude-3-7-sonnet
| claude-3-5-sonnet
| claude-3-opus
| claude-3-haiku
gemini-1.5-pro
| gemini-1.5-flash
| gemini-2.0-flash
| gemini-2.0-pro
command-r
| command-r-plus
DeepSeek-V3
| DeepSeek-R1
Llama-4-Scout-17B-16E-Instruct
| Llama-4-Maverick-17B-128E-Instruct-FP8
grok-3
| grok-3-mini
stream
parameter is set to true
, words will be sent back as data-only server-sent events as they become available. To read the stream, you can use the following code snippets:
conversationId
parameter needs to be included in the request body. The full conversation needs to be sent on every API call because Chatbase doesn’t save previous messages. The messages received in the latest API call for a given conversationId
overrides the conversation already saved there.