This is an Express API that provides various endpoints to build applications that can generate text completion and speech synthesis using the OpenAI's GPT-3 model and the VoiceRSS API.
The API is hosted on Heroku. So you can use it without having to install it locally.
Base URL: https://api-nova-voicebot.herokuapp.com
Here's a list of all the available endpoints:
This endpoint returns a welcome message to confirm that the API is up and running.
GET /
Welcome to the NOVA API!
- This endpoint takes in a request body containing a text prompt and returns the completion of that prompt using the OpenAI's GPT-3 model.
POST /api/completion
Content-Type: application/json
Authorization: Bearer <token>
{
"prompt": string;
"user": string;
}
Accept: application/json
{
"success": true;
"completion": {
"id": string;
"object": "text_completion",
"created": number;
"model": "text-davinci-003",
"choices": [
{
"text": string; # The actual completion
"index": 0,
"logprobs": null,
"finish_reason": string;
}
],
"usage": {
"prompt_tokens": number;
"completion_tokens": number;
"total_tokens": number;
}
}
}
- This endpoint takes in a request body containing a text input and returns the speech synthesis of that text.
POST /api/speech
Content-Type: application/json
Authorization: Bearer <token>
{
"text": string;
"lang"?: string; # Default: "en-US"
"speed"?: string; # Default: "0"
"codec"?: string; # Default: "mp3"
"format"?: string; # Default: "8khz_8bit_mono"
"b64"?: string; # Default: "true"
}
Accept: application/json
{
"success": true;
"speech": string; # "Base64-encoded audio"
}
- This endpoint creates a new user account.
POST /user/signup
Content-Type: application/json
{
"email": string;
"password": string;
}
Accept: application/json
{
"success": true;
"user": {
"username": string;
"email": string;
}
}
- This endpoint logs in an existing user.
POST /user/login
Content-Type: application/json
{
"email": string;
"password": string;
}
Accept: application/json
{
"success": true;
"token": string; # User token, expires in 1 day
}
- This endpoint returns user information based on the token provided in the request.
POST /user/userinfo
Content-Type: application/json
{
"token": string; # User token
}
Accept: application/json
{
"success": true;
"user": {
"username": string;
"email": string;
}
}
- This endpoint deletes a user account based on the token provided in the request.
POST /user/delete
Content-Type: application/json
{
"token": string;
}
Accept: application/json
{
"success": true;
}
- This endpoint sends an email to the NOVA support team.
POST /support/contact
Content-Type: application/json
{
"name": string;
"email": string;
"subject": string;
"message": string;
}
Accept: application/json
{
"success": true;
"message": "Message sent successfully";
"info": SMTPTransport.SentMessageInfo; # See https://nodemailer.com/message/
}
All errors are returned in the following format:
Status: <status code>
{
"success": false;
"error": string;
"fields"?: string[];
"categories"?: string[]; # Only for /api/completion, when the prompt is against OpenAI's guidelines
}
- Clone the repository
git clone https://github.com/YacineSteeve/nova-voicebot-api.git
- Install dependencies
yarn install
- Add environment variables:
- Create a
.env
file in the root directory - add the environment variables listed in the .env.example file.
Note:
NODE_ENV
should be set todevelopment
.
- Start the server
yarn dev