> For the complete documentation index, see [llms.txt](https://docs.nisa.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.nisa.ai/deploying-bots/api.md).

# API

ChatBot API Integration

Welcome to the Nisa Knowledge API, your gateway to a rich, customizable ChatGPT experience tailored to meet your business requirements. Whether you're building a customer service bot, a virtual assistant, or a suite of AI tools to augment organizational productivity and decision-making, our API simplifies the integration process.

#### Getting Started

Before proceeding, make sure you have registered on our platform to generate your unique API key. This is a crucial step towards unlocking a custom ChatGPT experience designed for your needs.

#### Endpoint

```
POST <https://{BASE_URL}/v1/api/engage>
```

#### Authentication

Authenticate your requests by including your API key in the header of each request.

Header:

```
Authorization: Bearer YOUR_API_KEY
```

Replace `YOUR_API_KEY` with the API key you generated in the platform.

#### Making a Request

Initiate a `POST` request to the endpoint to interact with the chatbot. Your request body should include the content of your inquiry along with optional parameters like `source`, `verbose`, and `stream` to tailor the request to your specifications.

#### Parameters:

* **message (required)**: The inquiry or message you wish to relay to the chatbot.
* **source (optional)**: To specify the source of information. The default value is 'ALL'.
* **stream (optional)**: A boolean flag to initiate a streaming response. The default value is false.

Example Request Body:

```json
{
    "message": "What is the capital of France?",
    "source": "ALL",
    "stream": false
}

```

***

#### Response

Upon making a request, you will receive a JSON object containing the chatbot's reply, curated to provide precise and relevant answers in line with your organization's context. If the `stream` parameter is set to true, the response will be streamed back to the client.

Example Response:

```json
{
    "message": "The capital of France is Paris."
}
```

Example Streamed Response:

```json
{
    "done": true,
    "message": "The capital of France is Paris.",
    "sources": [...]
}
```

***

#### Stream Feature

When the `stream` parameter is set to true in the request body, the response will be streamed to the client. This is particularly useful for handling long-running queries or processing large amounts of data. The response object will contain a `done` flag indicating whether the streaming is complete, along with the message and sources of information used to generate the response.

***

#### Error Handling

In the event of an error, the API will respond with an appropriate status code along with a message describing the error.

Example Error Response:

```json
{
    "error": "Invalid API key provided.",
    "status": 401
}
```

#### Conclusion

Voila! Integrating the nisa Knowledge API into your applications is a straightforward process. By doing so, you unlock a tailored ChatGPT experience that can significantly boost productivity and enhance decision-making across your team. Ensure to handle the responses effectively and monitor your usage to avoid any disruptions.
