> For the complete documentation index, see [llms.txt](https://teman-insight.gitbook.io/teman-insight/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://teman-insight.gitbook.io/teman-insight/chatting/chat-api-integration.md).

# Chat API Integration

If you prefer to build your own user interface, chat functionality integration via API key is available.&#x20;

## 1. Retrieving API Key

once you have created your knowledge base, you can get the API key through :&#x20;

1. Knowledge Base list menu (API Key Column)<br>

   <figure><img src="/files/xdK6gnebw2LiiLcgR6W9" alt=""><figcaption></figcaption></figure>

2. Edit Knowledge Base  (Under API Key section)<br>

   <figure><img src="/files/UC7L4g6xwIUEDoCWe2Lb" alt=""><figcaption></figcaption></figure>

## 2. Creating API Request

#### Request

```markup
curl --location --request POST 'https://api.temaninsight.com/api/public/partners/knowledgebases/ask' \
--header 'Content-Type: application/json' \
--header 'api-key: <Input your API Key>' \
--data '{
    "message": "Hallo, can you explain me what you can do ?"
    "session_id": <Input session_id>
}'
```

* make your request (method: POST) to this endpoint : `https://api.temaninsight.com/api/public/partners/knowledgebases/ask`
* `message` : input your question that you want to send
* `session_id` (Optional) : this is a chatroom identifier.&#x20;
  * In the beginning of conversation you might not need to include this.&#x20;
  * However, once you receive your first response from API , you will get session\_id.
  * If you want the AI to be able to get the context within the same conversation (chatroom) , you need to include this session\_id when you sending request&#x20;

#### Response&#x20;

```json
{
    "data": {
        "answer": "Hi , I am your ai agent. I can help you answering your question",
        "embeddings": // Beta
            [
                "/9j/2wBDAAIBAQEBAQIBAQECAgICAgQDAgICAgUEB",
                "...."
            ], 
        "session_id": "a42e5790-6b94-4313-95b5-896f710d5e17",
        "timestamp": "2025-08-13T02:42:35.791012419Z"
    },
    "error": null,
    "request_id": "b8ff200f-72d8-4b01-b4fa-31a62c7e12df"
}
```

* `answer` : this is the answer from the AI
* `embeddings` :  array of strings contains images that are retrieved by the AI. This value is `null` if you turn this off on Knowledge Base edit page. \
  \
  \&#xNAN;*please note that this field is still in beta*
* `session_id` : use this value if you want to make the AI answering your question with existing conversation as a context


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://teman-insight.gitbook.io/teman-insight/chatting/chat-api-integration.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
