# Chat

## List Sessions

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

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

List all chat sessions for the current project.

### Parameters

- `query ChatListParams`

  - `OrganizationID param.Field[string]`

  - `PageSize param.Field[int64]`

  - `PageToken param.Field[string]`

  - `ProjectID param.Field[string]`

### Returns

- `type ChatListResponse 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.

  - `SharedAccess ChatListResponseSharedAccess`

    What this chat's share link grants: read_only (transcript only) or query (viewers may ask new questions).

    - `const ChatListResponseSharedAccessQuery ChatListResponseSharedAccess = "query"`

    - `const ChatListResponseSharedAccessReadOnly ChatListResponseSharedAccess = "read_only"`

  - `GeneratedTitle string`

    Auto-generated title derived from the first user message.

  - `IndexIDs []string`

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

  - `JobMetadata ChatListResponseJobMetadata`

    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/run-llama/llama-parse-go"
  "github.com/run-llama/llama-parse-go/option"
)

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

  })
  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",
      "shared_access": "read_only",
      "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.Chat.New(ctx, params) (*ChatNewResponse, error)`

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

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

### Parameters

- `params ChatNewParams`

  - `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.

  - `SharedAccess param.Field[ChatNewParamsSharedAccess]`

    Body param: What this chat's share link grants: read_only (transcript only) or query (viewers may ask new questions). Null follows the deployment default.

    - `const ChatNewParamsSharedAccessQuery ChatNewParamsSharedAccess = "query"`

    - `const ChatNewParamsSharedAccessReadOnly ChatNewParamsSharedAccess = "read_only"`

### Returns

- `type ChatNewResponse 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.

  - `SharedAccess ChatNewResponseSharedAccess`

    What this chat's share link grants: read_only (transcript only) or query (viewers may ask new questions).

    - `const ChatNewResponseSharedAccessQuery ChatNewResponseSharedAccess = "query"`

    - `const ChatNewResponseSharedAccessReadOnly ChatNewResponseSharedAccess = "read_only"`

  - `GeneratedTitle string`

    Auto-generated title derived from the first user message.

  - `IndexIDs []string`

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

  - `JobMetadata ChatNewResponseJobMetadata`

    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/run-llama/llama-parse-go"
  "github.com/run-llama/llama-parse-go/option"
)

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

  })
  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",
  "shared_access": "read_only",
  "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.Chat.Get(ctx, sessionID, query) (*ChatGetResponse, error)`

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

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

### Parameters

- `sessionID string`

- `query ChatGetParams`

  - `OrganizationID param.Field[string]`

  - `ProjectID param.Field[string]`

### Returns

- `type ChatGetResponse struct{…}`

  Full chat session including its complete event history.

  - `Events []ChatGetResponseEventUnion`

    Ordered list of events that make up the conversation history.

    - `type ChatGetResponseEventStop struct{…}`

      - `Error string`

      - `IsError bool`

      - `Usage ChatGetResponseEventStopUsage`

        - `DurationMs float64`

        - `TotalInputTokens int64`

        - `TotalOutputTokens int64`

        - `Turns int64`

      - `SkippedIndexIDs []string`

        Requested indexes this turn could not query.

      - `Type string`

        - `const ChatGetResponseEventStopTypeStop ChatGetResponseEventStopType = "stop"`

    - `type ChatGetResponseEventTextDelta struct{…}`

      - `Content string`

      - `Type string`

        - `const ChatGetResponseEventTextDeltaTypeTextDelta ChatGetResponseEventTextDeltaType = "text_delta"`

    - `type ChatGetResponseEventText struct{…}`

      - `Content string`

      - `Type string`

        - `const ChatGetResponseEventTextTypeText ChatGetResponseEventTextType = "text"`

    - `type ChatGetResponseEventThinkingDelta struct{…}`

      - `Content string`

      - `Type string`

        - `const ChatGetResponseEventThinkingDeltaTypeThinkingDelta ChatGetResponseEventThinkingDeltaType = "thinking_delta"`

    - `type ChatGetResponseEventThinking struct{…}`

      - `Content string`

      - `Type string`

        - `const ChatGetResponseEventThinkingTypeThinking ChatGetResponseEventThinkingType = "thinking"`

    - `type ChatGetResponseEventToolCall struct{…}`

      - `Arguments map[string, any]`

      - `CallID string`

      - `Name string`

      - `Type string`

        - `const ChatGetResponseEventToolCallTypeToolCall ChatGetResponseEventToolCallType = "tool_call"`

    - `type ChatGetResponseEventToolResult struct{…}`

      - `CallID string`

      - `Name string`

      - `Result any`

      - `ImageAttachment ChatGetResponseEventToolResultImageAttachment`

        Coordinates for lazily resolving a page screenshot presigned URL.

        - `AttachmentName string`

        - `SourceID string`

      - `Type string`

        - `const ChatGetResponseEventToolResultTypeToolResult ChatGetResponseEventToolResultType = "tool_result"`

    - `type ChatGetResponseEventUserInput struct{…}`

      - `Content string`

      - `Type string`

        - `const ChatGetResponseEventUserInputTypeUserInput ChatGetResponseEventUserInputType = "user_input"`

  - `LastUpdatedAt string`

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

  - `SessionID string`

    Unique session identifier.

  - `SharedAccess ChatGetResponseSharedAccess`

    What this chat's share link grants: read_only (transcript only) or query (viewers may ask new questions).

    - `const ChatGetResponseSharedAccessQuery ChatGetResponseSharedAccess = "query"`

    - `const ChatGetResponseSharedAccessReadOnly ChatGetResponseSharedAccess = "read_only"`

  - `GeneratedTitle string`

    Auto-generated title derived from the first user message.

  - `IndexIDs []string`

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

  - `JobMetadata ChatGetResponseJobMetadata`

    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/run-llama/llama-parse-go"
  "github.com/run-llama/llama-parse-go/option"
)

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

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

#### Response

```json
{
  "events": [
    {
      "error": "error",
      "is_error": true,
      "usage": {
        "duration_ms": 0,
        "total_input_tokens": 0,
        "total_output_tokens": 0,
        "turns": 0
      },
      "skipped_index_ids": [
        "string"
      ],
      "type": "stop"
    }
  ],
  "last_updated_at": "2026-04-22T12:34:41.342245",
  "session_id": "ses-abc123",
  "shared_access": "read_only",
  "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.Chat.Delete(ctx, sessionID, body) error`

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

Delete a session.

### Parameters

- `sessionID string`

- `body ChatDeleteParams`

  - `OrganizationID param.Field[string]`

  - `ProjectID param.Field[string]`

### Example

```go
package main

import (
  "context"

  "github.com/run-llama/llama-parse-go"
  "github.com/run-llama/llama-parse-go/option"
)

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

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

## Get Session Summary

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

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

Retrieve a session summary by ID.

### Parameters

- `sessionID string`

- `query ChatGetSummaryParams`

  - `OrganizationID param.Field[string]`

  - `ProjectID param.Field[string]`

### Returns

- `type ChatGetSummaryResponse 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.

  - `SharedAccess ChatGetSummaryResponseSharedAccess`

    What this chat's share link grants: read_only (transcript only) or query (viewers may ask new questions).

    - `const ChatGetSummaryResponseSharedAccessQuery ChatGetSummaryResponseSharedAccess = "query"`

    - `const ChatGetSummaryResponseSharedAccessReadOnly ChatGetSummaryResponseSharedAccess = "read_only"`

  - `GeneratedTitle string`

    Auto-generated title derived from the first user message.

  - `IndexIDs []string`

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

  - `JobMetadata ChatGetSummaryResponseJobMetadata`

    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/run-llama/llama-parse-go"
  "github.com/run-llama/llama-parse-go/option"
)

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

    },
  )
  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",
  "shared_access": "read_only",
  "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.Chat.Stream(ctx, sessionID, params) (*ChatStreamResponse, error)`

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

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

### Parameters

- `sessionID string`

- `params ChatStreamParams`

  - `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

  - `RequireAllIndexes param.Field[bool]`

    Body param: Fail the turn if any requested index cannot be queried.

### Returns

- `type ChatStreamResponse interface{…}`

### Example

```go
package main

import (
  "context"
  "fmt"

  "github.com/run-llama/llama-parse-go"
  "github.com/run-llama/llama-parse-go/option"
)

func main() {
  client := llamacloud.NewClient(
    option.WithAPIKey("My API Key"),
  )
  response, err := client.Chat.Stream(
    context.TODO(),
    "session_id",
    llamacloud.ChatStreamParams{
      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
{}
```
