# Chat

## List Sessions

`client.Beta.Chat.List(ctx, query) (*PaginatedCursor[BetaChatListResponse], error)`

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

List all chat sessions for the current project.

### Parameters

- `query BetaChatListParams`

  - `OrganizationID param.Field[string]`

  - `PageSize param.Field[int64]`

  - `PageToken param.Field[string]`

  - `ProjectID param.Field[string]`

### Returns

- `type BetaChatListResponse struct{…}`

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

  - `LastUpdatedAt string`

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

  - `SessionID string`

    Unique session identifier.

  - `GeneratedTitle string`

    Auto-generated title derived from the first user message.

  - `IndexIDs []string`

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

  - `JobMetadata BetaChatListResponseJobMetadata`

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

    - `DurationMs float64`

    - `Error string`

    - `ExportConfigIDs []string`

    - `IsError bool`

    - `TotalInputTokens int64`

    - `TotalOutputTokens int64`

    - `Turns int64`

### Example

```go
package main

import (
  "context"
  "fmt"

  "github.com/stainless-sdks/llamacloud-prod-go"
  "github.com/stainless-sdks/llamacloud-prod-go/option"
)

func main() {
  client := llamacloudprod.NewClient(
    option.WithAPIKey("My API Key"),
  )
  page, err := client.Beta.Chat.List(context.TODO(), llamacloudprod.BetaChatListParams{

  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", page)
}
```

#### 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.New(ctx, params) (*BetaChatNewResponse, error)`

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

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

### Parameters

- `params BetaChatNewParams`

  - `OrganizationID param.Field[string]`

    Query param

  - `ProjectID param.Field[string]`

    Query param

  - `IndexIDs param.Field[[]string]`

    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

- `type BetaChatNewResponse struct{…}`

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

  - `LastUpdatedAt string`

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

  - `SessionID string`

    Unique session identifier.

  - `GeneratedTitle string`

    Auto-generated title derived from the first user message.

  - `IndexIDs []string`

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

  - `JobMetadata BetaChatNewResponseJobMetadata`

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

    - `DurationMs float64`

    - `Error string`

    - `ExportConfigIDs []string`

    - `IsError bool`

    - `TotalInputTokens int64`

    - `TotalOutputTokens int64`

    - `Turns int64`

### Example

```go
package main

import (
  "context"
  "fmt"

  "github.com/stainless-sdks/llamacloud-prod-go"
  "github.com/stainless-sdks/llamacloud-prod-go/option"
)

func main() {
  client := llamacloudprod.NewClient(
    option.WithAPIKey("My API Key"),
  )
  chat, err := client.Beta.Chat.New(context.TODO(), llamacloudprod.BetaChatNewParams{

  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", chat.SessionID)
}
```

#### 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.Get(ctx, sessionID, query) (*BetaChatGetResponse, error)`

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

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

### Parameters

- `sessionID string`

- `query BetaChatGetParams`

  - `OrganizationID param.Field[string]`

  - `ProjectID param.Field[string]`

### Returns

- `type BetaChatGetResponse struct{…}`

  Full chat session including its complete event history.

  - `Events []BetaChatGetResponseEventUnion`

    Ordered list of events that make up the conversation history.

    - `type BetaChatGetResponseEventThinkingDelta struct{…}`

      - `Content string`

      - `Type string`

        - `const BetaChatGetResponseEventThinkingDeltaTypeThinkingDelta BetaChatGetResponseEventThinkingDeltaType = "thinking_delta"`

    - `type BetaChatGetResponseEventTextDelta struct{…}`

      - `Content string`

      - `Type string`

        - `const BetaChatGetResponseEventTextDeltaTypeTextDelta BetaChatGetResponseEventTextDeltaType = "text_delta"`

    - `type BetaChatGetResponseEventThinking struct{…}`

      - `Content string`

      - `Type string`

        - `const BetaChatGetResponseEventThinkingTypeThinking BetaChatGetResponseEventThinkingType = "thinking"`

    - `type BetaChatGetResponseEventText struct{…}`

      - `Content string`

      - `Type string`

        - `const BetaChatGetResponseEventTextTypeText BetaChatGetResponseEventTextType = "text"`

    - `type BetaChatGetResponseEventToolCall struct{…}`

      - `Arguments map[string, any]`

      - `CallID string`

      - `Name string`

      - `Type string`

        - `const BetaChatGetResponseEventToolCallTypeToolCall BetaChatGetResponseEventToolCallType = "tool_call"`

    - `type BetaChatGetResponseEventToolResult struct{…}`

      - `CallID string`

      - `Name string`

      - `Result any`

      - `ImageAttachment BetaChatGetResponseEventToolResultImageAttachment`

        Coordinates for lazily resolving a page screenshot presigned URL.

        - `AttachmentName string`

        - `SourceID string`

      - `Type string`

        - `const BetaChatGetResponseEventToolResultTypeToolResult BetaChatGetResponseEventToolResultType = "tool_result"`

    - `type BetaChatGetResponseEventStop struct{…}`

      - `Error string`

      - `IsError bool`

      - `Usage BetaChatGetResponseEventStopUsage`

        - `DurationMs float64`

        - `TotalInputTokens int64`

        - `TotalOutputTokens int64`

        - `Turns int64`

      - `Type string`

        - `const BetaChatGetResponseEventStopTypeStop BetaChatGetResponseEventStopType = "stop"`

    - `type BetaChatGetResponseEventUserInput struct{…}`

      - `Content string`

      - `Type string`

        - `const BetaChatGetResponseEventUserInputTypeUserInput BetaChatGetResponseEventUserInputType = "user_input"`

  - `LastUpdatedAt string`

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

  - `SessionID string`

    Unique session identifier.

  - `GeneratedTitle string`

    Auto-generated title derived from the first user message.

  - `IndexIDs []string`

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

  - `JobMetadata BetaChatGetResponseJobMetadata`

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

    - `DurationMs float64`

    - `Error string`

    - `ExportConfigIDs []string`

    - `IsError bool`

    - `TotalInputTokens int64`

    - `TotalOutputTokens int64`

    - `Turns int64`

### Example

```go
package main

import (
  "context"
  "fmt"

  "github.com/stainless-sdks/llamacloud-prod-go"
  "github.com/stainless-sdks/llamacloud-prod-go/option"
)

func main() {
  client := llamacloudprod.NewClient(
    option.WithAPIKey("My API Key"),
  )
  chat, err := client.Beta.Chat.Get(
    context.TODO(),
    "session_id",
    llamacloudprod.BetaChatGetParams{

    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", chat.SessionID)
}
```

#### 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(ctx, sessionID, body) error`

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

Delete a session.

### Parameters

- `sessionID string`

- `body BetaChatDeleteParams`

  - `OrganizationID param.Field[string]`

  - `ProjectID param.Field[string]`

### Example

```go
package main

import (
  "context"

  "github.com/stainless-sdks/llamacloud-prod-go"
  "github.com/stainless-sdks/llamacloud-prod-go/option"
)

func main() {
  client := llamacloudprod.NewClient(
    option.WithAPIKey("My API Key"),
  )
  err := client.Beta.Chat.Delete(
    context.TODO(),
    "session_id",
    llamacloudprod.BetaChatDeleteParams{

    },
  )
  if err != nil {
    panic(err.Error())
  }
}
```

## Get Session Summary

`client.Beta.Chat.GetSummary(ctx, sessionID, query) (*BetaChatGetSummaryResponse, error)`

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

Retrieve a session summary by ID.

### Parameters

- `sessionID string`

- `query BetaChatGetSummaryParams`

  - `OrganizationID param.Field[string]`

  - `ProjectID param.Field[string]`

### Returns

- `type BetaChatGetSummaryResponse struct{…}`

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

  - `LastUpdatedAt string`

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

  - `SessionID string`

    Unique session identifier.

  - `GeneratedTitle string`

    Auto-generated title derived from the first user message.

  - `IndexIDs []string`

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

  - `JobMetadata BetaChatGetSummaryResponseJobMetadata`

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

    - `DurationMs float64`

    - `Error string`

    - `ExportConfigIDs []string`

    - `IsError bool`

    - `TotalInputTokens int64`

    - `TotalOutputTokens int64`

    - `Turns int64`

### Example

```go
package main

import (
  "context"
  "fmt"

  "github.com/stainless-sdks/llamacloud-prod-go"
  "github.com/stainless-sdks/llamacloud-prod-go/option"
)

func main() {
  client := llamacloudprod.NewClient(
    option.WithAPIKey("My API Key"),
  )
  response, err := client.Beta.Chat.GetSummary(
    context.TODO(),
    "session_id",
    llamacloudprod.BetaChatGetSummaryParams{

    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", response.SessionID)
}
```

#### 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(ctx, sessionID, params) (*BetaChatSetTitleResponse, error)`

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

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

### Parameters

- `sessionID string`

- `params BetaChatSetTitleParams`

  - `FirstMessage param.Field[string]`

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

  - `OrganizationID param.Field[string]`

    Query param

  - `ProjectID param.Field[string]`

    Query param

### Returns

- `type BetaChatSetTitleResponse struct{…}`

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

  - `LastUpdatedAt string`

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

  - `SessionID string`

    Unique session identifier.

  - `GeneratedTitle string`

    Auto-generated title derived from the first user message.

  - `IndexIDs []string`

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

  - `JobMetadata BetaChatSetTitleResponseJobMetadata`

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

    - `DurationMs float64`

    - `Error string`

    - `ExportConfigIDs []string`

    - `IsError bool`

    - `TotalInputTokens int64`

    - `TotalOutputTokens int64`

    - `Turns int64`

### Example

```go
package main

import (
  "context"
  "fmt"

  "github.com/stainless-sdks/llamacloud-prod-go"
  "github.com/stainless-sdks/llamacloud-prod-go/option"
)

func main() {
  client := llamacloudprod.NewClient(
    option.WithAPIKey("My API Key"),
  )
  response, err := client.Beta.Chat.SetTitle(
    context.TODO(),
    "session_id",
    llamacloudprod.BetaChatSetTitleParams{
      FirstMessage: "What were the main findings in Q3?",
    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", response.SessionID)
}
```

#### 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(ctx, sessionID, params) (*BetaChatStreamResponse, error)`

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

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

### Parameters

- `sessionID string`

- `params BetaChatStreamParams`

  - `IndexIDs param.Field[[]string]`

    Body param: Indexes to retrieve data from.

  - `Prompt param.Field[string]`

    Body param: User message for this chat turn.

  - `OrganizationID param.Field[string]`

    Query param

  - `ProjectID param.Field[string]`

    Query param

### Returns

- `type BetaChatStreamResponse interface{…}`

### Example

```go
package main

import (
  "context"
  "fmt"

  "github.com/stainless-sdks/llamacloud-prod-go"
  "github.com/stainless-sdks/llamacloud-prod-go/option"
)

func main() {
  client := llamacloudprod.NewClient(
    option.WithAPIKey("My API Key"),
  )
  response, err := client.Beta.Chat.Stream(
    context.TODO(),
    "session_id",
    llamacloudprod.BetaChatStreamParams{
      IndexIDs: []string{"idx-abc123", "idx-def456"},
      Prompt: "What were the main findings in Q3?",
    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", response)
}
```

#### Response

```json
{}
```
