# AsyncCosmosDBChatMessageHistory

> **Class** in `langchain_azure_cosmosdb`

📖 [View in docs](https://reference.langchain.com/python/langchain-azure-cosmosdb/aio/_chat_history/AsyncCosmosDBChatMessageHistory)

Async chat message history backed by Azure CosmosDB.

## Signature

```python
AsyncCosmosDBChatMessageHistory(
    self,
    cosmos_endpoint: str,
    cosmos_database: str,
    cosmos_container: str,
    session_id: str,
    user_id: str,
    credential: Any = None,
    connection_string: Optional[str] = None,
    ttl: Optional[int] = None,
    cosmos_client_kwargs: Optional[dict] = None,
)
```

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `cosmos_endpoint` | `str` | Yes | The connection endpoint for the account. |
| `cosmos_database` | `str` | Yes | The name of the database to use. |
| `cosmos_container` | `str` | Yes | The name of the container to use. |
| `session_id` | `str` | Yes | The session ID to use. |
| `user_id` | `str` | Yes | The user ID to use. |
| `credential` | `Any` | No | The credential for Azure Cosmos DB. (default: `None`) |
| `connection_string` | `Optional[str]` | No | The connection string to authenticate. (default: `None`) |
| `ttl` | `Optional[int]` | No | Time to live (seconds) for documents in the container. (default: `None`) |
| `cosmos_client_kwargs` | `Optional[dict]` | No | Additional kwargs for the CosmosClient. (default: `None`) |

## Extends

- `BaseChatMessageHistory`

## Constructors

```python
__init__(
    self,
    cosmos_endpoint: str,
    cosmos_database: str,
    cosmos_container: str,
    session_id: str,
    user_id: str,
    credential: Any = None,
    connection_string: Optional[str] = None,
    ttl: Optional[int] = None,
    cosmos_client_kwargs: Optional[dict] = None,
) -> None
```

| Name | Type |
|------|------|
| `cosmos_endpoint` | `str` |
| `cosmos_database` | `str` |
| `cosmos_container` | `str` |
| `session_id` | `str` |
| `user_id` | `str` |
| `credential` | `Any` |
| `connection_string` | `Optional[str]` |
| `ttl` | `Optional[int]` |
| `cosmos_client_kwargs` | `Optional[dict]` |


## Properties

- `cosmos_endpoint`
- `cosmos_database`
- `cosmos_container`
- `credential`
- `conn_string`
- `session_id`
- `user_id`
- `ttl`
- `messages`

## Methods

- [`prepare_cosmos()`](https://reference.langchain.com/python/langchain-azure-cosmosdb/aio/_chat_history/AsyncCosmosDBChatMessageHistory/prepare_cosmos)
- [`load_messages()`](https://reference.langchain.com/python/langchain-azure-cosmosdb/aio/_chat_history/AsyncCosmosDBChatMessageHistory/load_messages)
- [`add_message()`](https://reference.langchain.com/python/langchain-azure-cosmosdb/aio/_chat_history/AsyncCosmosDBChatMessageHistory/add_message)
- [`aadd_messages()`](https://reference.langchain.com/python/langchain-azure-cosmosdb/aio/_chat_history/AsyncCosmosDBChatMessageHistory/aadd_messages)
- [`upsert_messages()`](https://reference.langchain.com/python/langchain-azure-cosmosdb/aio/_chat_history/AsyncCosmosDBChatMessageHistory/upsert_messages)
- [`clear()`](https://reference.langchain.com/python/langchain-azure-cosmosdb/aio/_chat_history/AsyncCosmosDBChatMessageHistory/clear)
- [`aclear()`](https://reference.langchain.com/python/langchain-azure-cosmosdb/aio/_chat_history/AsyncCosmosDBChatMessageHistory/aclear)

---

[View source on GitHub](https://github.com/langchain-ai/langchain-azure/blob/e62c2a55aaa0942fdac739b4066011953b80018e/libs/azure-cosmosdb/src/langchain_azure_cosmosdb/aio/_chat_history.py#L28)