API
Create chatbot #
In this guide, we will walk through the process of creating a chatbot using an API.
Prerequisites #
Before you begin, make sure you have the following:
- An API key for accessing the Chatsistant API.
- A development environment or tool for making HTTP requests, such as Curl or a programming language like Python.
API Endpoint #
The API endpoint for creating a chatbot is:
https://app.chatsistant.com/api/v1/chatbot/create
Request Body #
To create a chatbot, you need to send a POST request to the API endpoint with a JSON request body. Here’s an example request body:
{
"model": "gpt-3.5-turbo",
"name": "Your Chatbot's Name",
"prompt": "A sample prompt for your chatbot.",
"rate_limit": [
20,
240
],
"rate_limit_message": "Too many messages",
"show_citations": false,
"temperature": 0,
"visibility": "private"
}
model (string, optional): Specify the model you want to use. In this example, we’re using gpt-3.5-turbo.
Options available: gpt-3.5-turbo, gpt-3.5-turbo-16k, gpt-4
name (string, required): Provide a name for your chatbot.
prompt (string, optional): You can provide an initial prompt for your chatbot.
rate_limit (array, optional): Set the rate limit for the chatbot in messages per minute. It’s an array with two values: [20, 240].
First number: amount of messages. Min 1 – Max 100
Second number: amount of seconds. Min 1 – Max 360
rate_limit_message (string, optional): Define a message to display when the rate limit is exceeded.
show_citations (boolean, optional): Set to true if you want the chatbot to show citations for its responses.
temperature (float, optional): You can adjust the temperature parameter for response randomness. A value of 0 makes responses deterministic, while higher values increase randomness.
Options are values as a float between 0 and 1
visibility (string, optional): Set the visibility of your chatbot.
Options available: private, public, hybrid
Example Request #
Here’re example commands to create a chatbot using the Chatsistant API:
Replace <token>
with your actual API key.
Curl #
curl -X POST https://app.chatsistant.com/api/v1/chatbot/create \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <token>" \
-d '{
"model": "gpt-3.5-turbo",
"name": "Your Chatbot Name",
"prompt": "A sample prompt for your chatbot.",
"rate_limit": [
20,
240
],
"rate_limit_message": "Too many messages",
"show_citations": false,
"temperature": 0,
"visibility": "private"
}'
Python #
import requests
url = 'https://app.chatsistant.com/api/v1/chatbot/create'
headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer <token>'
}
data = {
"model": "gpt-3.5-turbo",
"name": "Your Chatbot Name",
"prompt": "A sample prompt for your chatbot.",
"rate_limit": [
20,
240
],
"rate_limit_message": "Too many messages",
"show_citations": false,
"temperature": 0,
"visibility": "private"
}
response = requests.post(url, headers=headers, json=data)
if response.status_code == 200:
print("Request successful!")
print(response.json())
else:
print("Request failed with status code:", response.status_code)
print(response.text)
JavaScript (Axios) #
const axios = require('axios');
const url = 'https://app.chatsistant.com/api/v1/chatbot/create';
const headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer <token>'
};
const data = {
"model": "gpt-3.5-turbo",
"name": "Your Chatbot Name",
"prompt": "A sample prompt for your chatbot.",
"rate_limit": [
20,
240
],
"rate_limit_message": "Too many messages",
"show_citations": false,
"temperature": 0,
"visibility": "private"
};
axios.post(url, data, { headers })
.then(response => {
console.log('Request successful!');
console.log(response.data);
})
.catch(error => {
console.error('Request failed:', error);
});
That’s it! You’ve now learned how to create your own chatbot using the Chatsistant API.