# Chat

You may want to ask a follow-up question on top of the previous questions and answers. You can do so with `chat()` API. Ask in a chat will answer the question based on the contents related to the question and the previous questions and answers.

By default, chat will get answers from all relevant documents in the collection. If you want to chat with a single document, you could limit the document when ask.

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

```
There is no chat HTTP API. Please use the ask API with history_messages.
```

{% endtab %}

{% tab title="Python" %}

```
import chatbees as cb

# Configure API key
cb.init(api_key="my_api_key", account_id="my_account_id")

# start a new chat
chat = cb.collection('llm_research').chat()

# to chat with a single document, specify the doc_name
# chat = cb.collection('llm_research').chat(doc_name='file.pdf')

# ask the first question
answer, refs = chat.ask('what is a transformer?')

# ask the second question
answer, refs = chat.ask('how does transformer work?')

```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: 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://docs.chatbees.ai/chatbees/api-references/document-operations/chat.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.
