# Chat

Bot API allows you to try out different Large Language Models (LLMs) from providers like Mistral, OpenAI, and Claude.

For more details on the supported LLM models and their capabilities, please refer to the [chatbot](https://docs.qolaba.ai/chatbot "mention").

## Chat with LLM

<mark style="color:green;">`POST`</mark> `/chat`

**Headers**

| Name          | Value              |
| ------------- | ------------------ |
| Content-Type  | `application/json` |
| Authorization | `Bearer <token>`   |

**Body**

<table><thead><tr><th width="166">Name</th><th width="162">Type</th><th>Description</th></tr></thead><tbody><tr><td>llm</td><td>string</td><td><p>-> The <code>llm</code> parameter specifies the type of Large Language Model (LLM) to be used. The supported values are:</p><ul><li><code>ClaudeAI</code></li><li><code>OpenAI</code></li><li><code>GeminiAI</code></li><li><code>OpenRouterAI</code></li></ul><p></p></td></tr><tr><td>llm_model</td><td>string</td><td><p></p><p>-> The <code>llm_model</code> parameter specifies the name of the Large Language Model (LLM) to be used. The supported values for this parameter depend on the <code>llm</code> you have selected.</p><p>For example, if the <code>llm</code> is <code>OpenAI</code>, the supported <code>llm_model</code> values include:</p><ul><li><code>"gpt-4.1-mini-2025-04-14"</code></li><li><code>"gpt-4.1-2025-04-14"</code></li></ul><p>Similarly, if the <code>llm</code> is <code>ClaudeAI</code>, the supported <code>llm_model</code> values include:</p><ul><li><code>"claude-3-7-sonnet-latest"</code></li></ul><p>Ensure that the <code>llm_model</code> value you provide is compatible with the selected <code>model_type</code>.</p><p></p><p>-> Supported LLMs and their Models are : </p><p></p><p>GeminiAI</p><ol><li>gemini-2.5-pro </li><li>gemini-2.5-flash</li></ol><p></p><p>ClaudeAI</p><ol><li>claude-sonnet-4-20250514</li><li>claude-opus-4-1-20250805</li></ol><p></p><p>OpenAI</p><ol><li>gpt-4.1-mini-2025-04-14</li><li>gpt-4.1-nano-2025-04-14</li><li>gpt-4o-mini </li><li>gpt-4.1-2025-04-14</li><li>o1</li></ol><p>(Note: Below models for OpenAI LLM must be configured with <code>temperature=1</code> ,while runninng this model)</p><ol><li>o3-mini</li><li>o3</li><li>o4-mini-2025-04-16  </li><li>gpt-5-2025-08-07</li><li>gpt-5-mini-2025-08-07</li><li>gpt-5-nano-2025-08-07</li></ol><p></p><p>OpenRouterAI</p><ol><li>x-ai/grok-4</li><li>x-ai/grok-3-mini-beta</li><li>x-ai/grok-3-beta</li><li>perplexity/sonar-pro</li><li>perplexity/sonar-reasoning-pro</li><li>perplexity/sonar-reasoning</li><li>perplexity/sonar-deep-research</li><li>deepseek/deepseek-chat</li><li>deepseek/deepseek-r1</li></ol></td></tr><tr><td>history</td><td>List of Dictionary (Python) or map (C++)</td><td><p>-> The <code>history</code> parameter allows you to provide the previous chat history and the last user message. The history should follow a specific pattern:</p><ol><li>The history should start with a user message.</li><li>After each user message, there should be a response from the assistant.</li><li>The last message in the history should be a user message or query.</li></ol><p>-> The history should be provided as a list of dictionaries, where each dictionary represents a message. The dictionary should have the following structure:</p><pre><code> {
    "role": "user",
    "content": {
      "text": "please give 50 word story in English",
      "image_data": [
         {
           "url": "string",
           "details": "low"
         }
       ]
     }
  }

</code></pre><p>The <code>image\_data</code> parameter is a list that can contain up to 5 image URLs. The <code>details</code> parameter is optional and can be used to specify the level of detail required for the image analysis (only for OpenAI models).</p><p>Here's an example of the <code>history</code> parameter:</p><pre><code>"history": \[
{
"role": "user",
"content": {
"text": "hey",
"image\_data": \[]
}
},
{
"role": "assistant",
"content": {
"text": "Hello! How can I assist you today?",
"image\_data": \[]
}
},
{
"role": "user",
"content": {
"text": "Please analyze this image",
"image\_data": \[
{
"url": "<https://res.cloudinary.com/qolaba/image/upload/v1695690455/kxug1tmiolt1dtsvv5br.jpg>",
"details": "low"
}
]
}
}
]

</code></pre></td></tr><tr><td>temperature</td><td>float</td><td><p>-> The <code>temperature</code> parameter accepts a float value between 0 and 1. This parameter helps control the level of determinism in the output from the Large Language Model (LLM).</p><p>-> Higher temperature values (closer to 1) will result in more diverse and creative output, while lower values (closer to 0) will lead to more deterministic and conservative responses.</p></td></tr><tr><td>image\_analyze</td><td>bool</td><td>-> If you are passing image URLs and want the model to analyze the images, set the <code>image\_analyze</code> parameter to <code>true</code>.</td></tr><tr><td>enable\_tool</td><td>bool</td><td><p>-> To use the tools supported by the Chat API, enable the <code>enable\_tool</code> parameter. The Chat API currently supports two tools:</p><ol><li>Vector Search</li><li>Internet Search</li></ol><p>-> After enabling the <code>enable\_tool</code> parameter, you can provide the details of the tool you want to use in the <code>tools</code> parameter.<br></p></td></tr><tr><td>system\_msg</td><td>string</td><td>-> The <code>system\_msg</code> parameter allows you to set a system message for the Large Language Model (LLM). This message can be used to provide context or instructions to the model, which can influence the tone and behavior of the generated responses.</td></tr><tr><td>tools</td><td>dictionary or map</td><td><p></p><p>The <code>tools</code> parameter allows you to configure the capabilities available to the assistant during a conversation. It defines which tools are enabled, how much past context to consider, and specifies settings for embeddings, PDFs, and image generation. This is useful for tailoring the assistant’s functionality to your use case.</p><p><strong>🔹 Structure</strong></p><pre class="language-json"><code class="lang-json">jsonCopyEdit"tools": {
"tool\_list": {
"image\_generation": false,
"image\_generation1": false,
"image\_editing": false,
"search\_doc": false,
"internet\_search": false,
"python\_code\_execution\_tool": false,
"csv\_analysis": false
},
"number\_of\_context": 3,
"pdf\_references": \[],
"embedding\_model": \[
"text-embedding-3-large"
],
"image\_generation\_parameters": {}
} </code></pre><p><strong>🔹 Field Descriptions</strong></p><ul><li><p><strong>tool\_list</strong>: An object with boolean flags to enable or disable specific tools. Setting a value to <code>true</code> activates that feature.</p><ul><li><code>image\_generation</code>: Enables image creation from text prompts.</li><li><code>image\_generation1</code>: Optional alternate switch for image generation (if supported).</li><li><code>image\_editing</code>: Enables uploading and editing images.</li><li><code>search\_doc</code>: Allows document-based searching.</li><li><code>internet\_search</code>: Enables real-time web searches.</li><li><code>python\_code\_execution\_tool</code>: Allows execution of Python code within a safe sandbox.</li><li><code>csv\_analysis</code>: Enables processing and analysis of uploaded CSV files.</li></ul></li><li><strong>number\_of\_context</strong>: An integer defining how many previous user-assistant interactions to retain in memory. Higher values help preserve conversation flow.</li><li><strong>pdf\_references</strong>: A list of PDFs that the assistant can reference for contextual information should be stored in vector store database. Each entry includes an unique id which comes from the output of vector store API. If you're adding more than one document using <code>pdf\_references</code>, make sure you add the same number of entries in the <code>embedding\_model</code> array.</li><li><strong>embedding\_model</strong>: we support  <code>"text-embedding-3-large"</code> as  the embedding model.</li><li><strong>image\_generation\_parameters</strong>: An object to define settings like size or style for image generation. Leave it empty for default behavior.</li></ul></td></tr><tr><td>token</td><td>string</td><td>Authentication token needed for the request.</td></tr><tr><td>orgID</td><td>string </td><td>Identifies the organization associated with the request.</td></tr><tr><td>function\_call\_list</td><td>string</td><td>Lists the functions called during the process.</td></tr><tr><td>systemId </td><td>string</td><td>Specifies the system identifier linked to the request.</td></tr><tr><td>last\_user\_query</td><td>string</td><td>Provides the last user query made in the chat.</td></tr></tbody></table>

Example of Input body parameters :&#x20;

```
data '{
  "llm": "GeminiAI",
  "llm_model": "gemini-2.5-flash",
  "history": [
    {
      "role": "user",
      "content": {
        "text": "please give 50 word story in English",
        "image_data": [
          {
            "url": "string",
            "details": "low"
          }
        ]
      }
    }
  ],
  "temperature": 0.7,
  "image_analyze": false,
  "enable_tool": false,
  "system_msg": "You are a helpful assistant.",
  "tools": {
    "tool_list": {
      "image_generation": false,
      "image_generation1": false,
      "image_editing": false,
      "search_doc": false,
      "internet_search": false,
      "python_code_execution_tool": false,
      "csv_analysis": false
    },
    "number_of_context": 3,
      "pdf_references": [
      "output vectorstore1",
      "output vectorstore2"
    ],
    "embedding_model": [
      "text-embedding-3-large",
      "text-embedding-3-large"
    ],
    "image_generation_parameters": {}
  },
  "token": "123",
  "orgID": "string",
  "function_call_list": [],
  "systemId": "string",
  "last_user_query": "string"
}'
```

After passing the necessary parameters and executing the Chat API, you will receive a stream response. A successful response will look similar to the following:

**Response**

{% tabs %}
{% tab title="200" %}

<pre class="language-json"><code class="lang-json"><strong>{
</strong>  "output": null, 
  "promptTokens": null, 
  "completionTokens": null
}
</code></pre>

{% endtab %}

{% tab title="500" %}

```json
{
  "output": null, 
  "error": string, 
  "error_data": string
}
```

{% endtab %}
{% endtabs %}

The Chat API response is a streaming response, which means you will receive the output in chunks as the model generates the response. The response will continue to stream until the generation is complete.

The response will contain the following elements:

* `output`: This object contains the generated text output from the model.

The text output from the LLM can be obtained from the `output` parameter. When the response is complete, the final chunk will contain a `null` value in the `output` parameter, indicating the end of the stream.

## Run the API

To test this API, please use the following link:

{% embed url="<https://app.theneo.io/api-runner/qolaba/ml-apis/api-reference/chat-api>" %}
