# Chat

## List Sessions

`client.beta.chat.list(ChatListParamsquery?, RequestOptionsoptions?): PaginatedCursor<ChatListResponse>`

**get** `/api/v1/chat`

List all chat sessions for the current project.

### Parameters

- `query: ChatListParams`

  - `organization_id?: string | null`

  - `page_size?: number | null`

  - `page_token?: string | null`

  - `project_id?: string | null`

### Returns

- `ChatListResponse`

  Summary of a chat session, including its title and last run metadata.

  - `last_updated_at: string`

    ISO-format timestamp showing when the session was last updated.

  - `session_id: string`

    Unique session identifier.

  - `generated_title?: string | null`

    Auto-generated title derived from the first user message.

  - `index_ids?: Array<string> | null`

    Indexes this session is bound to. Null on unbound sessions.

  - `job_metadata?: JobMetadata | null`

    Token usage and status from the most recent run. Null if the session has not been run yet.

    - `duration_ms?: number`

    - `error?: string | null`

    - `export_config_ids?: Array<string> | null`

    - `is_error?: boolean`

    - `total_input_tokens?: number | null`

    - `total_output_tokens?: number | null`

    - `turns?: number`

### Example

```typescript
import LlamaCloud from '@llamaindex/llama-cloud';

const client = new LlamaCloud({
  apiKey: process.env['LLAMA_CLOUD_API_KEY'], // This is the default and can be omitted
});

// Automatically fetches more pages as needed.
for await (const chatListResponse of client.beta.chat.list()) {
  console.log(chatListResponse.session_id);
}
```

#### Response

```json
{
  "items": [
    {
      "last_updated_at": "2026-04-22T12:34:41.342245",
      "session_id": "ses-abc123",
      "generated_title": "What were the main findings in Q3?...",
      "index_ids": [
        "idx-abc123",
        "idx-def456"
      ],
      "job_metadata": {
        "duration_ms": 0,
        "error": "error",
        "export_config_ids": [
          "string"
        ],
        "is_error": true,
        "total_input_tokens": 0,
        "total_output_tokens": 0,
        "turns": 0
      }
    }
  ],
  "next_page_token": "next_page_token"
}
```

## Create Session

`client.beta.chat.create(ChatCreateParamsparams?, RequestOptionsoptions?): ChatCreateResponse`

**post** `/api/v1/chat`

Create a chat session, optionally bound to indexes (locked after the first message).

### Parameters

- `params: ChatCreateParams`

  - `organization_id?: string | null`

    Query param

  - `project_id?: string | null`

    Query param

  - `index_ids?: Array<string> | null`

    Body param: Indexes this session will retrieve from. Once set and the first message has been sent, the source set is locked for the session's lifetime. Leave null to create an unbound session.

### Returns

- `ChatCreateResponse`

  Summary of a chat session, including its title and last run metadata.

  - `last_updated_at: string`

    ISO-format timestamp showing when the session was last updated.

  - `session_id: string`

    Unique session identifier.

  - `generated_title?: string | null`

    Auto-generated title derived from the first user message.

  - `index_ids?: Array<string> | null`

    Indexes this session is bound to. Null on unbound sessions.

  - `job_metadata?: JobMetadata | null`

    Token usage and status from the most recent run. Null if the session has not been run yet.

    - `duration_ms?: number`

    - `error?: string | null`

    - `export_config_ids?: Array<string> | null`

    - `is_error?: boolean`

    - `total_input_tokens?: number | null`

    - `total_output_tokens?: number | null`

    - `turns?: number`

### Example

```typescript
import LlamaCloud from '@llamaindex/llama-cloud';

const client = new LlamaCloud({
  apiKey: process.env['LLAMA_CLOUD_API_KEY'], // This is the default and can be omitted
});

const chat = await client.beta.chat.create();

console.log(chat.session_id);
```

#### Response

```json
{
  "last_updated_at": "2026-04-22T12:34:41.342245",
  "session_id": "ses-abc123",
  "generated_title": "What were the main findings in Q3?...",
  "index_ids": [
    "idx-abc123",
    "idx-def456"
  ],
  "job_metadata": {
    "duration_ms": 0,
    "error": "error",
    "export_config_ids": [
      "string"
    ],
    "is_error": true,
    "total_input_tokens": 0,
    "total_output_tokens": 0,
    "turns": 0
  }
}
```

## Get Full Session

`client.beta.chat.retrieve(stringsessionID, ChatRetrieveParamsquery?, RequestOptionsoptions?): ChatRetrieveResponse`

**get** `/api/v1/chat/{session_id}`

Retrieve a full session by ID, including its event history.

### Parameters

- `sessionID: string`

- `query: ChatRetrieveParams`

  - `organization_id?: string | null`

  - `project_id?: string | null`

### Returns

- `ChatRetrieveResponse`

  Full chat session including its complete event history.

  - `events: Array<ThinkingDeltaEvent | TextDeltaEvent | ThinkingEvent | 5 more>`

    Ordered list of events that make up the conversation history.

    - `ThinkingDeltaEvent`

      - `content: string`

      - `type?: "thinking_delta"`

        - `"thinking_delta"`

    - `TextDeltaEvent`

      - `content: string`

      - `type?: "text_delta"`

        - `"text_delta"`

    - `ThinkingEvent`

      - `content: string`

      - `type?: "thinking"`

        - `"thinking"`

    - `TextEvent`

      - `content: string`

      - `type?: "text"`

        - `"text"`

    - `ToolCallEvent`

      - `arguments: Record<string, unknown>`

      - `call_id: string`

      - `name: string`

      - `type?: "tool_call"`

        - `"tool_call"`

    - `ToolResultEvent`

      - `call_id: string`

      - `name: string`

      - `result: unknown`

      - `image_attachment?: ImageAttachment | null`

        Coordinates for lazily resolving a page screenshot presigned URL.

        - `attachment_name: string`

        - `source_id: string`

      - `type?: "tool_result"`

        - `"tool_result"`

    - `StopEvent`

      - `error: string | null`

      - `is_error: boolean`

      - `usage: Usage`

        - `duration_ms?: number`

        - `total_input_tokens?: number | null`

        - `total_output_tokens?: number | null`

        - `turns?: number`

      - `type?: "stop"`

        - `"stop"`

    - `UserInputEvent`

      - `content: string`

      - `type?: "user_input"`

        - `"user_input"`

  - `last_updated_at: string`

    ISO-format timestamp showing when the session was last updated.

  - `session_id: string`

    Unique session identifier.

  - `generated_title?: string | null`

    Auto-generated title derived from the first user message.

  - `index_ids?: Array<string> | null`

    Indexes this session is bound to. Null on unbound sessions.

  - `job_metadata?: JobMetadata | null`

    Token usage and status from the most recent run. Null if the session has not been run yet.

    - `duration_ms?: number`

    - `error?: string | null`

    - `export_config_ids?: Array<string> | null`

    - `is_error?: boolean`

    - `total_input_tokens?: number | null`

    - `total_output_tokens?: number | null`

    - `turns?: number`

### Example

```typescript
import LlamaCloud from '@llamaindex/llama-cloud';

const client = new LlamaCloud({
  apiKey: process.env['LLAMA_CLOUD_API_KEY'], // This is the default and can be omitted
});

const chat = await client.beta.chat.retrieve('session_id');

console.log(chat.session_id);
```

#### Response

```json
{
  "events": [
    {
      "content": "content",
      "type": "thinking_delta"
    }
  ],
  "last_updated_at": "2026-04-22T12:34:41.342245",
  "session_id": "ses-abc123",
  "generated_title": "What were the main findings in Q3?...",
  "index_ids": [
    "idx-abc123",
    "idx-def456"
  ],
  "job_metadata": {
    "duration_ms": 0,
    "error": "error",
    "export_config_ids": [
      "string"
    ],
    "is_error": true,
    "total_input_tokens": 0,
    "total_output_tokens": 0,
    "turns": 0
  }
}
```

## Delete Session

`client.beta.chat.delete(stringsessionID, ChatDeleteParamsparams?, RequestOptionsoptions?): void`

**delete** `/api/v1/chat/{session_id}`

Delete a session.

### Parameters

- `sessionID: string`

- `params: ChatDeleteParams`

  - `organization_id?: string | null`

  - `project_id?: string | null`

### Example

```typescript
import LlamaCloud from '@llamaindex/llama-cloud';

const client = new LlamaCloud({
  apiKey: process.env['LLAMA_CLOUD_API_KEY'], // This is the default and can be omitted
});

await client.beta.chat.delete('session_id');
```

## Get Session Summary

`client.beta.chat.getSummary(stringsessionID, ChatGetSummaryParamsquery?, RequestOptionsoptions?): ChatGetSummaryResponse`

**get** `/api/v1/chat/{session_id}/summary`

Retrieve a session summary by ID.

### Parameters

- `sessionID: string`

- `query: ChatGetSummaryParams`

  - `organization_id?: string | null`

  - `project_id?: string | null`

### Returns

- `ChatGetSummaryResponse`

  Summary of a chat session, including its title and last run metadata.

  - `last_updated_at: string`

    ISO-format timestamp showing when the session was last updated.

  - `session_id: string`

    Unique session identifier.

  - `generated_title?: string | null`

    Auto-generated title derived from the first user message.

  - `index_ids?: Array<string> | null`

    Indexes this session is bound to. Null on unbound sessions.

  - `job_metadata?: JobMetadata | null`

    Token usage and status from the most recent run. Null if the session has not been run yet.

    - `duration_ms?: number`

    - `error?: string | null`

    - `export_config_ids?: Array<string> | null`

    - `is_error?: boolean`

    - `total_input_tokens?: number | null`

    - `total_output_tokens?: number | null`

    - `turns?: number`

### Example

```typescript
import LlamaCloud from '@llamaindex/llama-cloud';

const client = new LlamaCloud({
  apiKey: process.env['LLAMA_CLOUD_API_KEY'], // This is the default and can be omitted
});

const response = await client.beta.chat.getSummary('session_id');

console.log(response.session_id);
```

#### Response

```json
{
  "last_updated_at": "2026-04-22T12:34:41.342245",
  "session_id": "ses-abc123",
  "generated_title": "What were the main findings in Q3?...",
  "index_ids": [
    "idx-abc123",
    "idx-def456"
  ],
  "job_metadata": {
    "duration_ms": 0,
    "error": "error",
    "export_config_ids": [
      "string"
    ],
    "is_error": true,
    "total_input_tokens": 0,
    "total_output_tokens": 0,
    "turns": 0
  }
}
```

## Generate Session Title

`client.beta.chat.setTitle(stringsessionID, ChatSetTitleParamsparams, RequestOptionsoptions?): ChatSetTitleResponse`

**post** `/api/v1/chat/{session_id}/title`

Generate a title for a session from its first user message.

### Parameters

- `sessionID: string`

- `params: ChatSetTitleParams`

  - `first_message: string`

    Body param: First user message of the session, used to infer a short title.

  - `organization_id?: string | null`

    Query param

  - `project_id?: string | null`

    Query param

### Returns

- `ChatSetTitleResponse`

  Summary of a chat session, including its title and last run metadata.

  - `last_updated_at: string`

    ISO-format timestamp showing when the session was last updated.

  - `session_id: string`

    Unique session identifier.

  - `generated_title?: string | null`

    Auto-generated title derived from the first user message.

  - `index_ids?: Array<string> | null`

    Indexes this session is bound to. Null on unbound sessions.

  - `job_metadata?: JobMetadata | null`

    Token usage and status from the most recent run. Null if the session has not been run yet.

    - `duration_ms?: number`

    - `error?: string | null`

    - `export_config_ids?: Array<string> | null`

    - `is_error?: boolean`

    - `total_input_tokens?: number | null`

    - `total_output_tokens?: number | null`

    - `turns?: number`

### Example

```typescript
import LlamaCloud from '@llamaindex/llama-cloud';

const client = new LlamaCloud({
  apiKey: process.env['LLAMA_CLOUD_API_KEY'], // This is the default and can be omitted
});

const response = await client.beta.chat.setTitle('session_id', {
  first_message: 'What were the main findings in Q3?',
});

console.log(response.session_id);
```

#### Response

```json
{
  "last_updated_at": "2026-04-22T12:34:41.342245",
  "session_id": "ses-abc123",
  "generated_title": "What were the main findings in Q3?...",
  "index_ids": [
    "idx-abc123",
    "idx-def456"
  ],
  "job_metadata": {
    "duration_ms": 0,
    "error": "error",
    "export_config_ids": [
      "string"
    ],
    "is_error": true,
    "total_input_tokens": 0,
    "total_output_tokens": 0,
    "turns": 0
  }
}
```

## Stream Messages

`client.beta.chat.stream(stringsessionID, ChatStreamParamsparams, RequestOptionsoptions?): ChatStreamResponse`

**post** `/api/v1/chat/{session_id}/messages/stream`

Stream agent events for a chat turn as Server-Sent Events.

### Parameters

- `sessionID: string`

- `params: ChatStreamParams`

  - `index_ids: Array<string>`

    Body param: Indexes to retrieve data from.

  - `prompt: string`

    Body param: User message for this chat turn.

  - `organization_id?: string | null`

    Query param

  - `project_id?: string | null`

    Query param

### Returns

- `ChatStreamResponse = unknown`

### Example

```typescript
import LlamaCloud from '@llamaindex/llama-cloud';

const client = new LlamaCloud({
  apiKey: process.env['LLAMA_CLOUD_API_KEY'], // This is the default and can be omitted
});

const response = await client.beta.chat.stream('session_id', {
  index_ids: ['idx-abc123', 'idx-def456'],
  prompt: 'What were the main findings in Q3?',
});

console.log(response);
```

#### Response

```json
{}
```

## Domain Types

### Chat List Response

- `ChatListResponse`

  Summary of a chat session, including its title and last run metadata.

  - `last_updated_at: string`

    ISO-format timestamp showing when the session was last updated.

  - `session_id: string`

    Unique session identifier.

  - `generated_title?: string | null`

    Auto-generated title derived from the first user message.

  - `index_ids?: Array<string> | null`

    Indexes this session is bound to. Null on unbound sessions.

  - `job_metadata?: JobMetadata | null`

    Token usage and status from the most recent run. Null if the session has not been run yet.

    - `duration_ms?: number`

    - `error?: string | null`

    - `export_config_ids?: Array<string> | null`

    - `is_error?: boolean`

    - `total_input_tokens?: number | null`

    - `total_output_tokens?: number | null`

    - `turns?: number`

### Chat Create Response

- `ChatCreateResponse`

  Summary of a chat session, including its title and last run metadata.

  - `last_updated_at: string`

    ISO-format timestamp showing when the session was last updated.

  - `session_id: string`

    Unique session identifier.

  - `generated_title?: string | null`

    Auto-generated title derived from the first user message.

  - `index_ids?: Array<string> | null`

    Indexes this session is bound to. Null on unbound sessions.

  - `job_metadata?: JobMetadata | null`

    Token usage and status from the most recent run. Null if the session has not been run yet.

    - `duration_ms?: number`

    - `error?: string | null`

    - `export_config_ids?: Array<string> | null`

    - `is_error?: boolean`

    - `total_input_tokens?: number | null`

    - `total_output_tokens?: number | null`

    - `turns?: number`

### Chat Retrieve Response

- `ChatRetrieveResponse`

  Full chat session including its complete event history.

  - `events: Array<ThinkingDeltaEvent | TextDeltaEvent | ThinkingEvent | 5 more>`

    Ordered list of events that make up the conversation history.

    - `ThinkingDeltaEvent`

      - `content: string`

      - `type?: "thinking_delta"`

        - `"thinking_delta"`

    - `TextDeltaEvent`

      - `content: string`

      - `type?: "text_delta"`

        - `"text_delta"`

    - `ThinkingEvent`

      - `content: string`

      - `type?: "thinking"`

        - `"thinking"`

    - `TextEvent`

      - `content: string`

      - `type?: "text"`

        - `"text"`

    - `ToolCallEvent`

      - `arguments: Record<string, unknown>`

      - `call_id: string`

      - `name: string`

      - `type?: "tool_call"`

        - `"tool_call"`

    - `ToolResultEvent`

      - `call_id: string`

      - `name: string`

      - `result: unknown`

      - `image_attachment?: ImageAttachment | null`

        Coordinates for lazily resolving a page screenshot presigned URL.

        - `attachment_name: string`

        - `source_id: string`

      - `type?: "tool_result"`

        - `"tool_result"`

    - `StopEvent`

      - `error: string | null`

      - `is_error: boolean`

      - `usage: Usage`

        - `duration_ms?: number`

        - `total_input_tokens?: number | null`

        - `total_output_tokens?: number | null`

        - `turns?: number`

      - `type?: "stop"`

        - `"stop"`

    - `UserInputEvent`

      - `content: string`

      - `type?: "user_input"`

        - `"user_input"`

  - `last_updated_at: string`

    ISO-format timestamp showing when the session was last updated.

  - `session_id: string`

    Unique session identifier.

  - `generated_title?: string | null`

    Auto-generated title derived from the first user message.

  - `index_ids?: Array<string> | null`

    Indexes this session is bound to. Null on unbound sessions.

  - `job_metadata?: JobMetadata | null`

    Token usage and status from the most recent run. Null if the session has not been run yet.

    - `duration_ms?: number`

    - `error?: string | null`

    - `export_config_ids?: Array<string> | null`

    - `is_error?: boolean`

    - `total_input_tokens?: number | null`

    - `total_output_tokens?: number | null`

    - `turns?: number`

### Chat Get Summary Response

- `ChatGetSummaryResponse`

  Summary of a chat session, including its title and last run metadata.

  - `last_updated_at: string`

    ISO-format timestamp showing when the session was last updated.

  - `session_id: string`

    Unique session identifier.

  - `generated_title?: string | null`

    Auto-generated title derived from the first user message.

  - `index_ids?: Array<string> | null`

    Indexes this session is bound to. Null on unbound sessions.

  - `job_metadata?: JobMetadata | null`

    Token usage and status from the most recent run. Null if the session has not been run yet.

    - `duration_ms?: number`

    - `error?: string | null`

    - `export_config_ids?: Array<string> | null`

    - `is_error?: boolean`

    - `total_input_tokens?: number | null`

    - `total_output_tokens?: number | null`

    - `turns?: number`

### Chat Set Title Response

- `ChatSetTitleResponse`

  Summary of a chat session, including its title and last run metadata.

  - `last_updated_at: string`

    ISO-format timestamp showing when the session was last updated.

  - `session_id: string`

    Unique session identifier.

  - `generated_title?: string | null`

    Auto-generated title derived from the first user message.

  - `index_ids?: Array<string> | null`

    Indexes this session is bound to. Null on unbound sessions.

  - `job_metadata?: JobMetadata | null`

    Token usage and status from the most recent run. Null if the session has not been run yet.

    - `duration_ms?: number`

    - `error?: string | null`

    - `export_config_ids?: Array<string> | null`

    - `is_error?: boolean`

    - `total_input_tokens?: number | null`

    - `total_output_tokens?: number | null`

    - `turns?: number`

### Chat Stream Response

- `ChatStreamResponse = unknown`
