# ChatClient
The `ChatClient` class is the main entry point for using the Ably Chat SDK. It provides access to chat rooms, connection management, and the underlying Ably Realtime client.
The Chat SDK is built on top of the Ably Pub/Sub SDK and uses that to establish a connection with Ably. Instantiate a realtime client using the Pub/Sub SDK and pass the generated client into the Chat constructor.
#### Javascript
```
import { LogLevel } from '@ably/chat'
const realtimeClient = new Ably.Realtime({ key: 'your-api-key', clientId: '
An API key is required to authenticate with Ably. API keys are used either to authenticate directly with Ably using basic authentication, or to generate tokens for untrusted clients using [JWT authentication](https://ably.com/docs/auth/token.md#jwt).
## Properties
The `ChatClient` interface has the following properties:
### Javascript
```
import * as Ably from 'ably';
import { ChatClient } from '@ably/chat';
const realtimeClient = new Ably.Realtime({
key: 'your-api-key',
clientId: 'user-123'
});
const chatClient = new ChatClient(realtimeClient, clientOptions);
```
### Parameters
The `ChatClient()` constructor takes the following parameters:
### Javascript
```
await chatClient.dispose();
```
### Returns
`Promise
### Javascript
```
import * as Ably from 'ably';
import { ChatClient, LogLevel } from '@ably/chat';
const realtimeClient = new Ably.Realtime({
key: 'your-api-key',
clientId: 'user-123'
});
const chatClient = new ChatClient(realtimeClient, {
logLevel: LogLevel.Debug
});
// Access rooms
const room = await chatClient.rooms.get('my-room');
// Check connection status
console.log(chatClient.connection.status);
// Get current user ID
console.log(chatClient.clientId);
```
## Related Topics
- [Connection](https://ably.com/docs/chat/api/javascript/connection.md): API reference for the Connection interface in the Ably Chat JavaScript SDK.
- [Rooms](https://ably.com/docs/chat/api/javascript/rooms.md): API reference for the Rooms interface in the Ably Chat JavaScript SDK.
- [Room](https://ably.com/docs/chat/api/javascript/room.md): API reference for the Room interface in the Ably Chat JavaScript SDK.
- [Messages](https://ably.com/docs/chat/api/javascript/messages.md): API reference for the Messages interface in the Ably Chat JavaScript SDK.
- [Message](https://ably.com/docs/chat/api/javascript/message.md): API reference for the Message interface in the Ably Chat JavaScript SDK.
- [MessageReactions](https://ably.com/docs/chat/api/javascript/message-reactions.md): API reference for the MessageReactions interface in the Ably Chat JavaScript SDK.
- [Presence](https://ably.com/docs/chat/api/javascript/presence.md): API reference for the Presence interface in the Ably Chat JavaScript SDK.
- [Occupancy](https://ably.com/docs/chat/api/javascript/occupancy.md): API reference for the Occupancy interface in the Ably Chat JavaScript SDK.
- [Typing](https://ably.com/docs/chat/api/javascript/typing.md): API reference for the Typing interface in the Ably Chat JavaScript SDK.
- [RoomReactions](https://ably.com/docs/chat/api/javascript/room-reactions.md): API reference for the RoomReactions interface in the Ably Chat JavaScript SDK.
## Documentation Index
To discover additional Ably documentation:
1. Fetch [llms.txt](https://ably.com/llms.txt) for the canonical list of available pages.
2. Identify relevant URLs from that index.
3. Fetch target pages as needed.
Avoid using assumed or outdated documentation paths.