Coder Chats API

The Chats API from Coder — 20 operation(s) for chats.

Operations 25

GET /api/experimental/chats List chats #
POST /api/experimental/chats Create chat #
GET /api/experimental/chats/config/retention-days Get chat retention days #
PUT /api/experimental/chats/config/retention-days Update chat retention days #
POST /api/experimental/chats/files Upload chat file #
GET /api/experimental/chats/files/{file} Get chat file #
GET /api/experimental/chats/insights/pull-requests Get PR insights #
GET /api/experimental/chats/models List chat models #
GET /api/experimental/chats/watch Watch chat events for a user via WebSockets #
GET /api/experimental/chats/{chat} Get chat by ID #
PATCH /api/experimental/chats/{chat} Update chat #
GET /api/experimental/chats/{chat}/acl Get chat ACLs #
PATCH /api/experimental/chats/{chat}/acl Update chat ACL #
GET /api/experimental/chats/{chat}/diff Get chat diff contents #
POST /api/experimental/chats/{chat}/interrupt Interrupt chat #
GET /api/experimental/chats/{chat}/messages List chat messages #
POST /api/experimental/chats/{chat}/messages Send chat message #
PATCH /api/experimental/chats/{chat}/messages/{message} Edit chat message #
GET /api/experimental/chats/{chat}/prompts List chat user prompts #
POST /api/experimental/chats/{chat}/reconcile-invalid Reconcile invalid chat state #
GET /api/experimental/chats/{chat}/stream Stream chat events via WebSockets #
GET /api/experimental/chats/{chat}/stream/desktop Connect to chat workspace desktop via WebSockets #
GET /api/experimental/chats/{chat}/stream/git Watch chat workspace git state via WebSockets #
GET /api/experimental/chats/{chat}/stream/parts Stream chat parts via WebSockets #
POST /api/experimental/chats/{chat}/title/regenerate Regenerate chat title #

Work with this as data

Every API here is available over the APIs.io API and to AI agents over MCP.

MCP server

One button, every client — Claude, Cursor, VS Code and the rest.

https://apis.io/mcp

Tools for apis

7 MCP tools reach this
  • find_apisBrowse and filter every API in the catalog.
  • get_api_artifactsOne API's artifacts, grouped by type.
  • get_openapiThe primary OpenAPI for this API.
  • find_similar_apisAPIs that look like this one.
  • apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.
  • resolveTurn a domain, URL or GitHub org into the provider it belongs to.
  • find_cohortsEvery scored population of providers in the catalog.
All 92 tools →

Call it yourself

curl for this page
This API
curl "https://apis.io/api/v1/apis/coder-chats-api"
All apis
curl "https://apis.io/api/v1/apis?limit=25"

Discovery needs no key. Ratings and market analysis are Pro.

Get an API key

Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. See our Privacy Policy and Terms.

A second provider on the same verified email joins the account you already have.

OpenAPI Specification

coder-chats-api-openapi.yml Raw ↑
openapi: 3.2.0
info:
  description: Coderd is the service created by running coder server. It is a thin API that connects workspaces, provisioners and users. coderd stores its state in Postgres and is the only service that communicates with Postgres.
  title: Coder Agents Chats API
  termsOfService: https://coder.com/legal/terms-of-service
  contact:
    name: API Support
    url: https://coder.com
    email: support@coder.com
  license:
    name: AGPL-3.0
    url: https://github.com/coder/coder/blob/main/LICENSE
  version: '2.0'
servers:
- url: https://{coderHost}/api/v2
  description: Coder instance
  variables:
    coderHost:
      default: coder.example.com
      description: Your Coder deployment hostname
security:
- CoderSessionToken: []
tags:
- name: Chats
paths:
  /api/experimental/chats:
    get:
      operationId: list-chats
      summary: List chats
      tags:
      - Chats
      security:
      - CoderSessionToken: []
      description: 'Experimental: this endpoint is subject to change.'
      parameters:
      - name: q
        in: query
        required: false
        description: Search query. Supports title:<substring> (case-insensitive, quote multi-word values), archived:bool, has_unread:bool, pr_status:<draft\|open\|merged\|closed> as repeated or comma-separated values, source:<created_by_me\|shared_with_me>, diff_url:<url> (quote values containing colons), pr:<number> (exact PR number match), repo:<owner/repo> (case-insensitive substring match against git remote origin or URL), pr_title:<text> (case-insensitive PR title substring). Bare terms are not supported; use title:<value> for title filtering.
        schema:
          type: string
      - name: label
        in: query
        required: false
        description: Filter by label as key:value. Repeat for multiple (AND logic).
        schema:
          type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/codersdk.Chat'
    post:
      operationId: create-chat
      summary: Create chat
      tags:
      - Chats
      security:
      - CoderSessionToken: []
      description: 'Experimental: this endpoint is subject to change.'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/codersdk.CreateChatRequest'
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/codersdk.Chat'
  /api/experimental/chats/config/retention-days:
    get:
      operationId: get-chat-retention-days
      summary: Get chat retention days
      tags:
      - Chats
      security:
      - CoderSessionToken: []
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/codersdk.ChatRetentionDaysResponse'
    put:
      operationId: update-chat-retention-days
      summary: Update chat retention days
      tags:
      - Chats
      security:
      - CoderSessionToken: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/codersdk.UpdateChatRetentionDaysRequest'
      responses:
        '204':
          description: No Content
  /api/experimental/chats/files:
    post:
      operationId: upload-chat-file
      summary: Upload chat file
      tags:
      - Chats
      security:
      - CoderSessionToken: []
      description: 'Experimental: this endpoint is subject to change.'
      parameters:
      - name: organization
        in: query
        required: true
        description: Organization ID
        schema:
          type: string
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/codersdk.UploadChatFileResponse'
  /api/experimental/chats/files/{file}:
    get:
      operationId: get-chat-file
      summary: Get chat file
      tags:
      - Chats
      security:
      - CoderSessionToken: []
      description: 'Experimental: this endpoint is subject to change.'
      parameters:
      - name: file
        in: path
        required: true
        description: File ID
        schema:
          type: string
      responses:
        '200':
          description: OK
  /api/experimental/chats/insights/pull-requests:
    get:
      operationId: get-pr-insights
      summary: Get PR insights
      tags:
      - Chats
      security:
      - CoderSessionToken: []
      parameters:
      - name: start_date
        in: query
        required: true
        description: Start date (RFC3339)
        schema:
          type: string
      - name: end_date
        in: query
        required: true
        description: End date (RFC3339)
        schema:
          type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/codersdk.PRInsightsResponse'
  /api/experimental/chats/models:
    get:
      operationId: list-chat-models
      summary: List chat models
      tags:
      - Chats
      security:
      - CoderSessionToken: []
      description: 'Experimental: this endpoint is subject to change.'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/codersdk.ChatModelsResponse'
  /api/experimental/chats/watch:
    get:
      operationId: watch-chat-events-for-a-user-via-websockets
      summary: Watch chat events for a user via WebSockets
      tags:
      - Chats
      security:
      - CoderSessionToken: []
      description: 'Experimental: this endpoint is subject to change.'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/codersdk.ChatWatchEvent'
  /api/experimental/chats/{chat}:
    get:
      operationId: get-chat-by-id
      summary: Get chat by ID
      tags:
      - Chats
      security:
      - CoderSessionToken: []
      description: 'Experimental: this endpoint is subject to change.'
      parameters:
      - name: chat
        in: path
        required: true
        description: Chat ID
        schema:
          type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/codersdk.Chat'
    patch:
      operationId: update-chat
      summary: Update chat
      tags:
      - Chats
      security:
      - CoderSessionToken: []
      description: 'Experimental: this endpoint is subject to change.'
      parameters:
      - name: chat
        in: path
        required: true
        description: Chat ID
        schema:
          type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/codersdk.UpdateChatRequest'
      responses:
        '204':
          description: No Content
  /api/experimental/chats/{chat}/acl:
    get:
      operationId: get-chat-acls
      summary: Get chat ACLs
      tags:
      - Chats
      security:
      - CoderSessionToken: []
      description: 'Experimental: this endpoint is subject to change.'
      parameters:
      - name: chat
        in: path
        required: true
        description: Chat ID
        schema:
          type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/codersdk.ChatACL'
    patch:
      operationId: update-chat-acl
      summary: Update chat ACL
      tags:
      - Chats
      security:
      - CoderSessionToken: []
      description: 'Experimental: this endpoint is subject to change.'
      parameters:
      - name: chat
        in: path
        required: true
        description: Chat ID
        schema:
          type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/codersdk.UpdateChatACL'
      responses:
        '204':
          description: No Content
  /api/experimental/chats/{chat}/diff:
    get:
      operationId: get-chat-diff-contents
      summary: Get chat diff contents
      tags:
      - Chats
      security:
      - CoderSessionToken: []
      description: 'Experimental: this endpoint is subject to change.'
      parameters:
      - name: chat
        in: path
        required: true
        description: Chat ID
        schema:
          type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/codersdk.ChatDiffContents'
  /api/experimental/chats/{chat}/interrupt:
    post:
      operationId: interrupt-chat
      summary: Interrupt chat
      tags:
      - Chats
      security:
      - CoderSessionToken: []
      description: 'Experimental: this endpoint is subject to change.'
      parameters:
      - name: chat
        in: path
        required: true
        description: Chat ID
        schema:
          type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/codersdk.Chat'
  /api/experimental/chats/{chat}/messages:
    get:
      operationId: list-chat-messages
      summary: List chat messages
      tags:
      - Chats
      security:
      - CoderSessionToken: []
      description: 'Experimental: this endpoint is subject to change.'
      parameters:
      - name: chat
        in: path
        required: true
        description: Chat ID
        schema:
          type: string
      - name: before_id
        in: query
        required: false
        description: Return messages with id < before_id
        schema:
          type: integer
      - name: after_id
        in: query
        required: false
        description: Return messages with id > after_id
        schema:
          type: integer
      - name: limit
        in: query
        required: false
        description: Page size, 1 to 200. Defaults to 50.
        schema:
          type: integer
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/codersdk.ChatMessagesResponse'
    post:
      operationId: send-chat-message
      summary: Send chat message
      tags:
      - Chats
      security:
      - CoderSessionToken: []
      description: 'Experimental: this endpoint is subject to change.'
      parameters:
      - name: chat
        in: path
        required: true
        description: Chat ID
        schema:
          type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/codersdk.CreateChatMessageRequest'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/codersdk.CreateChatMessageResponse'
  /api/experimental/chats/{chat}/messages/{message}:
    patch:
      operationId: edit-chat-message
      summary: Edit chat message
      tags:
      - Chats
      security:
      - CoderSessionToken: []
      description: 'Experimental: this endpoint is subject to change.'
      parameters:
      - name: chat
        in: path
        required: true
        description: Chat ID
        schema:
          type: string
      - name: message
        in: path
        required: true
        description: Message ID
        schema:
          type: integer
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/codersdk.EditChatMessageRequest'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/codersdk.EditChatMessageResponse'
  /api/experimental/chats/{chat}/prompts:
    get:
      operationId: list-chat-user-prompts
      summary: List chat user prompts
      tags:
      - Chats
      security:
      - CoderSessionToken: []
      description: 'Experimental: this endpoint is subject to change.


        Returns the user-authored prompts in a chat, newest first,

        with each prompt''s text parts concatenated in the order they

        were authored. Used by the composer to power the up/down

        arrow prompt-history cycle without paging through every

        message in the chat.'
      parameters:
      - name: chat
        in: path
        required: true
        description: Chat ID
        schema:
          type: string
      - name: limit
        in: query
        required: false
        description: Page size, 0 to 2000. 0 (the default) means the server-side default of 500.
        schema:
          type: integer
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/codersdk.ChatPromptsResponse'
  /api/experimental/chats/{chat}/reconcile-invalid:
    post:
      operationId: reconcile-invalid-chat-state
      summary: Reconcile invalid chat state
      tags:
      - Chats
      security:
      - CoderSessionToken: []
      description: 'Experimental: this endpoint is subject to change.'
      parameters:
      - name: chat
        in: path
        required: true
        description: Chat ID
        schema:
          type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/codersdk.Chat'
  /api/experimental/chats/{chat}/stream:
    get:
      operationId: stream-chat-events-via-websockets
      summary: Stream chat events via WebSockets
      tags:
      - Chats
      security:
      - CoderSessionToken: []
      description: 'Experimental: this endpoint is subject to change.'
      parameters:
      - name: chat
        in: path
        required: true
        description: Chat ID
        schema:
          type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/codersdk.ChatStreamEvent'
  /api/experimental/chats/{chat}/stream/desktop:
    get:
      operationId: connect-to-chat-workspace-desktop-via-websockets
      summary: Connect to chat workspace desktop via WebSockets
      tags:
      - Chats
      security:
      - CoderSessionToken: []
      description: 'Raw binary WebSocket stream of the chat workspace desktop.

        Experimental: this endpoint is subject to change.'
      parameters:
      - name: chat
        in: path
        required: true
        description: Chat ID
        schema:
          type: string
      responses:
        '101':
          description: Switching Protocols
  /api/experimental/chats/{chat}/stream/git:
    get:
      operationId: watch-chat-workspace-git-state-via-websockets
      summary: Watch chat workspace git state via WebSockets
      tags:
      - Chats
      security:
      - CoderSessionToken: []
      description: 'Experimental: this endpoint is subject to change.'
      parameters:
      - name: chat
        in: path
        required: true
        description: Chat ID
        schema:
          type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/codersdk.WorkspaceAgentGitServerMessage'
  /api/experimental/chats/{chat}/stream/parts:
    get:
      operationId: stream-chat-parts-via-websockets
      summary: Stream chat parts via WebSockets
      tags:
      - Chats
      security:
      - CoderSessionToken: []
      description: 'Experimental: this endpoint is subject to change.'
      parameters:
      - name: chat
        in: path
        required: true
        description: Chat ID
        schema:
          type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/codersdk.ChatStreamEvent'
  /api/experimental/chats/{chat}/title/regenerate:
    post:
      operationId: regenerate-chat-title
      summary: Regenerate chat title
      tags:
      - Chats
      security:
      - CoderSessionToken: []
      description: 'Experimental: this endpoint is subject to change.'
      parameters:
      - name: chat
        in: path
        required: true
        description: Chat ID
        schema:
          type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/codersdk.Chat'
components:
  schemas:
    codersdk.PRInsightsModelBreakdown:
      type: object
      properties:
        cost_per_merged_pr_micros:
          type: integer
        display_name:
          type: string
        merge_rate:
          type: number
        merged_prs:
          type: integer
        model_config_id:
          type: string
          format: uuid
        provider:
          type: string
        total_additions:
          type: integer
        total_cost_micros:
          type: integer
        total_deletions:
          type: integer
        total_prs:
          type: integer
    codersdk.ChatError:
      type: object
      properties:
        detail:
          type: string
          description: 'Detail is optional provider-specific context shown alongside the

            normalized error message when available.'
        kind:
          description: Kind classifies the error for consistent client rendering.
          allOf:
          - $ref: '#/components/schemas/codersdk.ChatErrorKind'
        message:
          type: string
          description: Message is the normalized, user-facing error message.
        provider:
          type: string
          description: Provider identifies the upstream model provider when known.
        retryable:
          type: boolean
          description: Retryable reports whether the underlying error is transient.
        status_code:
          type: integer
          description: StatusCode is the best-effort upstream HTTP status code.
    codersdk.PRInsightsResponse:
      type: object
      properties:
        by_model:
          type: array
          items:
            $ref: '#/components/schemas/codersdk.PRInsightsModelBreakdown'
        recent_prs:
          type: array
          items:
            $ref: '#/components/schemas/codersdk.PRInsightsPullRequest'
        summary:
          $ref: '#/components/schemas/codersdk.PRInsightsSummary'
        time_series:
          type: array
          items:
            $ref: '#/components/schemas/codersdk.PRInsightsTimeSeriesEntry'
    codersdk.Chat:
      type: object
      properties:
        agent_id:
          type: string
          format: uuid
        archived:
          type: boolean
        build_id:
          type: string
          format: uuid
        children:
          type: array
          description: 'Children holds child (subagent) chats nested under this root

            chat. Always initialized to an empty slice so the JSON field

            is present as []. Child chats cannot create their own

            subagents, so nesting depth is capped at 1 and this slice is

            always empty for child chats.'
          items:
            $ref: '#/components/schemas/codersdk.Chat'
        client_type:
          $ref: '#/components/schemas/codersdk.ChatClientType'
        created_at:
          type: string
          format: date-time
        diff_status:
          $ref: '#/components/schemas/codersdk.ChatDiffStatus'
        files:
          type: array
          items:
            $ref: '#/components/schemas/codersdk.ChatFileMetadata'
        has_unread:
          type: boolean
          description: 'HasUnread is true when assistant messages exist beyond

            the owner''s read cursor, which updates on stream

            connect and disconnect.'
        id:
          type: string
          format: uuid
        labels:
          type: object
          additionalProperties:
            type: string
        last_error:
          $ref: '#/components/schemas/codersdk.ChatError'
        last_injected_context:
          type: array
          description: 'LastInjectedContext holds the most recently persisted

            injected context parts (AGENTS.md files and skills). It

            is updated only when context changes, on first workspace

            attach or agent change.'
          items:
            $ref: '#/components/schemas/codersdk.ChatMessagePart'
        last_model_config_id:
          type: string
          format: uuid
        last_turn_summary:
          type: string
        mcp_server_ids:
          type: array
          items:
            type: string
            format: uuid
        organization_id:
          type: string
          format: uuid
        owner_id:
          type: string
          format: uuid
        owner_name:
          type: string
        owner_username:
          type: string
        parent_chat_id:
          type: string
          format: uuid
        pin_order:
          type: integer
        plan_mode:
          $ref: '#/components/schemas/codersdk.ChatPlanMode'
        root_chat_id:
          type: string
          format: uuid
        shared:
          type: boolean
          description: Shared is true when this chat's root chat has explicit user or group ACL entries.
        status:
          $ref: '#/components/schemas/codersdk.ChatStatus'
        title:
          type: string
        updated_at:
          type: string
          format: date-time
        warnings:
          type: array
          items:
            type: string
        workspace_id:
          type: string
          format: uuid
    codersdk.ChatStatus:
      type: string
      enum:
      - waiting
      - pending
      - running
      - paused
      - completed
      - error
      - requires_action
      - interrupting
    codersdk.WorkspaceAgentGitServerMessage:
      type: object
      properties:
        message:
          type: string
        repositories:
          type: array
          items:
            $ref: '#/components/schemas/codersdk.WorkspaceAgentRepoChanges'
        scanned_at:
          type: string
          format: date-time
        type:
          $ref: '#/components/schemas/codersdk.WorkspaceAgentGitServerMessageType'
    codersdk.EditChatMessageRequest:
      type: object
      properties:
        content:
          type: array
          items:
            $ref: '#/components/schemas/codersdk.ChatInputPart'
        model_config_id:
          type: string
          format: uuid
          description: 'ModelConfigID, when set, overrides the model used for the

            replacement user message and the assistant turn that follows.

            When nil the original message''s model is preserved.'
    codersdk.UploadChatFileResponse:
      type: object
      properties:
        id:
          type: string
          format: uuid
    codersdk.ChatRetentionDaysResponse:
      type: object
      properties:
        retention_days:
          type: integer
    codersdk.ChatUser:
      type: object
      properties:
        avatar_url:
          type: string
          format: uri
        id:
          type: string
          format: uuid
        name:
          type: string
        role:
          enum:
          - read
          allOf:
          - $ref: '#/components/schemas/codersdk.ChatRole'
        username:
          type: string
      required:
      - id
      - username
    codersdk.ChatMessagesResponse:
      type: object
      properties:
        has_more:
          type: boolean
        messages:
          type: array
          items:
            $ref: '#/components/schemas/codersdk.ChatMessage'
        queued_messages:
          type: array
          items:
            $ref: '#/components/schemas/codersdk.ChatQueuedMessage'
    codersdk.ChatModel:
      type: object
      properties:
        display_name:
          type: string
        id:
          type: string
        model:
          type: string
        provider:
          type: string
    codersdk.PRInsightsSummary:
      type: object
      properties:
        approval_rate:
          type: number
        cost_per_merged_pr_micros:
          type: integer
        merge_rate:
          type: number
        prev_cost_per_merged_pr_micros:
          type: integer
        prev_merge_rate:
          type: number
        prev_total_prs_created:
          type: integer
        prev_total_prs_merged:
          type: integer
        total_additions:
          type: integer
        total_cost_micros:
          type: integer
        total_deletions:
          type: integer
        total_prs_created:
          type: integer
        total_prs_merged:
          type: integer
    codersdk.ChatWatchEventKind:
      type: string
      enum:
      - status_change
      - summary_change
      - title_change
      - created
      - deleted
      - diff_status_change
      - action_required
    codersdk.ChatPrompt:
      type: object
      properties:
        id:
          type: integer
        text:
          type: string
    codersdk.UpdateChatACL:
      type: object
      properties:
        group_roles:
          type: object
          additionalProperties:
            $ref: '#/components/schemas/codersdk.ChatRole'
        user_roles:
          type: object
          additionalProperties:
            $ref: '#/components/schemas/codersdk.ChatRole'
    codersdk.ChatPromptsResponse:
      type: object
      properties:
        prompts:
          type: array
          items:
            $ref: '#/components/schemas/codersdk.ChatPrompt'
    codersdk.UpdateChatRequest:
      type: object
      properties:
        archived:
          type: boolean
        labels:
          type: object
          additionalProperties:
            type: string
        pin_order:
          type: integer
          description: "PinOrder controls the chat's pinned state and position.\n- nil: no change to pin state.\n- 0: unpin the chat.\n- >0 (chat is unpinned): pin the chat, appending it to\n  the end of the pinned list. The specific value is\n  ignored; the server assigns the next available position.\n- >0 (chat is already pinned): move the chat to the\n  requested position, shifting neighbors as needed. The\n  value is clamped to [1, pinned_count]."
        plan_mode:
          description: 'PlanMode switches the chat''s persistent plan mode.

            nil: no change, ptr to "plan": enable, ptr to "": clear.'
          allOf:
          - $ref: '#/components/schemas/codersdk.ChatPlanMode'
        title:
          type: string
        workspace_id:
          type: string
          format: uuid
    codersdk.ChatModelProviderUnavailableReason:
      type: string
      enum:
      - missing_api_key
      - fetch_failed
      - user_api_key_required
    codersdk.WorkspaceAgentGitServerMessageType:
      type: string
      enum:
      - changes
      - error
    codersdk.ChatRole:
      type: string
      enum:
      - read
      - ''
    codersdk.PRInsightsTimeSeriesEntry:
      type: object
      properties:
        date:
          type: string
          format: date-time
        prs_closed:
          type: integer
        prs_created:
          type: integer
        prs_merged:
          type: integer
    codersdk.ChatQueuedMessage:
      type: object
      properties:
        chat_id:
          type: string
          format: uuid
        content:
          type: array
          items:
            $ref: '#/components/schemas/codersdk.ChatMessagePart'
        created_at:
          type: string
          format: date-time
        id:
          type: integer
        model_config_id:
          type: string
          format: uuid
    codersdk.ChatStreamMessagePart:
      type: object
      properties:
        generation_attempt:
          type: integer
        history_version:
          type: integer
        part:
          $ref: '#/components/schemas/codersdk.ChatMessagePart'
        role:
          $ref: '#/components/schemas/codersdk.ChatMessageRole'
        seq:
          type: integer
    codersdk.ChatStreamEvent:
      type: object
      properties:
        action_required:
          $ref: '#/components/schemas/codersdk.ChatStreamActionRequired'
        chat_id:
          type: string
          format: uuid
        error:
          $ref: '#/components/schemas/codersdk.ChatError'
        message:
          $ref: '#/components/schemas/codersdk.ChatMessage'
        message_part:
          $ref: '#/components/schemas/codersdk.ChatStreamMessagePart'
        queued_messages:
          type: array
          items:
            $ref: '#/components/schemas/codersdk.ChatQueuedMessage'
        retry:
          $ref: '#/components/schemas/codersdk.ChatStreamRetry'
        status:
          $ref: '#/components/schemas/codersdk.ChatStreamStatus'
        type:
          $ref: '#/components/schemas/codersdk.ChatStreamEventType'
    codersdk.ChatWatchEvent:
      type: object
      properties:
        chat:
          $ref: '#/components/schemas/codersdk.Chat'
        kind:
          $ref: '#/components/schemas/codersdk.ChatWatchEventKind'
        tool_calls:
          type: array
          items:
            $ref: '#/components/schemas/codersdk.ChatStreamToolCall'
    codersdk.ChatClientType:
      type: string
      enum:
      - ui
      - api
    codersdk.ChatModelsResponse:
      type: object
      properties:
        providers:
          type: array
          items:
            $ref: '#/components/schemas/codersdk.ChatModelProvider'
    codersdk.DynamicTool:
      type: object
      properties:
        description:
          type: string
        input_schema:
          type: array
          description: 'InputSchema''s JSON key "input_schema" uses snake_case for

            SDK consistency, deviating from the camelCase "inputSchema"

            convention used by MCP.'
          items:
            type: integer
        name:
          type: string
    codersdk.ChatFileMetadata:
      type: object
      properties:
        created_at:
          type: string
          format: date-time
        id:
          type: string
          format: uuid
        mime_type:
          type: string
        name:
          type: string
        organization_id:
          type: string
          format: uuid
        owner_id:
          type: string
          format: uuid
    codersdk.ChatMessageUsage:
      type: object
      properties:
        cache_creation_tokens:
          type: integer
        cache_read_tokens:
          type: integer
        context_limit:
          type: integer
        input_tokens:
          type: integer
        output_tokens:
          type: integer
        reasoning_tokens:
          type: integer
        total_tokens:
          type: integer
    codersdk.ChatACL:
      type: object
      properties:
        groups:
          type: array
          items:
            $ref: '#/components/schemas/codersdk.ChatGroup'
        users:
          type: array
          items:
            $ref: '#/components/schemas/codersdk.ChatUser'
    codersdk.GroupSource:
      type: string
      enum:
      - user
      - oidc
    codersdk.ChatStreamEventType:
      type: string
      enum:
      - message_part
      - message
      - status
      - error
      - queue_update
      - retry
      - action_required
      - preview_reset
      - history_reset
    codersdk.ChatStreamRetry:
      type: object
      properties:
        attempt:
          type: integer
          description: Attempt is the 1-indexed retry attempt number.
        delay_ms:
          type: integer
          description: DelayM

# --- truncated at 32 KB (49 KB total) ---
# Full source: https://raw.githubusercontent.com/api-evangelist/coder/refs/heads/main/openapi/coder-chats-api-openapi.yml