Chat with Nara

The Nara chat API allows you to build applications that can engage in interactive chat with users, in real-time or asynchronously. In this guide, we'll walk you through how to use the API to send and receive messages. ##

Prerequisites

You need to have an API key provided by Nara. If you don't have an API key, you can obtain it by sending a request to [email protected].

Step 1: Start a New Conversation

To start a new conversation, you can do so by sending a chat message. To do this, use the /api/v1.0/chat endpoint.

This is a POST request, where the body of the request contains the initial message to start the conversation.

curl --location 'https://nara-backend-50wz.zeet-nara.zeet.app/api/v1.0/chat' \
--header 'Authorization: Bearer YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
    "message": "Hello Nara!",
    "conversation_id": "conv_123",
    "stream": false,
    "temperature": 0.1
}'

The conversation_id is a unique identifier that you provide for each conversation.

Step 2: Sending Further Messages

To send further messages within the same conversation, simply use the same conversation_id you initiated the conversation with:

curl --location 'https://nara-backend-50wz.zeet-nara.zeet.app/api/v1.0/chat' \
--header 'Authorization: Bearer YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
    "message": "I have a question.",
    "conversation_id": "conv_123",
    "stream": false,
    "temperature": 0.1
}'

This will allow Nara to keep track of the conversation context and generate appropriate responses.

Step 3: Retrieve Chat Messages

You can retrieve the chat messages of a specific user with the /api/v1.0/chat/messages endpoint. This is a GET request where you specify the user_id in the query string.

For example:

curl --location 'https://nara-backend-50wz.zeet-nara.zeet.app/api/v1.0/chat/messages?user_id=:eq:1254321&rows_per_page=20&current_page=1&sort_by=created_at%3Adesc' \
--header 'Authorization: Bearer YOUR_API_KEY'

This will return the 20 most recent messages for the user with ID 1254321.

Support

If you need help or have any questions, feel free to reach out to us at [email protected]. Happy chatting!