# ChatKit

## Domain Types

### ChatKit Workflow

- `type ChatKitWorkflow struct{…}`

  Workflow metadata and state returned for the session.

  - `ID string`

    Identifier of the workflow backing the session.

  - `StateVariables map[string, ChatKitWorkflowStateVariableUnion]`

    State variable key-value pairs applied when invoking the workflow. Defaults to null when no overrides were provided.

    - `string`

    - `bool`

    - `float64`

  - `Tracing ChatKitWorkflowTracing`

    Tracing settings applied to the workflow.

    - `Enabled bool`

      Indicates whether tracing is enabled.

  - `Version string`

    Specific workflow version used for the session. Defaults to null when using the latest deployment.

# Sessions

## Cancel chat session

`client.Beta.ChatKit.Sessions.Cancel(ctx, sessionID) (*ChatSession, error)`

**post** `/chatkit/sessions/{session_id}/cancel`

Cancel an active ChatKit session and return its most recent metadata.

Cancelling prevents new requests from using the issued client secret.

### Parameters

- `sessionID string`

### Returns

- `type ChatSession struct{…}`

  Represents a ChatKit session and its resolved configuration.

  - `ID string`

    Identifier for the ChatKit session.

  - `ChatKitConfiguration ChatSessionChatKitConfiguration`

    Resolved ChatKit feature configuration for the session.

    - `AutomaticThreadTitling ChatSessionAutomaticThreadTitling`

      Automatic thread titling preferences.

      - `Enabled bool`

        Whether automatic thread titling is enabled.

    - `FileUpload ChatSessionFileUpload`

      Upload settings for the session.

      - `Enabled bool`

        Indicates if uploads are enabled for the session.

      - `MaxFileSize int64`

        Maximum upload size in megabytes.

      - `MaxFiles int64`

        Maximum number of uploads allowed during the session.

    - `History ChatSessionHistory`

      History retention configuration.

      - `Enabled bool`

        Indicates if chat history is persisted for the session.

      - `RecentThreads int64`

        Number of prior threads surfaced in history views. Defaults to null when all history is retained.

  - `ClientSecret string`

    Ephemeral client secret that authenticates session requests.

  - `ExpiresAt int64`

    Unix timestamp (in seconds) for when the session expires.

  - `MaxRequestsPer1Minute int64`

    Convenience copy of the per-minute request limit.

  - `Object ChatKitSession`

    Type discriminator that is always `chatkit.session`.

    - `const ChatKitSessionChatKitSession ChatKitSession = "chatkit.session"`

  - `RateLimits ChatSessionRateLimits`

    Resolved rate limit values.

    - `MaxRequestsPer1Minute int64`

      Maximum allowed requests per one-minute window.

  - `Status ChatSessionStatus`

    Current lifecycle state of the session.

    - `const ChatSessionStatusActive ChatSessionStatus = "active"`

    - `const ChatSessionStatusExpired ChatSessionStatus = "expired"`

    - `const ChatSessionStatusCancelled ChatSessionStatus = "cancelled"`

  - `User string`

    User identifier associated with the session.

  - `Workflow ChatKitWorkflow`

    Workflow metadata for the session.

    - `ID string`

      Identifier of the workflow backing the session.

    - `StateVariables map[string, ChatKitWorkflowStateVariableUnion]`

      State variable key-value pairs applied when invoking the workflow. Defaults to null when no overrides were provided.

      - `string`

      - `bool`

      - `float64`

    - `Tracing ChatKitWorkflowTracing`

      Tracing settings applied to the workflow.

      - `Enabled bool`

        Indicates whether tracing is enabled.

    - `Version string`

      Specific workflow version used for the session. Defaults to null when using the latest deployment.

### Example

```go
package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAPIKey("My API Key"),
  )
  chatSession, err := client.Beta.ChatKit.Sessions.Cancel(context.TODO(), "cksess_123")
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", chatSession.ID)
}
```

#### Response

```json
{
  "id": "id",
  "chatkit_configuration": {
    "automatic_thread_titling": {
      "enabled": true
    },
    "file_upload": {
      "enabled": true,
      "max_file_size": 0,
      "max_files": 0
    },
    "history": {
      "enabled": true,
      "recent_threads": 0
    }
  },
  "client_secret": "client_secret",
  "expires_at": 0,
  "max_requests_per_1_minute": 0,
  "object": "chatkit.session",
  "rate_limits": {
    "max_requests_per_1_minute": 0
  },
  "status": "active",
  "user": "user",
  "workflow": {
    "id": "id",
    "state_variables": {
      "foo": "string"
    },
    "tracing": {
      "enabled": true
    },
    "version": "version"
  }
}
```

### Example

```go
package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient()
  chatSession, err := client.Beta.ChatKit.Sessions.Cancel(context.TODO(), "cksess_123")
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", chatSession.ID)
}
```

#### Response

```json
{
  "id": "cksess_123",
  "object": "chatkit.session",
  "workflow": {
    "id": "workflow_alpha",
    "version": "1"
  },
  "scope": {
    "customer_id": "cust_456"
  },
  "max_requests_per_1_minute": 30,
  "ttl_seconds": 900,
  "status": "cancelled",
  "cancelled_at": 1712345678
}
```

## Create ChatKit session

`client.Beta.ChatKit.Sessions.New(ctx, body) (*ChatSession, error)`

**post** `/chatkit/sessions`

Create a ChatKit session.

### Parameters

- `body BetaChatKitSessionNewParams`

  - `User param.Field[string]`

    A free-form string that identifies your end user; ensures this Session can access other objects that have the same `user` scope.

  - `Workflow param.Field[ChatSessionWorkflowParamResp]`

    Workflow that powers the session.

  - `ChatKitConfiguration param.Field[ChatSessionChatKitConfigurationParamResp]`

    Optional overrides for ChatKit runtime configuration features

  - `ExpiresAfter param.Field[ChatSessionExpiresAfterParamResp]`

    Optional override for session expiration timing in seconds from creation. Defaults to 10 minutes.

  - `RateLimits param.Field[ChatSessionRateLimitsParamResp]`

    Optional override for per-minute request limits. When omitted, defaults to 10.

### Returns

- `type ChatSession struct{…}`

  Represents a ChatKit session and its resolved configuration.

  - `ID string`

    Identifier for the ChatKit session.

  - `ChatKitConfiguration ChatSessionChatKitConfiguration`

    Resolved ChatKit feature configuration for the session.

    - `AutomaticThreadTitling ChatSessionAutomaticThreadTitling`

      Automatic thread titling preferences.

      - `Enabled bool`

        Whether automatic thread titling is enabled.

    - `FileUpload ChatSessionFileUpload`

      Upload settings for the session.

      - `Enabled bool`

        Indicates if uploads are enabled for the session.

      - `MaxFileSize int64`

        Maximum upload size in megabytes.

      - `MaxFiles int64`

        Maximum number of uploads allowed during the session.

    - `History ChatSessionHistory`

      History retention configuration.

      - `Enabled bool`

        Indicates if chat history is persisted for the session.

      - `RecentThreads int64`

        Number of prior threads surfaced in history views. Defaults to null when all history is retained.

  - `ClientSecret string`

    Ephemeral client secret that authenticates session requests.

  - `ExpiresAt int64`

    Unix timestamp (in seconds) for when the session expires.

  - `MaxRequestsPer1Minute int64`

    Convenience copy of the per-minute request limit.

  - `Object ChatKitSession`

    Type discriminator that is always `chatkit.session`.

    - `const ChatKitSessionChatKitSession ChatKitSession = "chatkit.session"`

  - `RateLimits ChatSessionRateLimits`

    Resolved rate limit values.

    - `MaxRequestsPer1Minute int64`

      Maximum allowed requests per one-minute window.

  - `Status ChatSessionStatus`

    Current lifecycle state of the session.

    - `const ChatSessionStatusActive ChatSessionStatus = "active"`

    - `const ChatSessionStatusExpired ChatSessionStatus = "expired"`

    - `const ChatSessionStatusCancelled ChatSessionStatus = "cancelled"`

  - `User string`

    User identifier associated with the session.

  - `Workflow ChatKitWorkflow`

    Workflow metadata for the session.

    - `ID string`

      Identifier of the workflow backing the session.

    - `StateVariables map[string, ChatKitWorkflowStateVariableUnion]`

      State variable key-value pairs applied when invoking the workflow. Defaults to null when no overrides were provided.

      - `string`

      - `bool`

      - `float64`

    - `Tracing ChatKitWorkflowTracing`

      Tracing settings applied to the workflow.

      - `Enabled bool`

        Indicates whether tracing is enabled.

    - `Version string`

      Specific workflow version used for the session. Defaults to null when using the latest deployment.

### Example

```go
package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAPIKey("My API Key"),
  )
  chatSession, err := client.Beta.ChatKit.Sessions.New(context.TODO(), openai.BetaChatKitSessionNewParams{
    User: "x",
    Workflow: openai.ChatSessionWorkflowParam{
      ID: "id",
    },
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", chatSession.ID)
}
```

#### Response

```json
{
  "id": "id",
  "chatkit_configuration": {
    "automatic_thread_titling": {
      "enabled": true
    },
    "file_upload": {
      "enabled": true,
      "max_file_size": 0,
      "max_files": 0
    },
    "history": {
      "enabled": true,
      "recent_threads": 0
    }
  },
  "client_secret": "client_secret",
  "expires_at": 0,
  "max_requests_per_1_minute": 0,
  "object": "chatkit.session",
  "rate_limits": {
    "max_requests_per_1_minute": 0
  },
  "status": "active",
  "user": "user",
  "workflow": {
    "id": "id",
    "state_variables": {
      "foo": "string"
    },
    "tracing": {
      "enabled": true
    },
    "version": "version"
  }
}
```

### Example

```go
package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient()
  chatSession, err := client.Beta.ChatKit.Sessions.New(context.TODO(), openai.BetaChatKitSessionNewParams{
    User: "user",
    Workflow: openai.ChatSessionWorkflowParam{
      ID: "id",
    },
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", chatSession.ID)
}
```

#### Response

```json
{
  "client_secret": "chatkit_token_123",
  "expires_at": 1735689600,
  "workflow": {
    "id": "workflow_alpha",
    "version": "2024-10-01"
  },
  "scope": {
    "project": "alpha",
    "environment": "staging"
  },
  "max_requests_per_1_minute": 60,
  "max_requests_per_session": 500,
  "status": "active"
}
```

# Threads

## List ChatKit thread items

`client.Beta.ChatKit.Threads.ListItems(ctx, threadID, query) (*ConversationCursorPage[ChatKitThreadItemListDataUnion], error)`

**get** `/chatkit/threads/{thread_id}/items`

List items that belong to a ChatKit thread.

### Parameters

- `threadID string`

- `query BetaChatKitThreadListItemsParams`

  - `After param.Field[string]`

    List items created after this thread item ID. Defaults to null for the first page.

  - `Before param.Field[string]`

    List items created before this thread item ID. Defaults to null for the newest results.

  - `Limit param.Field[int64]`

    Maximum number of thread items to return. Defaults to 20.

  - `Order param.Field[BetaChatKitThreadListItemsParamsOrder]`

    Sort order for results by creation time. Defaults to `desc`.

    - `const BetaChatKitThreadListItemsParamsOrderAsc BetaChatKitThreadListItemsParamsOrder = "asc"`

    - `const BetaChatKitThreadListItemsParamsOrderDesc BetaChatKitThreadListItemsParamsOrder = "desc"`

### Returns

- `type ChatKitThreadItemListDataUnion interface{…}`

  User-authored messages within a thread.

  - `type ChatKitThreadUserMessageItem struct{…}`

    User-authored messages within a thread.

    - `ID string`

      Identifier of the thread item.

    - `Attachments []ChatKitAttachment`

      Attachments associated with the user message. Defaults to an empty list.

      - `ID string`

        Identifier for the attachment.

      - `MimeType string`

        MIME type of the attachment.

      - `Name string`

        Original display name for the attachment.

      - `PreviewURL string`

        Preview URL for rendering the attachment inline.

      - `Type ChatKitAttachmentType`

        Attachment discriminator.

        - `const ChatKitAttachmentTypeImage ChatKitAttachmentType = "image"`

        - `const ChatKitAttachmentTypeFile ChatKitAttachmentType = "file"`

    - `Content []ChatKitThreadUserMessageItemContentUnion`

      Ordered content elements supplied by the user.

      - `type ChatKitThreadUserMessageItemContentInputText struct{…}`

        Text block that a user contributed to the thread.

        - `Text string`

          Plain-text content supplied by the user.

        - `Type InputText`

          Type discriminator that is always `input_text`.

          - `const InputTextInputText InputText = "input_text"`

      - `type ChatKitThreadUserMessageItemContentQuotedText struct{…}`

        Quoted snippet that the user referenced in their message.

        - `Text string`

          Quoted text content.

        - `Type QuotedText`

          Type discriminator that is always `quoted_text`.

          - `const QuotedTextQuotedText QuotedText = "quoted_text"`

    - `CreatedAt int64`

      Unix timestamp (in seconds) for when the item was created.

    - `InferenceOptions ChatKitThreadUserMessageItemInferenceOptions`

      Inference overrides applied to the message. Defaults to null when unset.

      - `Model string`

        Model name that generated the response. Defaults to null when using the session default.

      - `ToolChoice ChatKitThreadUserMessageItemInferenceOptionsToolChoice`

        Preferred tool to invoke. Defaults to null when ChatKit should auto-select.

        - `ID string`

          Identifier of the requested tool.

    - `Object ChatKitThreadItem`

      Type discriminator that is always `chatkit.thread_item`.

      - `const ChatKitThreadItemChatKitThreadItem ChatKitThreadItem = "chatkit.thread_item"`

    - `ThreadID string`

      Identifier of the parent thread.

    - `Type ChatKitUserMessage`

      - `const ChatKitUserMessageChatKitUserMessage ChatKitUserMessage = "chatkit.user_message"`

  - `type ChatKitThreadAssistantMessageItem struct{…}`

    Assistant-authored message within a thread.

    - `ID string`

      Identifier of the thread item.

    - `Content []ChatKitResponseOutputText`

      Ordered assistant response segments.

      - `Annotations []ChatKitResponseOutputTextAnnotationUnion`

        Ordered list of annotations attached to the response text.

        - `type ChatKitResponseOutputTextAnnotationFile struct{…}`

          Annotation that references an uploaded file.

          - `Source ChatKitResponseOutputTextAnnotationFileSource`

            File attachment referenced by the annotation.

            - `Filename string`

              Filename referenced by the annotation.

            - `Type File`

              Type discriminator that is always `file`.

              - `const FileFile File = "file"`

          - `Type File`

            Type discriminator that is always `file` for this annotation.

            - `const FileFile File = "file"`

        - `type ChatKitResponseOutputTextAnnotationURL struct{…}`

          Annotation that references a URL.

          - `Source ChatKitResponseOutputTextAnnotationURLSource`

            URL referenced by the annotation.

            - `Type URL`

              Type discriminator that is always `url`.

              - `const URLURL URL = "url"`

            - `URL string`

              URL referenced by the annotation.

          - `Type URL`

            Type discriminator that is always `url` for this annotation.

            - `const URLURL URL = "url"`

      - `Text string`

        Assistant generated text.

      - `Type OutputText`

        Type discriminator that is always `output_text`.

        - `const OutputTextOutputText OutputText = "output_text"`

    - `CreatedAt int64`

      Unix timestamp (in seconds) for when the item was created.

    - `Object ChatKitThreadItem`

      Type discriminator that is always `chatkit.thread_item`.

      - `const ChatKitThreadItemChatKitThreadItem ChatKitThreadItem = "chatkit.thread_item"`

    - `ThreadID string`

      Identifier of the parent thread.

    - `Type ChatKitAssistantMessage`

      Type discriminator that is always `chatkit.assistant_message`.

      - `const ChatKitAssistantMessageChatKitAssistantMessage ChatKitAssistantMessage = "chatkit.assistant_message"`

  - `type ChatKitWidgetItem struct{…}`

    Thread item that renders a widget payload.

    - `ID string`

      Identifier of the thread item.

    - `CreatedAt int64`

      Unix timestamp (in seconds) for when the item was created.

    - `Object ChatKitThreadItem`

      Type discriminator that is always `chatkit.thread_item`.

      - `const ChatKitThreadItemChatKitThreadItem ChatKitThreadItem = "chatkit.thread_item"`

    - `ThreadID string`

      Identifier of the parent thread.

    - `Type ChatKitWidget`

      Type discriminator that is always `chatkit.widget`.

      - `const ChatKitWidgetChatKitWidget ChatKitWidget = "chatkit.widget"`

    - `Widget string`

      Serialized widget payload rendered in the UI.

  - `type ChatKitThreadItemListDataChatKitClientToolCall struct{…}`

    Record of a client side tool invocation initiated by the assistant.

    - `ID string`

      Identifier of the thread item.

    - `Arguments string`

      JSON-encoded arguments that were sent to the tool.

    - `CallID string`

      Identifier for the client tool call.

    - `CreatedAt int64`

      Unix timestamp (in seconds) for when the item was created.

    - `Name string`

      Tool name that was invoked.

    - `Object ChatKitThreadItem`

      Type discriminator that is always `chatkit.thread_item`.

      - `const ChatKitThreadItemChatKitThreadItem ChatKitThreadItem = "chatkit.thread_item"`

    - `Output string`

      JSON-encoded output captured from the tool. Defaults to null while execution is in progress.

    - `Status string`

      Execution status for the tool call.

      - `const ChatKitThreadItemListDataChatKitClientToolCallStatusInProgress ChatKitThreadItemListDataChatKitClientToolCallStatus = "in_progress"`

      - `const ChatKitThreadItemListDataChatKitClientToolCallStatusCompleted ChatKitThreadItemListDataChatKitClientToolCallStatus = "completed"`

    - `ThreadID string`

      Identifier of the parent thread.

    - `Type ChatKitClientToolCall`

      Type discriminator that is always `chatkit.client_tool_call`.

      - `const ChatKitClientToolCallChatKitClientToolCall ChatKitClientToolCall = "chatkit.client_tool_call"`

  - `type ChatKitThreadItemListDataChatKitTask struct{…}`

    Task emitted by the workflow to show progress and status updates.

    - `ID string`

      Identifier of the thread item.

    - `CreatedAt int64`

      Unix timestamp (in seconds) for when the item was created.

    - `Heading string`

      Optional heading for the task. Defaults to null when not provided.

    - `Object ChatKitThreadItem`

      Type discriminator that is always `chatkit.thread_item`.

      - `const ChatKitThreadItemChatKitThreadItem ChatKitThreadItem = "chatkit.thread_item"`

    - `Summary string`

      Optional summary that describes the task. Defaults to null when omitted.

    - `TaskType string`

      Subtype for the task.

      - `const ChatKitThreadItemListDataChatKitTaskTaskTypeCustom ChatKitThreadItemListDataChatKitTaskTaskType = "custom"`

      - `const ChatKitThreadItemListDataChatKitTaskTaskTypeThought ChatKitThreadItemListDataChatKitTaskTaskType = "thought"`

    - `ThreadID string`

      Identifier of the parent thread.

    - `Type ChatKitTask`

      Type discriminator that is always `chatkit.task`.

      - `const ChatKitTaskChatKitTask ChatKitTask = "chatkit.task"`

  - `type ChatKitThreadItemListDataChatKitTaskGroup struct{…}`

    Collection of workflow tasks grouped together in the thread.

    - `ID string`

      Identifier of the thread item.

    - `CreatedAt int64`

      Unix timestamp (in seconds) for when the item was created.

    - `Object ChatKitThreadItem`

      Type discriminator that is always `chatkit.thread_item`.

      - `const ChatKitThreadItemChatKitThreadItem ChatKitThreadItem = "chatkit.thread_item"`

    - `Tasks []ChatKitThreadItemListDataChatKitTaskGroupTask`

      Tasks included in the group.

      - `Heading string`

        Optional heading for the grouped task. Defaults to null when not provided.

      - `Summary string`

        Optional summary that describes the grouped task. Defaults to null when omitted.

      - `Type string`

        Subtype for the grouped task.

        - `const ChatKitThreadItemListDataChatKitTaskGroupTaskTypeCustom ChatKitThreadItemListDataChatKitTaskGroupTaskType = "custom"`

        - `const ChatKitThreadItemListDataChatKitTaskGroupTaskTypeThought ChatKitThreadItemListDataChatKitTaskGroupTaskType = "thought"`

    - `ThreadID string`

      Identifier of the parent thread.

    - `Type ChatKitTaskGroup`

      Type discriminator that is always `chatkit.task_group`.

      - `const ChatKitTaskGroupChatKitTaskGroup ChatKitTaskGroup = "chatkit.task_group"`

### Example

```go
package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAPIKey("My API Key"),
  )
  page, err := client.Beta.ChatKit.Threads.ListItems(
    context.TODO(),
    "cthr_123",
    openai.BetaChatKitThreadListItemsParams{

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

#### Response

```json
{
  "data": [
    {
      "id": "id",
      "attachments": [
        {
          "id": "id",
          "mime_type": "mime_type",
          "name": "name",
          "preview_url": "preview_url",
          "type": "image"
        }
      ],
      "content": [
        {
          "text": "text",
          "type": "input_text"
        }
      ],
      "created_at": 0,
      "inference_options": {
        "model": "model",
        "tool_choice": {
          "id": "id"
        }
      },
      "object": "chatkit.thread_item",
      "thread_id": "thread_id",
      "type": "chatkit.user_message"
    }
  ],
  "first_id": "first_id",
  "has_more": true,
  "last_id": "last_id",
  "object": "list"
}
```

### Example

```go
package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient()
  page, err := client.Beta.ChatKit.Threads.ListItems(
    context.TODO(),
    "cthr_123",
    openai.BetaChatKitThreadListItemsParams{

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

#### Response

```json
{
  "data": [
    {
      "id": "cthi_user_001",
      "object": "chatkit.thread_item",
      "type": "user_message",
      "content": [
        {
          "type": "input_text",
          "text": "I need help debugging an onboarding issue."
        }
      ],
      "attachments": []
    },
    {
      "id": "cthi_assistant_002",
      "object": "chatkit.thread_item",
      "type": "assistant_message",
      "content": [
        {
          "type": "output_text",
          "text": "Let's start by confirming the workflow version you deployed."
        }
      ]
    }
  ],
  "has_more": false,
  "object": "list"
}
```

## Retrieve ChatKit thread

`client.Beta.ChatKit.Threads.Get(ctx, threadID) (*ChatKitThread, error)`

**get** `/chatkit/threads/{thread_id}`

Retrieve a ChatKit thread by its identifier.

### Parameters

- `threadID string`

### Returns

- `type ChatKitThread struct{…}`

  Represents a ChatKit thread and its current status.

  - `ID string`

    Identifier of the thread.

  - `CreatedAt int64`

    Unix timestamp (in seconds) for when the thread was created.

  - `Object ChatKitThread`

    Type discriminator that is always `chatkit.thread`.

    - `const ChatKitThreadChatKitThread ChatKitThread = "chatkit.thread"`

  - `Status ChatKitThreadStatusUnion`

    Current status for the thread. Defaults to `active` for newly created threads.

    - `type ChatKitThreadStatusActive struct{…}`

      Indicates that a thread is active.

      - `Type Active`

        Status discriminator that is always `active`.

        - `const ActiveActive Active = "active"`

    - `type ChatKitThreadStatusLocked struct{…}`

      Indicates that a thread is locked and cannot accept new input.

      - `Reason string`

        Reason that the thread was locked. Defaults to null when no reason is recorded.

      - `Type Locked`

        Status discriminator that is always `locked`.

        - `const LockedLocked Locked = "locked"`

    - `type ChatKitThreadStatusClosed struct{…}`

      Indicates that a thread has been closed.

      - `Reason string`

        Reason that the thread was closed. Defaults to null when no reason is recorded.

      - `Type Closed`

        Status discriminator that is always `closed`.

        - `const ClosedClosed Closed = "closed"`

  - `Title string`

    Optional human-readable title for the thread. Defaults to null when no title has been generated.

  - `User string`

    Free-form string that identifies your end user who owns the thread.

### Example

```go
package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAPIKey("My API Key"),
  )
  chatkitThread, err := client.Beta.ChatKit.Threads.Get(context.TODO(), "cthr_123")
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", chatkitThread.ID)
}
```

#### Response

```json
{
  "id": "cthr_def456",
  "created_at": 1712345600,
  "object": "chatkit.thread",
  "status": {
    "type": "active"
  },
  "title": "Demo feedback",
  "user": "user_456"
}
```

### Example

```go
package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
)

func main() {
  client := openai.NewClient()
  chatkitThread, err := client.Beta.ChatKit.Threads.Get(context.TODO(), "cthr_123")
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", chatkitThread.ID)
}
```

#### Response

```json
{
  "id": "cthr_abc123",
  "object": "chatkit.thread",
  "title": "Customer escalation",
  "items": {
    "data": [
      {
        "id": "cthi_user_001",
        "object": "chatkit.thread_item",
        "type": "user_message",
        "content": [
          {
            "type": "input_text",
            "text": "I need help debugging an onboarding issue."
          }
        ],
        "attachments": []
      },
      {
        "id": "cthi_assistant_002",
        "object": "chatkit.thread_item",
        "type": "assistant_message",
        "content": [
          {
            "type": "output_text",
            "text": "Let's start by confirming the workflow version you deployed."
          }
        ]
      }
    ],
    "has_more": false
  }
}
```

## Delete ChatKit thread

`client.Beta.ChatKit.Threads.Delete(ctx, threadID) (*BetaChatKitThreadDeleteResponse, error)`

**delete** `/chatkit/threads/{thread_id}`

Delete a ChatKit thread along with its items and stored attachments.

### Parameters

- `threadID string`

### Returns

- `type BetaChatKitThreadDeleteResponse struct{…}`

  Confirmation payload returned after deleting a thread.

  - `ID string`

    Identifier of the deleted thread.

  - `Deleted bool`

    Indicates that the thread has been deleted.

  - `Object ChatKitThreadDeleted`

    Type discriminator that is always `chatkit.thread.deleted`.

    - `const ChatKitThreadDeletedChatKitThreadDeleted ChatKitThreadDeleted = "chatkit.thread.deleted"`

### Example

```go
package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAPIKey("My API Key"),
  )
  thread, err := client.Beta.ChatKit.Threads.Delete(context.TODO(), "cthr_123")
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", thread.ID)
}
```

#### Response

```json
{
  "id": "id",
  "deleted": true,
  "object": "chatkit.thread.deleted"
}
```

### Example

```go
package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
)

func main() {
  client := openai.NewClient()
  thread, err := client.Beta.ChatKit.Threads.Delete(context.TODO(), "cthr_123")
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", thread.ID)
}
```

## List ChatKit threads

`client.Beta.ChatKit.Threads.List(ctx, query) (*ConversationCursorPage[ChatKitThread], error)`

**get** `/chatkit/threads`

List ChatKit threads with optional pagination and user filters.

### Parameters

- `query BetaChatKitThreadListParams`

  - `After param.Field[string]`

    List items created after this thread item ID. Defaults to null for the first page.

  - `Before param.Field[string]`

    List items created before this thread item ID. Defaults to null for the newest results.

  - `Limit param.Field[int64]`

    Maximum number of thread items to return. Defaults to 20.

  - `Order param.Field[BetaChatKitThreadListParamsOrder]`

    Sort order for results by creation time. Defaults to `desc`.

    - `const BetaChatKitThreadListParamsOrderAsc BetaChatKitThreadListParamsOrder = "asc"`

    - `const BetaChatKitThreadListParamsOrderDesc BetaChatKitThreadListParamsOrder = "desc"`

  - `User param.Field[string]`

    Filter threads that belong to this user identifier. Defaults to null to return all users.

### Returns

- `type ChatKitThread struct{…}`

  Represents a ChatKit thread and its current status.

  - `ID string`

    Identifier of the thread.

  - `CreatedAt int64`

    Unix timestamp (in seconds) for when the thread was created.

  - `Object ChatKitThread`

    Type discriminator that is always `chatkit.thread`.

    - `const ChatKitThreadChatKitThread ChatKitThread = "chatkit.thread"`

  - `Status ChatKitThreadStatusUnion`

    Current status for the thread. Defaults to `active` for newly created threads.

    - `type ChatKitThreadStatusActive struct{…}`

      Indicates that a thread is active.

      - `Type Active`

        Status discriminator that is always `active`.

        - `const ActiveActive Active = "active"`

    - `type ChatKitThreadStatusLocked struct{…}`

      Indicates that a thread is locked and cannot accept new input.

      - `Reason string`

        Reason that the thread was locked. Defaults to null when no reason is recorded.

      - `Type Locked`

        Status discriminator that is always `locked`.

        - `const LockedLocked Locked = "locked"`

    - `type ChatKitThreadStatusClosed struct{…}`

      Indicates that a thread has been closed.

      - `Reason string`

        Reason that the thread was closed. Defaults to null when no reason is recorded.

      - `Type Closed`

        Status discriminator that is always `closed`.

        - `const ClosedClosed Closed = "closed"`

  - `Title string`

    Optional human-readable title for the thread. Defaults to null when no title has been generated.

  - `User string`

    Free-form string that identifies your end user who owns the thread.

### Example

```go
package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAPIKey("My API Key"),
  )
  page, err := client.Beta.ChatKit.Threads.List(context.TODO(), openai.BetaChatKitThreadListParams{

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

#### Response

```json
{
  "data": [
    {
      "id": "cthr_def456",
      "created_at": 1712345600,
      "object": "chatkit.thread",
      "status": {
        "type": "active"
      },
      "title": "Demo feedback",
      "user": "user_456"
    }
  ],
  "first_id": "first_id",
  "has_more": true,
  "last_id": "last_id",
  "object": "list"
}
```

### Example

```go
package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
)

func main() {
  client := openai.NewClient()
  page, err := client.Beta.ChatKit.Threads.List(context.TODO(), openai.BetaChatKitThreadListParams{

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

#### Response

```json
{
  "data": [
    {
      "id": "cthr_abc123",
      "object": "chatkit.thread",
      "title": "Customer escalation"
    },
    {
      "id": "cthr_def456",
      "object": "chatkit.thread",
      "title": "Demo feedback"
    }
  ],
  "has_more": false,
  "object": "list"
}
```

## Domain Types

### Chat Session

- `type ChatSession struct{…}`

  Represents a ChatKit session and its resolved configuration.

  - `ID string`

    Identifier for the ChatKit session.

  - `ChatKitConfiguration ChatSessionChatKitConfiguration`

    Resolved ChatKit feature configuration for the session.

    - `AutomaticThreadTitling ChatSessionAutomaticThreadTitling`

      Automatic thread titling preferences.

      - `Enabled bool`

        Whether automatic thread titling is enabled.

    - `FileUpload ChatSessionFileUpload`

      Upload settings for the session.

      - `Enabled bool`

        Indicates if uploads are enabled for the session.

      - `MaxFileSize int64`

        Maximum upload size in megabytes.

      - `MaxFiles int64`

        Maximum number of uploads allowed during the session.

    - `History ChatSessionHistory`

      History retention configuration.

      - `Enabled bool`

        Indicates if chat history is persisted for the session.

      - `RecentThreads int64`

        Number of prior threads surfaced in history views. Defaults to null when all history is retained.

  - `ClientSecret string`

    Ephemeral client secret that authenticates session requests.

  - `ExpiresAt int64`

    Unix timestamp (in seconds) for when the session expires.

  - `MaxRequestsPer1Minute int64`

    Convenience copy of the per-minute request limit.

  - `Object ChatKitSession`

    Type discriminator that is always `chatkit.session`.

    - `const ChatKitSessionChatKitSession ChatKitSession = "chatkit.session"`

  - `RateLimits ChatSessionRateLimits`

    Resolved rate limit values.

    - `MaxRequestsPer1Minute int64`

      Maximum allowed requests per one-minute window.

  - `Status ChatSessionStatus`

    Current lifecycle state of the session.

    - `const ChatSessionStatusActive ChatSessionStatus = "active"`

    - `const ChatSessionStatusExpired ChatSessionStatus = "expired"`

    - `const ChatSessionStatusCancelled ChatSessionStatus = "cancelled"`

  - `User string`

    User identifier associated with the session.

  - `Workflow ChatKitWorkflow`

    Workflow metadata for the session.

    - `ID string`

      Identifier of the workflow backing the session.

    - `StateVariables map[string, ChatKitWorkflowStateVariableUnion]`

      State variable key-value pairs applied when invoking the workflow. Defaults to null when no overrides were provided.

      - `string`

      - `bool`

      - `float64`

    - `Tracing ChatKitWorkflowTracing`

      Tracing settings applied to the workflow.

      - `Enabled bool`

        Indicates whether tracing is enabled.

    - `Version string`

      Specific workflow version used for the session. Defaults to null when using the latest deployment.

### Chat Session Automatic Thread Titling

- `type ChatSessionAutomaticThreadTitling struct{…}`

  Automatic thread title preferences for the session.

  - `Enabled bool`

    Whether automatic thread titling is enabled.

### Chat Session ChatKit Configuration

- `type ChatSessionChatKitConfiguration struct{…}`

  ChatKit configuration for the session.

  - `AutomaticThreadTitling ChatSessionAutomaticThreadTitling`

    Automatic thread titling preferences.

    - `Enabled bool`

      Whether automatic thread titling is enabled.

  - `FileUpload ChatSessionFileUpload`

    Upload settings for the session.

    - `Enabled bool`

      Indicates if uploads are enabled for the session.

    - `MaxFileSize int64`

      Maximum upload size in megabytes.

    - `MaxFiles int64`

      Maximum number of uploads allowed during the session.

  - `History ChatSessionHistory`

    History retention configuration.

    - `Enabled bool`

      Indicates if chat history is persisted for the session.

    - `RecentThreads int64`

      Number of prior threads surfaced in history views. Defaults to null when all history is retained.

### Chat Session ChatKit Configuration Param

- `type ChatSessionChatKitConfigurationParamResp struct{…}`

  Optional per-session configuration settings for ChatKit behavior.

  - `AutomaticThreadTitling ChatSessionChatKitConfigurationParamAutomaticThreadTitlingResp`

    Configuration for automatic thread titling. When omitted, automatic thread titling is enabled by default.

    - `Enabled bool`

      Enable automatic thread title generation. Defaults to true.

  - `FileUpload ChatSessionChatKitConfigurationParamFileUploadResp`

    Configuration for upload enablement and limits. When omitted, uploads are disabled by default (max_files 10, max_file_size 512 MB).

    - `Enabled bool`

      Enable uploads for this session. Defaults to false.

    - `MaxFileSize int64`

      Maximum size in megabytes for each uploaded file. Defaults to 512 MB, which is the maximum allowable size.

    - `MaxFiles int64`

      Maximum number of files that can be uploaded to the session. Defaults to 10.

  - `History ChatSessionChatKitConfigurationParamHistoryResp`

    Configuration for chat history retention. When omitted, history is enabled by default with no limit on recent_threads (null).

    - `Enabled bool`

      Enables chat users to access previous ChatKit threads. Defaults to true.

    - `RecentThreads int64`

      Number of recent ChatKit threads users have access to. Defaults to unlimited when unset.

### Chat Session Expires After Param

- `type ChatSessionExpiresAfterParamResp struct{…}`

  Controls when the session expires relative to an anchor timestamp.

  - `Anchor CreatedAt`

    Base timestamp used to calculate expiration. Currently fixed to `created_at`.

    - `const CreatedAtCreatedAt CreatedAt = "created_at"`

  - `Seconds int64`

    Number of seconds after the anchor when the session expires.

### Chat Session File Upload

- `type ChatSessionFileUpload struct{…}`

  Upload permissions and limits applied to the session.

  - `Enabled bool`

    Indicates if uploads are enabled for the session.

  - `MaxFileSize int64`

    Maximum upload size in megabytes.

  - `MaxFiles int64`

    Maximum number of uploads allowed during the session.

### Chat Session History

- `type ChatSessionHistory struct{…}`

  History retention preferences returned for the session.

  - `Enabled bool`

    Indicates if chat history is persisted for the session.

  - `RecentThreads int64`

    Number of prior threads surfaced in history views. Defaults to null when all history is retained.

### Chat Session Rate Limits

- `type ChatSessionRateLimits struct{…}`

  Active per-minute request limit for the session.

  - `MaxRequestsPer1Minute int64`

    Maximum allowed requests per one-minute window.

### Chat Session Rate Limits Param

- `type ChatSessionRateLimitsParamResp struct{…}`

  Controls request rate limits for the session.

  - `MaxRequestsPer1Minute int64`

    Maximum number of requests allowed per minute for the session. Defaults to 10.

### Chat Session Status

- `type ChatSessionStatus string`

  - `const ChatSessionStatusActive ChatSessionStatus = "active"`

  - `const ChatSessionStatusExpired ChatSessionStatus = "expired"`

  - `const ChatSessionStatusCancelled ChatSessionStatus = "cancelled"`

### Chat Session Workflow Param

- `type ChatSessionWorkflowParamResp struct{…}`

  Workflow reference and overrides applied to the chat session.

  - `ID string`

    Identifier for the workflow invoked by the session.

  - `StateVariables map[string, ChatSessionWorkflowParamStateVariableUnionResp]`

    State variables forwarded to the workflow. Keys may be up to 64 characters, values must be primitive types, and the map defaults to an empty object.

    - `string`

    - `bool`

    - `float64`

  - `Tracing ChatSessionWorkflowParamTracingResp`

    Optional tracing overrides for the workflow invocation. When omitted, tracing is enabled by default.

    - `Enabled bool`

      Whether tracing is enabled during the session. Defaults to true.

  - `Version string`

    Specific workflow version to run. Defaults to the latest deployed version.

### ChatKit Attachment

- `type ChatKitAttachment struct{…}`

  Attachment metadata included on thread items.

  - `ID string`

    Identifier for the attachment.

  - `MimeType string`

    MIME type of the attachment.

  - `Name string`

    Original display name for the attachment.

  - `PreviewURL string`

    Preview URL for rendering the attachment inline.

  - `Type ChatKitAttachmentType`

    Attachment discriminator.

    - `const ChatKitAttachmentTypeImage ChatKitAttachmentType = "image"`

    - `const ChatKitAttachmentTypeFile ChatKitAttachmentType = "file"`

### ChatKit Response Output Text

- `type ChatKitResponseOutputText struct{…}`

  Assistant response text accompanied by optional annotations.

  - `Annotations []ChatKitResponseOutputTextAnnotationUnion`

    Ordered list of annotations attached to the response text.

    - `type ChatKitResponseOutputTextAnnotationFile struct{…}`

      Annotation that references an uploaded file.

      - `Source ChatKitResponseOutputTextAnnotationFileSource`

        File attachment referenced by the annotation.

        - `Filename string`

          Filename referenced by the annotation.

        - `Type File`

          Type discriminator that is always `file`.

          - `const FileFile File = "file"`

      - `Type File`

        Type discriminator that is always `file` for this annotation.

        - `const FileFile File = "file"`

    - `type ChatKitResponseOutputTextAnnotationURL struct{…}`

      Annotation that references a URL.

      - `Source ChatKitResponseOutputTextAnnotationURLSource`

        URL referenced by the annotation.

        - `Type URL`

          Type discriminator that is always `url`.

          - `const URLURL URL = "url"`

        - `URL string`

          URL referenced by the annotation.

      - `Type URL`

        Type discriminator that is always `url` for this annotation.

        - `const URLURL URL = "url"`

  - `Text string`

    Assistant generated text.

  - `Type OutputText`

    Type discriminator that is always `output_text`.

    - `const OutputTextOutputText OutputText = "output_text"`

### ChatKit Thread

- `type ChatKitThread struct{…}`

  Represents a ChatKit thread and its current status.

  - `ID string`

    Identifier of the thread.

  - `CreatedAt int64`

    Unix timestamp (in seconds) for when the thread was created.

  - `Object ChatKitThread`

    Type discriminator that is always `chatkit.thread`.

    - `const ChatKitThreadChatKitThread ChatKitThread = "chatkit.thread"`

  - `Status ChatKitThreadStatusUnion`

    Current status for the thread. Defaults to `active` for newly created threads.

    - `type ChatKitThreadStatusActive struct{…}`

      Indicates that a thread is active.

      - `Type Active`

        Status discriminator that is always `active`.

        - `const ActiveActive Active = "active"`

    - `type ChatKitThreadStatusLocked struct{…}`

      Indicates that a thread is locked and cannot accept new input.

      - `Reason string`

        Reason that the thread was locked. Defaults to null when no reason is recorded.

      - `Type Locked`

        Status discriminator that is always `locked`.

        - `const LockedLocked Locked = "locked"`

    - `type ChatKitThreadStatusClosed struct{…}`

      Indicates that a thread has been closed.

      - `Reason string`

        Reason that the thread was closed. Defaults to null when no reason is recorded.

      - `Type Closed`

        Status discriminator that is always `closed`.

        - `const ClosedClosed Closed = "closed"`

  - `Title string`

    Optional human-readable title for the thread. Defaults to null when no title has been generated.

  - `User string`

    Free-form string that identifies your end user who owns the thread.

### ChatKit Thread Assistant Message Item

- `type ChatKitThreadAssistantMessageItem struct{…}`

  Assistant-authored message within a thread.

  - `ID string`

    Identifier of the thread item.

  - `Content []ChatKitResponseOutputText`

    Ordered assistant response segments.

    - `Annotations []ChatKitResponseOutputTextAnnotationUnion`

      Ordered list of annotations attached to the response text.

      - `type ChatKitResponseOutputTextAnnotationFile struct{…}`

        Annotation that references an uploaded file.

        - `Source ChatKitResponseOutputTextAnnotationFileSource`

          File attachment referenced by the annotation.

          - `Filename string`

            Filename referenced by the annotation.

          - `Type File`

            Type discriminator that is always `file`.

            - `const FileFile File = "file"`

        - `Type File`

          Type discriminator that is always `file` for this annotation.

          - `const FileFile File = "file"`

      - `type ChatKitResponseOutputTextAnnotationURL struct{…}`

        Annotation that references a URL.

        - `Source ChatKitResponseOutputTextAnnotationURLSource`

          URL referenced by the annotation.

          - `Type URL`

            Type discriminator that is always `url`.

            - `const URLURL URL = "url"`

          - `URL string`

            URL referenced by the annotation.

        - `Type URL`

          Type discriminator that is always `url` for this annotation.

          - `const URLURL URL = "url"`

    - `Text string`

      Assistant generated text.

    - `Type OutputText`

      Type discriminator that is always `output_text`.

      - `const OutputTextOutputText OutputText = "output_text"`

  - `CreatedAt int64`

    Unix timestamp (in seconds) for when the item was created.

  - `Object ChatKitThreadItem`

    Type discriminator that is always `chatkit.thread_item`.

    - `const ChatKitThreadItemChatKitThreadItem ChatKitThreadItem = "chatkit.thread_item"`

  - `ThreadID string`

    Identifier of the parent thread.

  - `Type ChatKitAssistantMessage`

    Type discriminator that is always `chatkit.assistant_message`.

    - `const ChatKitAssistantMessageChatKitAssistantMessage ChatKitAssistantMessage = "chatkit.assistant_message"`

### ChatKit Thread Item List

- `type ChatKitThreadItemList struct{…}`

  A paginated list of thread items rendered for the ChatKit API.

  - `Data []ChatKitThreadItemListDataUnion`

    A list of items

    - `type ChatKitThreadUserMessageItem struct{…}`

      User-authored messages within a thread.

      - `ID string`

        Identifier of the thread item.

      - `Attachments []ChatKitAttachment`

        Attachments associated with the user message. Defaults to an empty list.

        - `ID string`

          Identifier for the attachment.

        - `MimeType string`

          MIME type of the attachment.

        - `Name string`

          Original display name for the attachment.

        - `PreviewURL string`

          Preview URL for rendering the attachment inline.

        - `Type ChatKitAttachmentType`

          Attachment discriminator.

          - `const ChatKitAttachmentTypeImage ChatKitAttachmentType = "image"`

          - `const ChatKitAttachmentTypeFile ChatKitAttachmentType = "file"`

      - `Content []ChatKitThreadUserMessageItemContentUnion`

        Ordered content elements supplied by the user.

        - `type ChatKitThreadUserMessageItemContentInputText struct{…}`

          Text block that a user contributed to the thread.

          - `Text string`

            Plain-text content supplied by the user.

          - `Type InputText`

            Type discriminator that is always `input_text`.

            - `const InputTextInputText InputText = "input_text"`

        - `type ChatKitThreadUserMessageItemContentQuotedText struct{…}`

          Quoted snippet that the user referenced in their message.

          - `Text string`

            Quoted text content.

          - `Type QuotedText`

            Type discriminator that is always `quoted_text`.

            - `const QuotedTextQuotedText QuotedText = "quoted_text"`

      - `CreatedAt int64`

        Unix timestamp (in seconds) for when the item was created.

      - `InferenceOptions ChatKitThreadUserMessageItemInferenceOptions`

        Inference overrides applied to the message. Defaults to null when unset.

        - `Model string`

          Model name that generated the response. Defaults to null when using the session default.

        - `ToolChoice ChatKitThreadUserMessageItemInferenceOptionsToolChoice`

          Preferred tool to invoke. Defaults to null when ChatKit should auto-select.

          - `ID string`

            Identifier of the requested tool.

      - `Object ChatKitThreadItem`

        Type discriminator that is always `chatkit.thread_item`.

        - `const ChatKitThreadItemChatKitThreadItem ChatKitThreadItem = "chatkit.thread_item"`

      - `ThreadID string`

        Identifier of the parent thread.

      - `Type ChatKitUserMessage`

        - `const ChatKitUserMessageChatKitUserMessage ChatKitUserMessage = "chatkit.user_message"`

    - `type ChatKitThreadAssistantMessageItem struct{…}`

      Assistant-authored message within a thread.

      - `ID string`

        Identifier of the thread item.

      - `Content []ChatKitResponseOutputText`

        Ordered assistant response segments.

        - `Annotations []ChatKitResponseOutputTextAnnotationUnion`

          Ordered list of annotations attached to the response text.

          - `type ChatKitResponseOutputTextAnnotationFile struct{…}`

            Annotation that references an uploaded file.

            - `Source ChatKitResponseOutputTextAnnotationFileSource`

              File attachment referenced by the annotation.

              - `Filename string`

                Filename referenced by the annotation.

              - `Type File`

                Type discriminator that is always `file`.

                - `const FileFile File = "file"`

            - `Type File`

              Type discriminator that is always `file` for this annotation.

              - `const FileFile File = "file"`

          - `type ChatKitResponseOutputTextAnnotationURL struct{…}`

            Annotation that references a URL.

            - `Source ChatKitResponseOutputTextAnnotationURLSource`

              URL referenced by the annotation.

              - `Type URL`

                Type discriminator that is always `url`.

                - `const URLURL URL = "url"`

              - `URL string`

                URL referenced by the annotation.

            - `Type URL`

              Type discriminator that is always `url` for this annotation.

              - `const URLURL URL = "url"`

        - `Text string`

          Assistant generated text.

        - `Type OutputText`

          Type discriminator that is always `output_text`.

          - `const OutputTextOutputText OutputText = "output_text"`

      - `CreatedAt int64`

        Unix timestamp (in seconds) for when the item was created.

      - `Object ChatKitThreadItem`

        Type discriminator that is always `chatkit.thread_item`.

        - `const ChatKitThreadItemChatKitThreadItem ChatKitThreadItem = "chatkit.thread_item"`

      - `ThreadID string`

        Identifier of the parent thread.

      - `Type ChatKitAssistantMessage`

        Type discriminator that is always `chatkit.assistant_message`.

        - `const ChatKitAssistantMessageChatKitAssistantMessage ChatKitAssistantMessage = "chatkit.assistant_message"`

    - `type ChatKitWidgetItem struct{…}`

      Thread item that renders a widget payload.

      - `ID string`

        Identifier of the thread item.

      - `CreatedAt int64`

        Unix timestamp (in seconds) for when the item was created.

      - `Object ChatKitThreadItem`

        Type discriminator that is always `chatkit.thread_item`.

        - `const ChatKitThreadItemChatKitThreadItem ChatKitThreadItem = "chatkit.thread_item"`

      - `ThreadID string`

        Identifier of the parent thread.

      - `Type ChatKitWidget`

        Type discriminator that is always `chatkit.widget`.

        - `const ChatKitWidgetChatKitWidget ChatKitWidget = "chatkit.widget"`

      - `Widget string`

        Serialized widget payload rendered in the UI.

    - `type ChatKitThreadItemListDataChatKitClientToolCall struct{…}`

      Record of a client side tool invocation initiated by the assistant.

      - `ID string`

        Identifier of the thread item.

      - `Arguments string`

        JSON-encoded arguments that were sent to the tool.

      - `CallID string`

        Identifier for the client tool call.

      - `CreatedAt int64`

        Unix timestamp (in seconds) for when the item was created.

      - `Name string`

        Tool name that was invoked.

      - `Object ChatKitThreadItem`

        Type discriminator that is always `chatkit.thread_item`.

        - `const ChatKitThreadItemChatKitThreadItem ChatKitThreadItem = "chatkit.thread_item"`

      - `Output string`

        JSON-encoded output captured from the tool. Defaults to null while execution is in progress.

      - `Status string`

        Execution status for the tool call.

        - `const ChatKitThreadItemListDataChatKitClientToolCallStatusInProgress ChatKitThreadItemListDataChatKitClientToolCallStatus = "in_progress"`

        - `const ChatKitThreadItemListDataChatKitClientToolCallStatusCompleted ChatKitThreadItemListDataChatKitClientToolCallStatus = "completed"`

      - `ThreadID string`

        Identifier of the parent thread.

      - `Type ChatKitClientToolCall`

        Type discriminator that is always `chatkit.client_tool_call`.

        - `const ChatKitClientToolCallChatKitClientToolCall ChatKitClientToolCall = "chatkit.client_tool_call"`

    - `type ChatKitThreadItemListDataChatKitTask struct{…}`

      Task emitted by the workflow to show progress and status updates.

      - `ID string`

        Identifier of the thread item.

      - `CreatedAt int64`

        Unix timestamp (in seconds) for when the item was created.

      - `Heading string`

        Optional heading for the task. Defaults to null when not provided.

      - `Object ChatKitThreadItem`

        Type discriminator that is always `chatkit.thread_item`.

        - `const ChatKitThreadItemChatKitThreadItem ChatKitThreadItem = "chatkit.thread_item"`

      - `Summary string`

        Optional summary that describes the task. Defaults to null when omitted.

      - `TaskType string`

        Subtype for the task.

        - `const ChatKitThreadItemListDataChatKitTaskTaskTypeCustom ChatKitThreadItemListDataChatKitTaskTaskType = "custom"`

        - `const ChatKitThreadItemListDataChatKitTaskTaskTypeThought ChatKitThreadItemListDataChatKitTaskTaskType = "thought"`

      - `ThreadID string`

        Identifier of the parent thread.

      - `Type ChatKitTask`

        Type discriminator that is always `chatkit.task`.

        - `const ChatKitTaskChatKitTask ChatKitTask = "chatkit.task"`

    - `type ChatKitThreadItemListDataChatKitTaskGroup struct{…}`

      Collection of workflow tasks grouped together in the thread.

      - `ID string`

        Identifier of the thread item.

      - `CreatedAt int64`

        Unix timestamp (in seconds) for when the item was created.

      - `Object ChatKitThreadItem`

        Type discriminator that is always `chatkit.thread_item`.

        - `const ChatKitThreadItemChatKitThreadItem ChatKitThreadItem = "chatkit.thread_item"`

      - `Tasks []ChatKitThreadItemListDataChatKitTaskGroupTask`

        Tasks included in the group.

        - `Heading string`

          Optional heading for the grouped task. Defaults to null when not provided.

        - `Summary string`

          Optional summary that describes the grouped task. Defaults to null when omitted.

        - `Type string`

          Subtype for the grouped task.

          - `const ChatKitThreadItemListDataChatKitTaskGroupTaskTypeCustom ChatKitThreadItemListDataChatKitTaskGroupTaskType = "custom"`

          - `const ChatKitThreadItemListDataChatKitTaskGroupTaskTypeThought ChatKitThreadItemListDataChatKitTaskGroupTaskType = "thought"`

      - `ThreadID string`

        Identifier of the parent thread.

      - `Type ChatKitTaskGroup`

        Type discriminator that is always `chatkit.task_group`.

        - `const ChatKitTaskGroupChatKitTaskGroup ChatKitTaskGroup = "chatkit.task_group"`

  - `FirstID string`

    The ID of the first item in the list.

  - `HasMore bool`

    Whether there are more items available.

  - `LastID string`

    The ID of the last item in the list.

  - `Object List`

    The type of object returned, must be `list`.

    - `const ListList List = "list"`

### ChatKit Thread User Message Item

- `type ChatKitThreadUserMessageItem struct{…}`

  User-authored messages within a thread.

  - `ID string`

    Identifier of the thread item.

  - `Attachments []ChatKitAttachment`

    Attachments associated with the user message. Defaults to an empty list.

    - `ID string`

      Identifier for the attachment.

    - `MimeType string`

      MIME type of the attachment.

    - `Name string`

      Original display name for the attachment.

    - `PreviewURL string`

      Preview URL for rendering the attachment inline.

    - `Type ChatKitAttachmentType`

      Attachment discriminator.

      - `const ChatKitAttachmentTypeImage ChatKitAttachmentType = "image"`

      - `const ChatKitAttachmentTypeFile ChatKitAttachmentType = "file"`

  - `Content []ChatKitThreadUserMessageItemContentUnion`

    Ordered content elements supplied by the user.

    - `type ChatKitThreadUserMessageItemContentInputText struct{…}`

      Text block that a user contributed to the thread.

      - `Text string`

        Plain-text content supplied by the user.

      - `Type InputText`

        Type discriminator that is always `input_text`.

        - `const InputTextInputText InputText = "input_text"`

    - `type ChatKitThreadUserMessageItemContentQuotedText struct{…}`

      Quoted snippet that the user referenced in their message.

      - `Text string`

        Quoted text content.

      - `Type QuotedText`

        Type discriminator that is always `quoted_text`.

        - `const QuotedTextQuotedText QuotedText = "quoted_text"`

  - `CreatedAt int64`

    Unix timestamp (in seconds) for when the item was created.

  - `InferenceOptions ChatKitThreadUserMessageItemInferenceOptions`

    Inference overrides applied to the message. Defaults to null when unset.

    - `Model string`

      Model name that generated the response. Defaults to null when using the session default.

    - `ToolChoice ChatKitThreadUserMessageItemInferenceOptionsToolChoice`

      Preferred tool to invoke. Defaults to null when ChatKit should auto-select.

      - `ID string`

        Identifier of the requested tool.

  - `Object ChatKitThreadItem`

    Type discriminator that is always `chatkit.thread_item`.

    - `const ChatKitThreadItemChatKitThreadItem ChatKitThreadItem = "chatkit.thread_item"`

  - `ThreadID string`

    Identifier of the parent thread.

  - `Type ChatKitUserMessage`

    - `const ChatKitUserMessageChatKitUserMessage ChatKitUserMessage = "chatkit.user_message"`

### ChatKit Widget Item

- `type ChatKitWidgetItem struct{…}`

  Thread item that renders a widget payload.

  - `ID string`

    Identifier of the thread item.

  - `CreatedAt int64`

    Unix timestamp (in seconds) for when the item was created.

  - `Object ChatKitThreadItem`

    Type discriminator that is always `chatkit.thread_item`.

    - `const ChatKitThreadItemChatKitThreadItem ChatKitThreadItem = "chatkit.thread_item"`

  - `ThreadID string`

    Identifier of the parent thread.

  - `Type ChatKitWidget`

    Type discriminator that is always `chatkit.widget`.

    - `const ChatKitWidgetChatKitWidget ChatKitWidget = "chatkit.widget"`

  - `Widget string`

    Serialized widget payload rendered in the UI.
