# Chats prompting

> Chats prompting - Chatsprovide a way to interact with LLMs through prompts, maintaining conversation
> history and context. Chats allow you to have multi-turn conversations with your LLM applications,
> where each prompt can reference previous messages in the conversation.

This Markdown file sits beside the HTML page at the same path (with a `.md` suffix). It summarizes the topic and lists links for tools and LLM context.

Companion generated at `2026-04-24T16:03:56.278910+00:00` (UTC).

## Primary page

- [Chats prompting](https://docs.datarobot.com/en/docs/api/dev-learning/python/genai/chats-prompting.html): Full documentation for this topic (HTML).

## Sections on this page

- [Create a chat](https://docs.datarobot.com/en/docs/api/dev-learning/python/genai/chats-prompting.html#create-a-chat): In-page section heading.
- [Submit prompts to a chat](https://docs.datarobot.com/en/docs/api/dev-learning/python/genai/chats-prompting.html#submit-prompts-to-a-chat): In-page section heading.
- [Retrieve chat history](https://docs.datarobot.com/en/docs/api/dev-learning/python/genai/chats-prompting.html#retrieve-chat-history): In-page section heading.
- [Manage chats](https://docs.datarobot.com/en/docs/api/dev-learning/python/genai/chats-prompting.html#manage-chats): In-page section heading.
- [Get chat information](https://docs.datarobot.com/en/docs/api/dev-learning/python/genai/chats-prompting.html#get-chat-information): In-page section heading.

## Related documentation

- [Developer documentation](https://docs.datarobot.com/en/docs/api/index.html): Linked from this page.
- [Developer learning](https://docs.datarobot.com/en/docs/api/dev-learning/index.html): Linked from this page.
- [Python API client user guide](https://docs.datarobot.com/en/docs/api/dev-learning/python/index.html): Linked from this page.
- [Generative AI](https://docs.datarobot.com/en/docs/api/dev-learning/python/genai/index.html): Linked from this page.
- [Chats](https://docs.datarobot.com/en/docs/api/reference/sdk/gen-prompting.html#datarobot.models.genai.chat.Chat): Linked from this page.

## Documentation content

# Chats and prompting

[Chats](https://docs.datarobot.com/en/docs/api/reference/sdk/gen-prompting.html#datarobot.models.genai.chat.Chat) provide a way to interact with LLMs through prompts, maintaining conversation history and context. Chats allow you to have multi-turn conversations with your LLM applications, where each prompt can reference previous messages in the conversation.

## Create a chat

Create a new chat from an LLM blueprint. When creating a chat, you should specify the following:

- name : A user-friendly name for the chat.
- llm_blueprint : The LLM blueprint ID or LLMBlueprint object to associate the chat with.

```
import datarobot as dr
blueprint = dr.genai.LLMBlueprint.get(blueprint_id)
chat = dr.genai.Chat.create(
    name="Customer Support Chat",
    llm_blueprint=blueprint_id
)
chat
```

## Submit prompts to a chat

Send prompts and receive responses using [datarobot.ChatPrompt.submit()](https://docs.datarobot.com/en/docs/api/reference/sdk/gen-prompting.html#datarobot.models.genai.chat_prompt.ChatPrompt.submit):

```
chat = dr.genai.Chat.get(chat_id)
prompt = dr.genai.ChatPrompt.create(
    chat=chat.id,
    text="What is your return policy?"
)
prompt.result_text
```

Submit a follow-up prompt that maintains the conversation history:

```
followup = dr.genai.ChatPrompt.create(
    chat=chat.id,
    text="How long does it take to process a return?"
)
print(f"Response: {followup.result_text}")
```

## Retrieve chat history

Get all prompts in a chat using [datarobot.ChatPrompt.list()](https://docs.datarobot.com/en/docs/api/reference/sdk/gen-prompting.html#datarobot.models.genai.chat_prompt.ChatPrompt.list):

```
chat = dr.genai.Chat.get(chat_id)
prompts = dr.genai.ChatPrompt.list(chat=chat.id)
for prompt in prompts:
    prompt.text
    prompt.result_text
```

Filter prompts by LLM blueprint:

```
blueprint = dr.genai.LLMBlueprint.get(blueprint_id)
blueprint_prompts = dr.genai.ChatPrompt.list(llm_blueprint=blueprint.id)
```

Filter prompts by playground:

```
playground = dr.genai.Playground.get(playground_id)
playground_prompts = dr.genai.ChatPrompt.list(playground=playground.id)
```

## Manage chats

List all chats:

```
all_chats = dr.genai.Chat.list()
print(f"Found {len(all_chats)} chat(s):")
for chat in all_chats:
    print(f"  - {chat.name} (ID: {chat.id})")
```

Filter by LLM blueprint:

```
blueprint = dr.genai.LLMBlueprint.get(blueprint_id)
blueprint_chats = dr.genai.Chat.list(llm_blueprint=blueprint.id)
```

Update the chat name:

```
chat = dr.genai.Chat.get(chat_id)
chat.update(name="Updated Chat Name")
```

Delete a chat:

```
chat.delete()
```

## Get chat information

Retrieve chat details:

```
chat = dr.genai.Chat.get(chat_id)
print(f"Name: {chat.name}")
print(f"LLM Blueprint: {chat.llm_blueprint_id}")
print(f"Is frozen: {chat.is_frozen}")
print(f"Prompts count: {chat.prompts_count}")
print(f"Warning: {chat.warning}")
```
