openapi: 3.1.0
info:
  title: Priors API
  description: 'Priors gives you memory agents. An agent learns from the observations you send it and
    answers from what it learned.


    Authenticate with an API key, which belongs to one project:


    - A service account''s key, for a product you build. It acts as the project''s service account and
    keeps working when people leave. Add `X-SP-End-User` to act for one person on your side.

    - A personal key, for building and testing from your own code. It acts as you, with your role in the
    project.


    Another organization, or another project, gets 404 for your identifiers.

    '
  contact:
    name: SapientPriors
    url: https://www.sapientpriors.com/
    email: hello@sapientpriors.io
  version: '2.0'
paths:
  /v2/agents/{agent_id}/threads/{thread_id}/observe:
    post:
      tags:
      - Threads
      summary: Learn messages or files
      description: 'Learn one message, a list of up to 100 messages (JSON), or documents (multipart) in
        the background. Returns

        202; poll each observation for progress.'
      operationId: observe_v2
      parameters:
      - name: agent_id
        in: path
        required: true
        schema:
          type: string
          pattern: ^agent_[0-9A-HJKMNP-TV-Z]{26}$
          description: The agent's identifier.
          title: Agent Id
        description: The agent's identifier.
      - name: thread_id
        in: path
        required: true
        schema:
          type: string
          pattern: ^thread_[0-9A-HJKMNP-TV-Z]{26}$
          description: The thread's identifier, scoped to the agent.
          title: Thread Id
        description: The thread's identifier, scoped to the agent.
      - name: Idempotency-Key
        in: header
        required: false
        schema:
          anyOf:
          - type: string
            minLength: 1
            maxLength: 255
          - type: 'null'
          description: 'A key you choose so a retry is safe: a retry with the same key and body gets the
            first response back instead of running again. Reusing a key for a different request, or while
            the first is still running, returns 409 `conflict`, with `details` `idempotency_key_reused`
            (use a new key) or `idempotency_key_in_flight` (wait, then retry).'
          title: Idempotency-Key
        description: 'A key you choose so a retry is safe: a retry with the same key and body gets the
          first response back instead of running again. Reusing a key for a different request, or while
          the first is still running, returns 409 `conflict`, with `details` `idempotency_key_reused`
          (use a new key) or `idempotency_key_in_flight` (wait, then retry).'
      responses:
        '202':
          description: Accepted for learning. A message call's Location points at its status; a file call
            names each file's observation in `files` instead.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ObserveAccepted'
          headers:
            Location:
              description: 'The status endpoint for this observation, as a relative reference: resolve
                it against this request''s URL. Follow it rather than building the path from `observation_id`.'
              schema:
                type: string
                format: uri-reference
            X-Request-Id:
              $ref: '#/components/headers/X-Request-Id'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '503':
          $ref: '#/components/responses/ServiceUnavailable'
        '500':
          $ref: '#/components/responses/InternalServerError'
        '429':
          $ref: '#/components/responses/TooManyRequests'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              additionalProperties: false
              description: 'One message as a string in `content`, or a list of up to 100 messages. With
                a list, set `speaker`,

                `speaker_id`, `timestamp` and `metadata` on each message, not beside `content`.'
              properties:
                speaker_id:
                  anyOf:
                  - maxLength: 200
                    minLength: 1
                    type: string
                  - type: 'null'
                  description: Your own id for the speaker. Kept on the turn and returned with it.
                  title: Speaker Id
                timestamp:
                  anyOf:
                  - format: date-time
                    type: string
                  - type: 'null'
                  description: When the message was said, used to date its memories. Defaults to when
                    the server receives it.
                  title: Timestamp
                metadata:
                  anyOf:
                  - additionalProperties: true
                    description: 'Where a turn came from: four named keys, and any keys of your own. At
                      most 32 keys and 8 KiB as JSON.'
                    properties:
                      path:
                        anyOf:
                        - maxLength: 1024
                          minLength: 1
                          type: string
                        - type: 'null'
                        description: The path of the file or page the turn came from.
                        title: Path
                      section:
                        anyOf:
                        - maxLength: 500
                          minLength: 1
                          type: string
                        - type: 'null'
                        description: The section of that source the turn came from.
                        title: Section
                      page:
                        anyOf:
                        - maximum: 1000000
                          minimum: 1
                          type: integer
                        - type: 'null'
                        description: The page the turn came from, counting from 1.
                        title: Page
                      parent_id:
                        anyOf:
                        - maxLength: 200
                          minLength: 1
                          type: string
                        - type: 'null'
                        description: The id of the item the turn belongs to, in your own system.
                        title: Parent Id
                    title: TurnMetadata
                    type: object
                  - type: 'null'
                  description: Where the message came from, kept on the turn and returned with it.
                content:
                  anyOf:
                  - maxLength: 2000000
                    minLength: 1
                    type: string
                  - items:
                      additionalProperties: false
                      description: One message in an `observe` list.
                      properties:
                        speaker_id:
                          anyOf:
                          - maxLength: 200
                            minLength: 1
                            type: string
                          - type: 'null'
                          description: Your own id for the speaker. Kept on the turn and returned with
                            it.
                          title: Speaker Id
                        timestamp:
                          anyOf:
                          - format: date-time
                            type: string
                          - type: 'null'
                          description: When the message was said, used to date its memories. Defaults
                            to when the server receives it.
                          title: Timestamp
                        metadata:
                          anyOf:
                          - additionalProperties: true
                            description: 'Where a turn came from: four named keys, and any keys of your
                              own. At most 32 keys and 8 KiB as JSON.'
                            properties:
                              path:
                                anyOf:
                                - maxLength: 1024
                                  minLength: 1
                                  type: string
                                - type: 'null'
                                description: The path of the file or page the turn came from.
                                title: Path
                              section:
                                anyOf:
                                - maxLength: 500
                                  minLength: 1
                                  type: string
                                - type: 'null'
                                description: The section of that source the turn came from.
                                title: Section
                              page:
                                anyOf:
                                - maximum: 1000000
                                  minimum: 1
                                  type: integer
                                - type: 'null'
                                description: The page the turn came from, counting from 1.
                                title: Page
                              parent_id:
                                anyOf:
                                - maxLength: 200
                                  minLength: 1
                                  type: string
                                - type: 'null'
                                description: The id of the item the turn belongs to, in your own system.
                                title: Parent Id
                            title: TurnMetadata
                            type: object
                          - type: 'null'
                          description: Where the message came from, kept on the turn and returned with
                            it.
                        text:
                          description: What was said.
                          maxLength: 2000000
                          minLength: 1
                          title: Text
                          type: string
                        speaker:
                          description: Who said it, such as a person's name.
                          maxLength: 200
                          minLength: 1
                          title: Speaker
                          type: string
                      required:
                      - text
                      - speaker
                      title: Message
                      type: object
                    maxItems: 100
                    minItems: 1
                    type: array
                  description: One message as a string, or a list of up to 100 messages, each with its
                    own speaker.
                  title: Content
                speaker:
                  anyOf:
                  - maxLength: 200
                    minLength: 1
                    type: string
                  - type: 'null'
                  description: Who said the message, such as a person's name. Required with an API key.
                  title: Speaker
              required:
              - content
              title: ObserveRequest
              type: object
          multipart/form-data:
            schema:
              additionalProperties: false
              description: 'The multipart fields sent beside the document in `file`: who uploaded it,
                as on a message. The agent also

                learns a turn saying who uploaded the file. The server splits the document into turns.'
              properties:
                file:
                  type: array
                  items:
                    type: string
                    format: binary
                  description: 'The documents, one `file` part each: repeat the part to send several,
                    up to the session''s `max_files_per_upload`; together they stay under its `max_upload_bytes`.'
                speaker_id:
                  anyOf:
                  - maxLength: 200
                    minLength: 1
                    type: string
                  - type: 'null'
                  description: Your own id for the speaker. Kept on the turn and returned with it.
                  title: Speaker Id
                timestamp:
                  anyOf:
                  - format: date-time
                    type: string
                  - type: 'null'
                  description: When the message was said, used to date its memories. Defaults to when
                    the server receives it.
                  title: Timestamp
                metadata:
                  anyOf:
                  - additionalProperties: true
                    description: 'Where a turn came from: four named keys, and any keys of your own. At
                      most 32 keys and 8 KiB as JSON.'
                    properties:
                      path:
                        anyOf:
                        - maxLength: 1024
                          minLength: 1
                          type: string
                        - type: 'null'
                        description: The path of the file or page the turn came from.
                        title: Path
                      section:
                        anyOf:
                        - maxLength: 500
                          minLength: 1
                          type: string
                        - type: 'null'
                        description: The section of that source the turn came from.
                        title: Section
                      page:
                        anyOf:
                        - maximum: 1000000
                          minimum: 1
                          type: integer
                        - type: 'null'
                        description: The page the turn came from, counting from 1.
                        title: Page
                      parent_id:
                        anyOf:
                        - maxLength: 200
                          minLength: 1
                          type: string
                        - type: 'null'
                        description: The id of the item the turn belongs to, in your own system.
                        title: Parent Id
                    title: TurnMetadata
                    type: object
                  - type: 'null'
                  description: Where the message came from, kept on the turn and returned with it.
                speaker:
                  anyOf:
                  - maxLength: 200
                    minLength: 1
                    type: string
                  - type: 'null'
                  description: Who said the message, such as a person's name. Required with an API key.
                  title: Speaker
                source_timestamp:
                  anyOf:
                  - format: date-time
                    type: string
                  - type: 'null'
                  description: When the source content is from, as an ISO 8601 timestamp. Applies to every
                    chunk of each file and defaults to ingestion time. Timestamps without an offset use
                    UTC. When resending a partially learned file, use the original source timestamp, or
                    omit it if the original upload was undated. A completed upload of the same bytes in
                    the same conversation is reused even with allow_duplicate. To apply a different timestamp,
                    read the file in another conversation.
                  title: Source Timestamp
                allow_duplicate:
                  default: false
                  title: Allow Duplicate
                  type: boolean
              title: DocumentFields
              type: object
              required:
              - file
      security:
      - projectKey: []
      x-mint:
        href: /api-reference/v2/threads/learn-messages-or-files
        metadata:
          sidebarTitle: Learn messages or files
    get:
      tags:
      - Threads
      summary: List observe calls
      description: 'The thread''s `observe` calls, newest first, file uploads included. Calls to observe-and-respond
        and

        observe-and-recall are not listed. With `status`, a page can come back short while `next_cursor`
        is still set.'
      operationId: list_observations_v2
      parameters:
      - name: agent_id
        in: path
        required: true
        schema:
          type: string
          pattern: ^agent_[0-9A-HJKMNP-TV-Z]{26}$
          description: The agent's identifier.
          title: Agent Id
        description: The agent's identifier.
      - name: thread_id
        in: path
        required: true
        schema:
          type: string
          pattern: ^thread_[0-9A-HJKMNP-TV-Z]{26}$
          description: The thread's identifier, scoped to the agent.
          title: Thread Id
        description: The thread's identifier, scoped to the agent.
      - name: status
        in: query
        required: false
        schema:
          anyOf:
          - enum:
            - queued
            - converting
            - processing
            - interrupted
            - committed
            - failed
            - cancelled
            type: string
          - type: 'null'
          description: Only the calls with this status.
          title: Status
        description: Only the calls with this status.
      - name: limit
        in: query
        required: false
        schema:
          type: integer
          maximum: 100
          minimum: 1
          description: The most rows to return in one page.
          default: 50
          title: Limit
        description: The most rows to return in one page.
      - name: cursor
        in: query
        required: false
        schema:
          anyOf:
          - type: string
            maxLength: 2048
          - type: 'null'
          description: The `next_cursor` of the previous page. Omit to read the first page.
          title: Cursor
        description: The `next_cursor` of the previous page. Omit to read the first page.
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Page_Observation_'
          headers:
            X-Request-Id:
              $ref: '#/components/headers/X-Request-Id'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '503':
          $ref: '#/components/responses/ServiceUnavailable'
        '500':
          $ref: '#/components/responses/InternalServerError'
      security:
      - projectKey: []
      x-mint:
        href: /api-reference/v2/threads/list-observe-calls
        metadata:
          sidebarTitle: List observe calls
  /v2/agents/{agent_id}/threads/{thread_id}/observe/{observation_id}:
    get:
      tags:
      - Threads
      summary: Get learning status
      description: How far an observation's learning has got. While it runs, `Retry-After` says when to
        ask again.
      operationId: get_observation_v2
      parameters:
      - name: agent_id
        in: path
        required: true
        schema:
          type: string
          pattern: ^agent_[0-9A-HJKMNP-TV-Z]{26}$
          description: The agent's identifier.
          title: Agent Id
        description: The agent's identifier.
      - name: thread_id
        in: path
        required: true
        schema:
          type: string
          pattern: ^thread_[0-9A-HJKMNP-TV-Z]{26}$
          description: The thread's identifier, scoped to the agent.
          title: Thread Id
        description: The thread's identifier, scoped to the agent.
      - name: observation_id
        in: path
        required: true
        schema:
          type: string
          description: The `observation_id` an observe, observe-and-respond or observe-and-recall call
            returned.
          title: Observation Id
        description: The `observation_id` an observe, observe-and-respond or observe-and-recall call returned.
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ObservationStatus'
          headers:
            X-Request-Id:
              $ref: '#/components/headers/X-Request-Id'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '503':
          $ref: '#/components/responses/ServiceUnavailable'
        '500':
          $ref: '#/components/responses/InternalServerError'
      security:
      - projectKey: []
      x-mint:
        href: /api-reference/v2/threads/get-learning-status
        metadata:
          sidebarTitle: Get learning status
  /v2/agents/{agent_id}/threads/{thread_id}/observe-and-respond:
    post:
      tags:
      - Threads
      summary: Learn and answer
      description: 'Answer one message and learn it, and the answer unless `learn_reply` is false. An
        agent whose owner turned

        off learning from conversations learns neither.'
      operationId: observe_and_respond_v2
      parameters:
      - name: agent_id
        in: path
        required: true
        schema:
          type: string
          pattern: ^agent_[0-9A-HJKMNP-TV-Z]{26}$
          description: The agent's identifier.
          title: Agent Id
        description: The agent's identifier.
      - name: thread_id
        in: path
        required: true
        schema:
          type: string
          pattern: ^thread_[0-9A-HJKMNP-TV-Z]{26}$
          description: The thread's identifier, scoped to the agent.
          title: Thread Id
        description: The thread's identifier, scoped to the agent.
      - name: Idempotency-Key
        in: header
        required: false
        schema:
          anyOf:
          - type: string
            minLength: 1
            maxLength: 255
          - type: 'null'
          description: 'A key you choose so a retry is safe: a retry with the same key and body gets the
            first response back instead of running again. Reusing a key for a different request, or while
            the first is still running, returns 409 `conflict`, with `details` `idempotency_key_reused`
            (use a new key) or `idempotency_key_in_flight` (wait, then retry).'
          title: Idempotency-Key
        description: 'A key you choose so a retry is safe: a retry with the same key and body gets the
          first response back instead of running again. Reusing a key for a different request, or while
          the first is still running, returns 409 `conflict`, with `details` `idempotency_key_reused`
          (use a new key) or `idempotency_key_in_flight` (wait, then retry).'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ObserveAndRespondV2Request'
      responses:
        '200':
          description: 'The answer as JSON or, with `stream: true`, as server-sent events: `delta` events
            with the answer''s text as it is written, then one `complete` event with the JSON body or
            one `error` event.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RespondResponse'
            text/event-stream:
              schema:
                type: string
              x-oai-itemSchema:
                oneOf:
                - type: object
                  required:
                  - event
                  - data
                  properties:
                    event:
                      const: delta
                    data:
                      $ref: '#/components/schemas/ChatStreamDelta'
                - type: object
                  required:
                  - event
                  - data
                  properties:
                    event:
                      const: complete
                    data:
                      $ref: '#/components/schemas/RespondResponse'
                - type: object
                  required:
                  - event
                  - data
                  properties:
                    event:
                      const: error
                    data:
                      $ref: '#/components/schemas/ErrorResponse'
              example: 'event: delta

                data: {"delta":"Studio 7B, "}


                event: delta

                data: {"delta":"on Thursdays."}


                event: complete

                data: {"answer":"Studio 7B, on Thursdays.","citations":[]}


                '
          headers:
            X-Request-Id:
              $ref: '#/components/headers/X-Request-Id'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '503':
          $ref: '#/components/responses/ServiceUnavailable'
        '500':
          $ref: '#/components/responses/InternalServerError'
        '429':
          $ref: '#/components/responses/TooManyRequests'
      security:
      - projectKey: []
      x-mint:
        href: /api-reference/v2/threads/learn-and-answer
        metadata:
          sidebarTitle: Learn and answer
  /v2/agents/{agent_id}/threads/{thread_id}/respond:
    post:
      tags:
      - Threads
      summary: Answer
      description: 'Answer one message and learn nothing. The message and the answer are kept in the thread''s
        history, and a later

        message on the thread is answered with them in view; they never become memories. Deleting the
        thread hides them

        and does not erase them.'
      operationId: respond_v2
      parameters:
      - name: agent_id
        in: path
        required: true
        schema:
          type: string
          pattern: ^agent_[0-9A-HJKMNP-TV-Z]{26}$
          description: The agent's identifier.
          title: Agent Id
        description: The agent's identifier.
      - name: thread_id
        in: path
        required: true
        schema:
          type: string
          pattern: ^thread_[0-9A-HJKMNP-TV-Z]{26}$
          description: The thread's identifier, scoped to the agent.
          title: Thread Id
        description: The thread's identifier, scoped to the agent.
      - name: Idempotency-Key
        in: header
        required: false
        schema:
          anyOf:
          - type: string
            minLength: 1
            maxLength: 255
          - type: 'null'
          description: 'A key you choose so a retry is safe: a retry with the same key and body gets the
            first response back instead of running again. Reusing a key for a different request, or while
            the first is still running, returns 409 `conflict`, with `details` `idempotency_key_reused`
            (use a new key) or `idempotency_key_in_flight` (wait, then retry).'
          title: Idempotency-Key
        description: 'A key you choose so a retry is safe: a retry with the same key and body gets the
          first response back instead of running again. Reusing a key for a different request, or while
          the first is still running, returns 409 `conflict`, with `details` `idempotency_key_reused`
          (use a new key) or `idempotency_key_in_flight` (wait, then retry).'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RespondRequest'
      responses:
        '200':
          description: 'The answer as JSON or, with `stream: true`, as server-sent events: `delta` events
            with the answer''s text as it is written, then one `complete` event with the JSON body or
            one `error` event.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RespondResponse'
            text/event-stream:
              schema:
                type: string
              x-oai-itemSchema:
                oneOf:
                - type: object
                  required:
                  - event
                  - data
                  properties:
                    event:
                      const: delta
                    data:
                      $ref: '#/components/schemas/ChatStreamDelta'
                - type: object
                  required:
                  - event
                  - data
                  properties:
                    event:
                      const: complete
                    data:
                      $ref: '#/components/schemas/RespondResponse'
                - type: object
                  required:
                  - event
                  - data
                  properties:
                    event:
                      const: error
                    data:
                      $ref: '#/components/schemas/ErrorResponse'
              example: 'event: delta

                data: {"delta":"Studio 7B, "}


                event: delta

                data: {"delta":"on Thursdays."}


                event: complete

                data: {"answer":"Studio 7B, on Thursdays.","citations":[]}


                '
          headers:
            X-Request-Id:
              $ref: '#/components/headers/X-Request-Id'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '503':
          $ref: '#/components/responses/ServiceUnavailable'
        '500':
          $ref: '#/components/responses/InternalServerError'
        '429':
          $ref: '#/components/responses/TooManyRequests'
      security:
      - projectKey: []
      x-mint:
        href: /api-reference/v2/threads/answer
        metadata:
          sidebarTitle: Answer
  /v2/agents/{agent_id}/threads/{thread_id}/observe-and-recall:
    post:
      tags:
      - Threads
      summary: Learn and recall
      description: Learn one message and return the memories the agent uses for it.
      operationId: observe_and_recall_v2
      parameters:
      - name: agent_id
        in: path
        required: true
        schema:
          type: string
          pattern: ^agent_[0-9A-HJKMNP-TV-Z]{26}$
          description: The agent's identifier.
          title: Agent Id
        description: The agent's identifier.
      - name: thread_id
        in: path
        required: true
        schema:
          type: string
          pattern: ^thread_[0-9A-HJKMNP-TV-Z]{26}$
          description: The thread's identifier, scoped to the agent.
          title: Thread Id
        description: The thread's identifier, scoped to the agent.
      - name: Idempotency-Key
        in: header
        required: false
        schema:
          anyOf:
          - type: string
            minLength: 1
            maxLength: 255
          - type: 'null'
          description: 'A key you choose so a retry is safe: a retry with the same key and body gets the
            first response back instead of running again. Reusing a key for a different request, or while
            the first is still running, returns 409 `conflict`, with `details` `idempotency_key_reused`
            (use a new key) or `idempotency_key_in_flight` (wait, then retry).'
          title: Idempotency-Key
        description: 'A key you choose so a retry is safe: a retry with the same key and body gets the
          first response back instead of running again. Reusing a key for a different request, or while
          the first is still running, returns 409 `conflict`, with `details` `idempotency_key_reused`
          (use a new key) or `idempotency_key_in_flight` (wait, then retry).'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RecallRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RecallResponse'
          headers:
            X-Request-Id:
              $ref: '#/components/headers/X-Request-Id'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '503':
          $ref: '#/components/responses/ServiceUnavailable'
        '500':
          $ref: '#/components/responses/InternalServerError'
        '429':
          $ref: '#/components/responses/TooManyRequests'
      security:
      - projectKey: []
      x-mint:
        href: /api-reference/v2/threads/learn-and-recall
        metadata:
          sidebarTitle: Learn and recall
  /v2/agents/{agent_id}/threads/{thread_id}/recall:
    post:
      tags:
      - Threads
      summary: Recall memories
      description: 'Return the memories the agent uses for one message, and learn nothing. The message
        is kept in the thread''s

        history with how many memories came back (not the memories), and never becomes a memory. Deleting
        the thread hides

        it and does not erase it.'
      operationId: recall_v2
      parameters:
      - name: agent_id
        in: path
        required: true
        schema:
          type: string
          pattern: ^agent_[0-9A-HJKMNP-TV-Z]{26}$
          description: The agent's identifier.
          title: Agent Id
        description: The agent's identifier.
      - name: thread_id
        in: path
        required: true
        schema:
          type: string
          pattern: ^thread_[0-9A-HJKMNP-TV-Z]{26}$
          description: The thread's identifier, scoped to the agent.
          title: Thread Id
        description: The thread's identifier, scoped to the agent.
      - name: Idempotency-Key
        in: header
        required: false
        schema:
          anyOf:
          - type: string
            minLength: 1
            maxLength: 255
          - type: 'null'
          description: 'A key you choose so a retry is safe: a retry with the same key and body gets the
            first response back instead of running again. Reusing a key for a different request, or while
            the first is still running, returns 409 `conflict`, with `details` `idempotency_key_reused`
            (use a new key) or `idempotency_key_in_flight` (wait, then retry).'
          title: Idempotency-Key
        description: 'A key you choose so a retry is safe: a retry with the same key and body gets the
          first response back instead of running again. Reusing a key for a different request, or while
          the first is still running, returns 409 `conflict`, with `details` `idempotency_key_reused`
          (use a new key) or `idempotency_key_in_flight` (wait, then retry).'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RecallRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RecallResponse'
          headers:
            X-Request-Id:
              $ref: '#/components/headers/X-Request-Id'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '503':
          $ref: '#/components/responses/ServiceUnavailable'
        '500':
          $ref: '#/components/responses/InternalServerError'
        '429':
          $ref: '#/components/responses/TooManyRequests'
      security:
      - projectKey: []
      x-mint:
        href: /api-reference/v2/threads/recall-memories
        metadata:
          sidebarTitle: Recall memories
  /v2/agents/{agent_id}/files:
    get:
      tags:
      - Files
      summary: List files
      description: 'The agent''s files, newest first. With `thread_id`, or when the caller may not see
        every file, a page can come

        back short or empty while `next_cursor` is still set.'
      operationId: list_files_v2
      parameters:
      - name: agent_id
        in: path
        required: true
        schema:
          type: string
          pattern: ^agent_[0-9A-HJKMNP-TV-Z]{26}$
          description: The agent's identifier.
          title: Agent Id
        description: The agent's identifier.
      - name: thread_id
        in: query
        required: false
        schema:
          anyOf:
          - type: string
            pattern: ^thread_[0-9A-HJKMNP-TV-Z]{26}$
            description: Server-generated thread identifier.
          - type: 'null'
          description: Only the files uploaded into this thread.
          title: Thread Id
        description: Only the files uploaded into this thread.
      - name: type
        in: query
        required: false
        schema:
          anyOf:
          - enum:
            - document
            - image
            type: string
          - type: 'null'
          description: Only documents, or only images.
          title: Type
        description: Only documents, or only images.
      - name: limit
        in: query
        required: false
        schema:
          type: integer
          maximum: 100
          minimum: 1
          description: The most rows to return in one page.
          default: 50
          title: Limit
        description: The most rows to return in one page.
      - name: cursor
        in: query
        required: false
        schema:
          anyOf:
          - type: string
            maxLength: 2048
          - type: 'null'
          description: The `next_cursor` of the previous page. Omit to read the first page.
          title: Cursor
        description: The `next_cursor` of the previous page. Omit to read the first page.
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Page_File_'
          headers:
            X-Request-Id:
              $ref: '#/components/headers/X-Request-Id'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '503':
          $ref: '#/components/responses/ServiceUnavailable'
        '500':
          $ref: '#/components/responses/InternalServerError'
      security:
      - projectKey: []
      x-mint:
        href: /api-reference/v2/files/list-files
        metadata:
          sidebarTitle: List files
  /v2/agents/{agent_id}/files/{file_id}:
    get:
      tags:
      - Files
      summary: Get file
      description: One file and its learning progress. While the file is being read, `Retry-After` says
        when to ask again.
      operationId: get_file_v2
      parameters:
      - name: agent_id
        in: path
        required: true
        schema:
          type: string
          pattern: ^agent_[0-9A-HJKMNP-TV-Z]{26}$
          description: The agent's identifier.
          title: Agent Id
        description: The agent's identifier.
      - name: file_id
        in: path
        required: true
        schema:
          type: string
          pattern: ^(?:src_|img_)[0-9a-f]{32}$
          description: The file's id.
          title: File Id
        description: The file's id.
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/File'
          headers:
            X-Request-Id:
              $ref: '#/components/headers/X-Request-Id'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '503':
          $ref: '#/components/responses/ServiceUnavailable'
        '500':
          $ref: '#/components/responses/InternalServerError'
      security:
      - projectKey: []
      x-mint:
        href: /api-reference/v2/files/get-file
        metadata:
          sidebarTitle: Get file
    delete:
      tags:
      - Files
      summary: Delete file
      description: 'Delete the file, its pictures, and the memories of every turn that cites it: your
        own upload, or anyone''s for

        whoever manages the agent''s files. Returns 202 once the file is gone; the deletion is done when
        every turn listed

        at `Location` is `forgotten`.'
      operationId: delete_file_v2
      parameters:
      - name: agent_id
        in: path
        required: true
        schema:
          type: string
          pattern: ^agent_[0-9A-HJKMNP-TV-Z]{26}$
          description: The agent's identifier.
          title: Agent Id
        description: The agent's identifier.
      - name: file_id
        in: path
        required: true
        schema:
          type: string
          pattern: ^(?:src_|img_)[0-9a-f]{32}$
          description: The file's id.
          title: File Id
        description: The file's id.
      responses:
        '202':
          description: Successful Response
          headers:
            X-Request-Id:
              $ref: '#/components/headers/X-Request-Id'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '503':
          $ref: '#/components/responses/ServiceUnavailable'
        '500':
          $ref: '#/components/responses/InternalServerError'
      security:
      - projectKey: []
      x-mint:
        href: /api-reference/v2/files/delete-file
        metadata:
          sidebarTitle: Delete file
  /v2/agents/{agent_id}/files/{file_id}/download:
    get:
      tags:
      - Files
      summary: Download file
      description: 'The file''s bytes, served inline and never cached. A file the caller may not see returns
        the same 404 as a

        missing one.'
      operationId: download_file_v2
      parameters:
      - name: agent_id
        in: path
        required: true
        schema:
          type: string
          pattern: ^agent_[0-9A-HJKMNP-TV-Z]{26}$
          description: The agent's identifier.
          title: Agent Id
        description: The agent's identifier.
      - name: file_id
        in: path
        required: true
        schema:
          type: string
          pattern: ^(?:src_|img_)[0-9a-f]{32}$
          description: The file's id.
          title: File Id
        description: The file's id.
      responses:
        '200':
          description: The file's bytes, with its own media type.
          content:
            application/octet-stream:
              schema:
                type: string
                format: binary
          headers:
            Cache-Control:
              $ref: '#/components/headers/Cache-Control'
            X-Request-Id:
              $ref: '#/components/headers/X-Request-Id'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '503':
          $ref: '#/components/responses/ServiceUnavailable'
        '500':
          $ref: '#/components/responses/InternalServerError'
      security:
      - projectKey: []
      x-mint:
        href: /api-reference/v2/files/download-file
        metadata:
          sidebarTitle: Download file
  /v2/agents/{agent_id}/files/{file_id}/resume:
    post:
      tags:
      - Files
      summary: Resume a file
      description: 'Finish a stopped upload, or read a finished document''s unread pictures again. Returns
        202 with the file;

        `Location` points at the file to poll.'
      operationId: resume_file_v2
      parameters:
      - name: agent_id
        in: path
        required: true
        schema:
          type: string
          pattern: ^agent_[0-9A-HJKMNP-TV-Z]{26}$
          description: The agent's identifier.
          title: Agent Id
        description: The agent's identifier.
      - name: file_id
        in: path
        required: true
        schema:
          type: string
          pattern: ^(?:src_)[0-9a-f]{32}$
          description: The document's file id.
          title: File Id
        description: The document's file id.
      requestBody:
        content:
          application/json:
            schema:
              anyOf:
              - $ref: '#/components/schemas/ResumeRequest'
              - type: 'null'
              title: Body
      responses:
        '202':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/File'
          headers:
            X-Request-Id:
              $ref: '#/components/headers/X-Request-Id'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '503':
          $ref: '#/components/responses/ServiceUnavailable'
        '500':
          $ref: '#/components/responses/InternalServerError'
        '429':
          $ref: '#/components/responses/TooManyRequests'
      security:
      - projectKey: []
      x-mint:
        href: /api-reference/v2/files/resume-a-file
        metadata:
          sidebarTitle: Resume a file
  /v2/agents/{agent_id}/threads:
    get:
      tags:
      - Threads
      summary: List threads
      description: 'The threads the caller may reach, oldest first unless `order` is desc: every live
        one for the owner and a

        member, and only their own for anyone else in the organization.'
      operationId: list_threads_v2
      parameters:
      - name: agent_id
        in: path
        required: true
        schema:
          type: string
          pattern: ^agent_[0-9A-HJKMNP-TV-Z]{26}$
          description: The agent's identifier.
          title: Agent Id
        description: The agent's identifier.
      - name: order
        in: query
        required: false
        schema:
          enum:
          - asc
          - desc
          type: string
          description: asc lists the oldest thread first; desc, the newest.
          default: asc
          title: Order
        description: asc lists the oldest thread first; desc, the newest.
      - name: limit
        in: query
        required: false
        schema:
          type: integer
          maximum: 100
          minimum: 1
          description: The most rows to return in one page.
          default: 50
          title: Limit
        description: The most rows to return in one page.
      - name: cursor
        in: query
        required: false
        schema:
          anyOf:
          - type: string
            maxLength: 2048
          - type: 'null'
          description: The `next_cursor` of the previous page. Omit to read the first page.
          title: Cursor
        description: The `next_cursor` of the previous page. Omit to read the first page.
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Page_Thread_'
          headers:
            X-Request-Id:
              $ref: '#/components/headers/X-Request-Id'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '503':
          $ref: '#/components/responses/ServiceUnavailable'
        '500':
          $ref: '#/components/responses/InternalServerError'
      security:
      - projectKey: []
      x-mint:
        href: /api-reference/v2/threads/list-threads
        metadata:
          sidebarTitle: List threads
    post:
      tags:
      - Threads
      summary: Create thread
      description: Start a new thread on the agent.
      operationId: create_thread_v2
      parameters:
      - name: agent_id
        in: path
        required: true
        schema:
          type: string
          pattern: ^agent_[0-9A-HJKMNP-TV-Z]{26}$
          description: The agent's identifier.
          title: Agent Id
        description: The agent's identifier.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateThreadRequest'
      responses:
        '201':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Thread'
          headers:
            X-Request-Id:
              $ref: '#/components/headers/X-Request-Id'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '503':
          $ref: '#/components/responses/ServiceUnavailable'
        '500':
          $ref: '#/components/responses/InternalServerError'
        '429':
          $ref: '#/components/responses/TooManyRequests'
      security:
      - projectKey: []
      x-mint:
        href: /api-reference/v2/threads/create-thread
        metadata:
          sidebarTitle: Create thread
  /v2/agents/{agent_id}/threads/{thread_id}:
    get:
      tags:
      - Threads
      summary: Get thread
      description: One thread with its latest turns. The agent's owner reads older ones with `GET /memories?thread_id=`.
      operationId: get_thread_v2
      parameters:
      - name: agent_id
        in: path
        required: true
        schema:
          type: string
          pattern: ^agent_[0-9A-HJKMNP-TV-Z]{26}$
          description: The agent's identifier.
          title: Agent Id
        description: The agent's identifier.
      - name: thread_id
        in: path
        required: true
        schema:
          type: string
          pattern: ^thread_[0-9A-HJKMNP-TV-Z]{26}$
          description: The thread's identifier, scoped to the agent.
          title: Thread Id
        description: The thread's identifier, scoped to the agent.
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ThreadWithMessages'
          headers:
            X-Request-Id:
              $ref: '#/components/headers/X-Request-Id'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '503':
          $ref: '#/components/responses/ServiceUnavailable'
        '500':
          $ref: '#/components/responses/InternalServerError'
      security:
      - projectKey: []
      x-mint:
        href: /api-reference/v2/threads/get-thread
        metadata:
          sidebarTitle: Get thread
    patch:
      tags:
      - Threads
      summary: Update thread
      description: Change a thread's title or metadata. Fields left out stay as they are.
      operationId: update_thread_v2
      parameters:
      - name: agent_id
        in: path
        required: true
        schema:
          type: string
          pattern: ^agent_[0-9A-HJKMNP-TV-Z]{26}$
          description: The agent's identifier.
          title: Agent Id
        description: The agent's identifier.
      - name: thread_id
        in: path
        required: true
        schema:
          type: string
          pattern: ^thread_[0-9A-HJKMNP-TV-Z]{26}$
          description: The thread's identifier, scoped to the agent.
          title: Thread Id
        description: The thread's identifier, scoped to the agent.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateThreadRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Thread'
          headers:
            X-Request-Id:
              $ref: '#/components/headers/X-Request-Id'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '503':
          $ref: '#/components/responses/ServiceUnavailable'
        '500':
          $ref: '#/components/responses/InternalServerError'
      security:
      - projectKey: []
      x-mint:
        href: /api-reference/v2/threads/update-thread
        metadata:
          sidebarTitle: Update thread
    delete:
      tags:
      - Threads
      summary: Delete thread
      description: 'Delete the thread and discard what it has not learned yet. The memories it made stay,
        and its saved turns,

        respond and recall ones included, are hidden rather than erased.'
      operationId: delete_thread_v2
      parameters:
      - name: agent_id
        in: path
        required: true
        schema:
          type: string
          pattern: ^agent_[0-9A-HJKMNP-TV-Z]{26}$
          description: The agent's identifier.
          title: Agent Id
        description: The agent's identifier.
      - name: thread_id
        in: path
        required: true
        schema:
          type: string
          pattern: ^thread_[0-9A-HJKMNP-TV-Z]{26}$
          description: The thread's identifier, scoped to the agent.
          title: Thread Id
        description: The thread's identifier, scoped to the agent.
      responses:
        '202':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Thread'
          headers:
            X-Request-Id:
              $ref: '#/components/headers/X-Request-Id'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '503':
          $ref: '#/components/responses/ServiceUnavailable'
        '500':
          $ref: '#/components/responses/InternalServerError'
      security:
      - projectKey: []
      x-mint:
        href: /api-reference/v2/threads/delete-thread
        metadata:
          sidebarTitle: Delete thread
  /v2/agents/{agent_id}/memories:
    get:
      tags:
      - Memories
      summary: List memories
      description: 'The agent''s turns across its threads, newest first. File pieces are listed only when
        the request names a

        `file_id`, an `observation_id` or the piece''s own `thread_id`. Owner only.'
      operationId: list_memories_v2
      parameters:
      - name: agent_id
        in: path
        required: true
        schema:
          type: string
          pattern: ^agent_[0-9A-HJKMNP-TV-Z]{26}$
          description: The agent's identifier.
          title: Agent Id
        description: The agent's identifier.
      - name: thread_id
        in: query
        required: false
        schema:
          anyOf:
          - type: string
            pattern: ^thread_[0-9A-HJKMNP-TV-Z]{26}$
            description: Server-generated thread identifier.
          - type: 'null'
          description: Only the turns of this thread.
          title: Thread Id
        description: Only the turns of this thread.
      - name: file_id
        in: query
        required: false
        schema:
          anyOf:
          - type: string
            pattern: ^(?:src_|img_)[0-9a-f]{32}$
          - type: 'null'
          description: Only the turns that came from this file.
          title: File Id
        description: Only the turns that came from this file.
      - name: speaker_id
        in: query
        required: false
        schema:
          anyOf:
          - type: string
            minLength: 1
            maxLength: 200
          - type: 'null'
          description: Only the turns sent with this `speaker_id`.
          title: Speaker Id
        description: Only the turns sent with this `speaker_id`.
      - name: observation_id
        in: query
        required: false
        schema:
          anyOf:
          - type: string
            pattern: ^obs_[0-9A-HJKMNP-TV-Z]{26}$
            description: Server-generated observation identifier.
          - type: 'null'
          description: Only the turns of the observe, observe-and-respond or observe-and-recall call that
            returned this id. Some older observe turns carry no id and are never listed.
          title: Observation Id
        description: Only the turns of the observe, observe-and-respond or observe-and-recall call that
          returned this id. Some older observe turns carry no id and are never listed.
      - name: state
        in: query
        required: false
        schema:
          anyOf:
          - enum:
            - learned
            - learning
            - not_learned
            - forgotten
            type: string
          - type: 'null'
          description: Only the turns in this state, such as not_learned for the turns to send again.
            A page can then hold fewer than `limit` turns; follow `next_cursor` until it is null.
          title: State
        description: Only the turns in this state, such as not_learned for the turns to send again. A
          page can then hold fewer than `limit` turns; follow `next_cursor` until it is null.
      - name: limit
        in: query
        required: false
        schema:
          type: integer
          maximum: 100
          minimum: 1
          description: The most rows to return in one page.
          default: 50
          title: Limit
        description: The most rows to return in one page.
      - name: cursor
        in: query
        required: false
        schema:
          anyOf:
          - type: string
            maxLength: 2048
          - type: 'null'
          description: The `next_cursor` of the previous page. Omit to read the first page.
          title: Cursor
        description: The `next_cursor` of the previous page. Omit to read the first page.
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Page_Turn_'
          headers:
            X-Request-Id:
              $ref: '#/components/headers/X-Request-Id'
        '404':
          $ref: '#/components/responses/OwnedAgentNotFound'
        '409':
          $ref: '#/components/responses/AgentNotReady'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '503':
          $ref: '#/components/responses/ServiceUnavailable'
        '500':
          $ref: '#/components/responses/InternalServerError'
      security:
      - projectKey: []
      x-mint:
        href: /api-reference/v2/memories/list-memories
        metadata:
          sidebarTitle: List memories
  /v2/agents/{agent_id}/memories/{turn_id}:
    delete:
      tags:
      - Memories
      summary: Forget a memory
      description: Delete every memory made from a turn; the turn stays in its conversation, `forgotten`.
        Owner only.
      operationId: delete_memory_v2
      parameters:
      - name: agent_id
        in: path
        required: true
        schema:
          type: string
          pattern: ^agent_[0-9A-HJKMNP-TV-Z]{26}$
          description: The agent's identifier.
          title: Agent Id
        description: The agent's identifier.
      - name: turn_id
        in: path
        required: true
        schema:
          type: string
          minLength: 1
          maxLength: 200
          description: The id of the turn whose memories to delete.
          title: Turn Id
        description: The id of the turn whose memories to delete.
      responses:
        '204':
          description: Successful Response
          headers:
            X-Request-Id:
              $ref: '#/components/headers/X-Request-Id'
        '404':
          $ref: '#/components/responses/MemoryNotFound'
        '409':
          $ref: '#/components/responses/ForgetMemoryConflict'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '503':
          $ref: '#/components/responses/ServiceUnavailable'
        '500':
          $ref: '#/components/responses/InternalServerError'
      security:
      - projectKey: []
      x-mint:
        href: /api-reference/v2/memories/forget-a-memory
        metadata:
          sidebarTitle: Forget a memory
  /v2/agents:
    get:
      tags:
      - Agents
      summary: List agents
      description: The agents the caller owns, or that are shared with them, a page at a time.
      operationId: list_agents_v2
      parameters:
      - name: scope
        in: query
        required: false
        schema:
          enum:
          - owned
          - shared
          type: string
          description: 'owned for the agents the caller owns; shared for the agents shared with them.
            Omitted, it is owned, except that a service account''s key then lists every agent it can use
            in its project: those it administers are its owned ones, and the rest its shared ones.'
          title: Scope
        description: 'owned for the agents the caller owns; shared for the agents shared with them. Omitted,
          it is owned, except that a service account''s key then lists every agent it can use in its project:
          those it administers are its owned ones, and the rest its shared ones.'
      - name: limit
        in: query
        required: false
        schema:
          type: integer
          maximum: 100
          minimum: 1
          description: The most rows to return in one page.
          default: 50
          title: Limit
        description: The most rows to return in one page.
      - name: cursor
        in: query
        required: false
        schema:
          anyOf:
          - type: string
            maxLength: 2048
          - type: 'null'
          description: The `next_cursor` of the previous page. Omit to read the first page.
          title: Cursor
        description: The `next_cursor` of the previous page. Omit to read the first page.
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Page_AgentSummary_'
          headers:
            X-Request-Id:
              $ref: '#/components/headers/X-Request-Id'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '503':
          $ref: '#/components/responses/ServiceUnavailable'
        '500':
          $ref: '#/components/responses/InternalServerError'
      security:
      - projectKey: []
      x-mint:
        href: /api-reference/v2/agents/list-agents
        metadata:
          sidebarTitle: List agents
    post:
      tags:
      - Agents
      summary: Create agent
      description: Create an agent. Returns 202 while it initializes; poll the `Location` until `status`
        is `ready`.
      operationId: create_agent_v2
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateAgentV2Request'
      responses:
        '202':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AgentSummary'
          headers:
            X-Request-Id:
              $ref: '#/components/headers/X-Request-Id'
        '409':
          $ref: '#/components/responses/AgentQuotaExceeded'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '503':
          $ref: '#/components/responses/ServiceUnavailable'
        '500':
          $ref: '#/components/responses/InternalServerError'
      security:
      - projectKey: []
      x-mint:
        href: /api-reference/v2/agents/create-agent
        metadata:
          sidebarTitle: Create agent
  /v2/agents/{agent_id}:
    get:
      tags:
      - Agents
      summary: Get agent
      description: One agent, without its threads. Poll it after creating an agent until `status` is ready.
      operationId: get_agent_v2
      parameters:
      - name: agent_id
        in: path
        required: true
        schema:
          type: string
          pattern: ^agent_[0-9A-HJKMNP-TV-Z]{26}$
          description: The agent's identifier.
          title: Agent Id
        description: The agent's identifier.
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AgentSummary'
          headers:
            X-Request-Id:
              $ref: '#/components/headers/X-Request-Id'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '503':
          $ref: '#/components/responses/ServiceUnavailable'
        '500':
          $ref: '#/components/responses/InternalServerError'
      security:
      - projectKey: []
      x-mint:
        href: /api-reference/v2/agents/get-agent
        metadata:
          sidebarTitle: Get agent
    patch:
      tags:
      - Agents
      summary: Update agent
      description: Replace an agent's config. Owner only.
      operationId: update_agent_v2
      parameters:
      - name: agent_id
        in: path
        required: true
        schema:
          type: string
          pattern: ^agent_[0-9A-HJKMNP-TV-Z]{26}$
          description: The agent's identifier.
          title: Agent Id
        description: The agent's identifier.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateAgentV2Request'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AgentSummary'
          headers:
            X-Request-Id:
              $ref: '#/components/headers/X-Request-Id'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '503':
          $ref: '#/components/responses/ServiceUnavailable'
        '500':
          $ref: '#/components/responses/InternalServerError'
      security:
      - projectKey: []
      x-mint:
        href: /api-reference/v2/agents/update-agent
        metadata:
          sidebarTitle: Update agent
    delete:
      tags:
      - Agents
      summary: Delete agent
      description: Delete an agent. Owner only.
      operationId: delete_agent_v2
      parameters:
      - name: agent_id
        in: path
        required: true
        schema:
          type: string
          pattern: ^agent_[0-9A-HJKMNP-TV-Z]{26}$
          description: The agent's identifier.
          title: Agent Id
        description: The agent's identifier.
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AgentSummary'
          headers:
            X-Request-Id:
              $ref: '#/components/headers/X-Request-Id'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '503':
          $ref: '#/components/responses/ServiceUnavailable'
        '500':
          $ref: '#/components/responses/InternalServerError'
      security:
      - projectKey: []
      x-mint:
        href: /api-reference/v2/agents/delete-agent
        metadata:
          sidebarTitle: Delete agent
  /v2/agents/{agent_id}/logs:
    get:
      tags:
      - Agents
      summary: List activity
      description: 'Who used the agent, newest first: one row per side of each completed turn, no message
        text. Owner only.'
      operationId: list_logs_v2
      parameters:
      - name: agent_id
        in: path
        required: true
        schema:
          type: string
          pattern: ^agent_[0-9A-HJKMNP-TV-Z]{26}$
          description: The agent's identifier.
          title: Agent Id
        description: The agent's identifier.
      - name: thread_id
        in: query
        required: false
        schema:
          anyOf:
          - type: string
            pattern: ^thread_[0-9A-HJKMNP-TV-Z]{26}$
            description: Server-generated thread identifier.
          - type: 'null'
          description: Only the turns taken in this thread.
          title: Thread Id
        description: Only the turns taken in this thread.
      - name: limit
        in: query
        required: false
        schema:
          type: integer
          maximum: 100
          minimum: 1
          description: The most rows to return in one page.
          default: 50
          title: Limit
        description: The most rows to return in one page.
      - name: cursor
        in: query
        required: false
        schema:
          anyOf:
          - type: string
            maxLength: 2048
          - type: 'null'
          description: The `next_cursor` of the previous page. Omit to read the first page.
          title: Cursor
        description: The `next_cursor` of the previous page. Omit to read the first page.
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Page_ActivityEntry_'
          headers:
            X-Request-Id:
              $ref: '#/components/headers/X-Request-Id'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '503':
          $ref: '#/components/responses/ServiceUnavailable'
        '500':
          $ref: '#/components/responses/InternalServerError'
      security:
      - projectKey: []
      x-mint:
        href: /api-reference/v2/agents/list-activity
        metadata:
          sidebarTitle: List activity
  /v2/organization/members:
    get:
      tags:
      - Organization
      summary: Find a member
      description: 'The colleague in the caller''s organization who signs in with `email`, to share an
        agent with. An unknown email

        and one outside the organization return the same 404.'
      operationId: find_member
      parameters:
      - name: email
        in: query
        required: true
        schema:
          type: string
          minLength: 3
          maxLength: 254
          description: The email the colleague signs in with.
          title: Email
        description: The email the colleague signs in with.
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Member'
          headers:
            X-Request-Id:
              $ref: '#/components/headers/X-Request-Id'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '503':
          $ref: '#/components/responses/ServiceUnavailable'
        '500':
          $ref: '#/components/responses/InternalServerError'
        '429':
          $ref: '#/components/responses/TooManyRequests'
      security:
      - projectKey: []
      x-mint:
        href: /api-reference/v2/organization/find-a-member
        metadata:
          sidebarTitle: Find a member
  /v2/me:
    get:
      tags:
      - Users
      summary: Get me
      description: Who the caller is and the organization they act in. `organization` is null until they
        join one.
      operationId: get_me
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Me'
          headers:
            X-Request-Id:
              $ref: '#/components/headers/X-Request-Id'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '503':
          $ref: '#/components/responses/ServiceUnavailable'
        '500':
          $ref: '#/components/responses/InternalServerError'
      security:
      - projectKey: []
      x-mint:
        href: /api-reference/v2/users/get-me
        metadata:
          sidebarTitle: Get me
  /v2/projects/{project_id}/usage:
    get:
      tags:
      - Projects
      summary: Get a project's usage
      description: 'Every charge to the project over the range: totals, daily buckets, and sums by agent,
        by API key and by

        operation. Agents the caller cannot open in this project are summed into one `agent_restricted`
        row. A charge made without a key

        is grouped by how it was made: by a person signed in, by an app key, or before credentials were
        recorded.'
      operationId: get_project_usage
      parameters:
      - name: project_id
        in: path
        required: true
        schema:
          type: string
          pattern: ^proj_[0-9A-HJKMNP-TV-Z]{26}$
          description: The project's identifier.
          title: Project Id
        description: The project's identifier.
      - name: from
        in: query
        required: true
        schema:
          type: string
          format: date
          description: First day of the range, inclusive, in `tz`.
          title: From
        description: First day of the range, inclusive, in `tz`.
      - name: to
        in: query
        required: true
        schema:
          type: string
          format: date
          description: Last day of the range, inclusive, in `tz`. The range is at most 366 days, counting
            both ends.
          title: To
        description: Last day of the range, inclusive, in `tz`. The range is at most 366 days, counting
          both ends.
      - name: tz
        in: query
        required: true
        schema:
          type: string
          minLength: 1
          maxLength: 64
          pattern: ^[A-Za-z0-9_+\-/]+$
          description: IANA time zone the days are bucketed in.
          examples:
          - Asia/Kolkata
          title: Tz
        description: IANA time zone the days are bucketed in.
      - name: agent_id
        in: query
        required: false
        schema:
          anyOf:
          - type: string
            minLength: 1
            maxLength: 200
          - type: 'null'
          description: Only this agent's charges. A non-admin naming an agent they cannot reach gets 404.
          title: Agent Id
        description: Only this agent's charges. A non-admin naming an agent they cannot reach gets 404.
      - name: route
        in: query
        required: false
        schema:
          anyOf:
          - enum:
            - observe
            - observe-and-recall
            - recall
            - observe-and-respond
            - respond
            type: string
          - type: 'null'
          description: Only charges made through this operation.
          title: Route
        description: Only charges made through this operation.
      - name: api_key_id
        in: query
        required: false
        schema:
          anyOf:
          - type: string
            minLength: 1
            maxLength: 200
          - type: 'null'
          description: Only the charges made with this API key.
          title: Api Key Id
        description: Only the charges made with this API key.
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProjectUsageReport'
          headers:
            X-Request-Id:
              $ref: '#/components/headers/X-Request-Id'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '503':
          $ref: '#/components/responses/ServiceUnavailable'
        '500':
          $ref: '#/components/responses/InternalServerError'
      security:
      - projectKey: []
      x-mint:
        href: /api-reference/v2/projects/get-a-projects-usage
        metadata:
          sidebarTitle: Get a project's usage
  /v2/health/answer-mode:
    get:
      tags:
      - Health
      summary: Get the answer mode
      description: Whether memory is fully active ("fast"), starting up ("warming") or idle. Reading it
        starts nothing.
      operationId: get_answer_mode
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AnswerMode'
          headers:
            X-Request-Id:
              $ref: '#/components/headers/X-Request-Id'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '503':
          $ref: '#/components/responses/ServiceUnavailable'
        '500':
          $ref: '#/components/responses/InternalServerError'
      security:
      - projectKey: []
      x-mint:
        href: /api-reference/v2/health/get-the-answer-mode
        metadata:
          sidebarTitle: Get the answer mode
components:
  schemas:
    ActivityEntry:
      properties:
        log_id:
          type: integer
          format: int64
          title: Log Id
          description: Id of this entry in the activity history.
        thread_id:
          anyOf:
          - type: string
          - type: 'null'
          title: Thread Id
          description: The thread the turn was taken in.
        user_id:
          type: string
          title: User Id
          description: Immutable id of the principal who took the turn.
        actor_email:
          type: string
          title: Actor Email
          description: The principal's email when they took the turn.
        actor_display_name:
          type: string
          title: Actor Display Name
          description: The principal's display name when they took the turn.
        direction:
          type: string
          enum:
          - user
          - agent
          title: Direction
          description: '`user` for what the principal sent; `agent` for what the agent returned. Treat
            an unknown value as opaque, not as an error.

            '
        route:
          type: string
          enum:
          - observe
          - observe_and_respond
          - respond
          - observe_and_recall
          - recall
          title: Route
          description: 'The call that took the turn. Treat an unknown value as opaque, not as an error.

            '
        request_id:
          anyOf:
          - type: string
          - type: 'null'
          title: Request Id
          description: The id of the request that took the turn.
        created_at:
          type: string
          format: date-time
          title: Created At
          description: 'When the principal''s side was accepted, or when the agent''s side completed.

            '
      type: object
      required:
      - log_id
      - thread_id
      - user_id
      - actor_email
      - actor_display_name
      - direction
      - route
      - request_id
      - created_at
      title: ActivityEntry
      description: 'One side of one completed turn in an agent''s activity history: who acted and how,
        never what was said. The actor fields are as they were when the turn was recorded.

        '
    AgentConfig:
      properties:
        role:
          type: string
          maxLength: 200
          minLength: 1
          title: Role
          description: Short description of the memory agent's role.
        objective:
          type: string
          maxLength: 2000
          minLength: 1
          title: Objective
          description: Primary learning objective this memory agent supports.
        metadata:
          additionalProperties: true
          type: object
          maxProperties: 50
          title: Metadata
          description: 'Opaque caller-defined metadata, at most 50 keys.

            '
      additionalProperties: false
      type: object
      required:
      - role
      - objective
      title: AgentConfig
      description: The role and objective a memory agent works to, with caller metadata.
    AgentConfigResponse:
      properties:
        role:
          type: string
          maxLength: 200
          minLength: 1
          title: Role
          description: Short description of the memory agent's role.
        objective:
          type: string
          maxLength: 2000
          minLength: 1
          title: Objective
          description: Primary learning objective this memory agent supports.
        metadata:
          additionalProperties: true
          type: object
          maxProperties: 50
          title: Metadata
          description: 'Opaque caller-defined metadata, at most 50 keys.

            '
      type: object
      required:
      - role
      - objective
      - metadata
      title: AgentConfigResponse
      description: An agent's role, objective and metadata.
    AgentSummary:
      properties:
        agent_id:
          type: string
          pattern: ^agent_[0-9A-HJKMNP-TV-Z]{26}$
          title: Agent Id
          description: Unique identifier for the managed memory agent.
        status:
          type: string
          enum:
          - initializing
          - ready
          - failed
          - deleted
          title: Status
          description: The agent's lifecycle state.
        agent_config:
          $ref: '#/components/schemas/AgentConfigResponse'
          description: The agent's role, objective and metadata.
        created_at:
          type: string
          format: date-time
          title: Created At
          description: When this was created.
        updated_at:
          type: string
          format: date-time
          title: Updated At
          description: When this was last changed.
        visibility:
          type: string
          enum:
          - public
          - private
          title: Visibility
          description: 'Who can reach the agent: `public` or `private`. Creating an agent describes each
            value. A Project admin can change it in the Priors application.

            '
        access:
          type: string
          enum:
          - owner
          - member
          - organization
          title: Access
          description: 'How the caller reaches the agent:


            - `owner`: they own it.

            - `member`: they were given access, and reach every thread.

            - `organization`: a member of its organization reaching a discoverable agent not shared with
            them. They reach only the threads they created.

            '
      type: object
      required:
      - agent_id
      - status
      - agent_config
      - created_at
      - updated_at
      - visibility
      - access
      title: AgentSummary
      description: A memory agent, without its threads.
    AnswerMode:
      properties:
        mode:
          type: string
          enum:
          - fast
          - warming
          - idle
          title: Mode
          description: '"fast": memory is fully active. "warming": memory is starting up, usually for
            a few minutes; replies arrive normally. "idle": memory has not been used for a while; the
            next request starts it and is answered while it warms.'
      type: object
      required:
      - mode
      title: AnswerMode
      description: Whether memory is fully active, starting up, or idle.
    ApiKeyRef:
      properties:
        key_id:
          type: string
          title: Key Id
          description: The key's id, the part between its prefix and its secret.
        name:
          anyOf:
          - type: string
          - type: 'null'
          title: Name
          description: The key's name; null when it is not known.
        owner:
          anyOf:
          - $ref: '#/components/schemas/PrincipalRef'
          - type: 'null'
          description: Who the key acts as; null when it is not known.
      type: object
      required:
      - key_id
      - name
      - owner
      title: ApiKeyRef
      description: An API key.
    Citation:
      properties:
        file_id:
          type: string
          title: File Id
          description: The file's id.
        label:
          type: string
          title: Label
          description: 'A name to show for the file: its filename.'
        media_type:
          type: string
          title: Media Type
          description: The file's media type.
        href:
          type: string
          title: Href
          description: Where to download the file, with the same credentials.
        verified:
          type: boolean
          title: Verified
          description: True when the agent looked at this image while answering; false when the answer
            only drew on memories learned from the file.
      type: object
      required:
      - file_id
      - label
      - media_type
      - href
      - verified
      title: Citation
      description: A file the answer drew on.
    CreateAgentV2Request:
      properties:
        agent_config:
          $ref: '#/components/schemas/AgentConfig'
        visibility:
          type: string
          enum:
          - public
          - private
          title: Visibility
          description: 'Who can reach the agent.


            - `public`: everyone with a role in the agent''s project, and the project''s service account
            keys.

            - `private`: its creator, the project''s Project admins and the organization''s Org admins.
            Service account keys never reach it.


            Only a Project admin or an Org admin creates a `public` agent; anyone else naming it gets
            403. Left out, the agent is `public` for them and `private` for anyone else. A service account''s
            agents are always `public`: its key naming `private` gets 400.

            '
      additionalProperties: false
      type: object
      required:
      - agent_config
      title: CreateAgentV2Request
      description: The new agent's config and who may reach it.
    CreateThreadRequest:
      properties:
        title:
          anyOf:
          - type: string
            maxLength: 200
            minLength: 1
          - type: 'null'
          title: Title
          description: Optional human-readable thread title.
        metadata:
          additionalProperties: true
          type: object
          maxProperties: 50
          title: Metadata
          description: 'Opaque caller-defined metadata, at most 50 keys.

            '
      additionalProperties: false
      type: object
      title: CreateThreadRequest
      description: The optional title and metadata a new thread is created with.
    ErrorResponse:
      properties:
        error:
          type: string
          title: Error
          description: A sentence describing what went wrong, for a person to read.
        code:
          type: string
          title: Code
          description: 'Machine-readable condition. Branch on this, not on the status. Treat an unknown
            value as the status code''s default meaning.


            Known values: invalid_request, images_not_accepted, unauthorized, forbidden, payment_required,
            insufficient_credits, not_found, agent_not_found, project_not_found, thread_not_found, conflict,
            agent_quota_exceeded, upload_in_progress, duplicate_upload_in_progress, document_already_ingested,
            document_uploaded_elsewhere, agent_not_ready, session_changed, trial_ended, trial_full_today,
            payload_too_large, unsupported_media_type, rate_limit_exceeded, service_unavailable, service_not_configured,
            answer_model_unavailable, empty_answer, upstream_timeout, internal_error, and the upload codes
            (unsupported_document, document_needs_ocr, encrypted_document, malformed_document, empty_document,
            document_too_large, document_too_complex, document_too_many_turns, document_too_many_pages,
            document_too_large_for_ocr, document_pages_unexpected, document_service_unavailable, ocr_failed,
            ingestion_failed, secret_file, document_contains_secret).


            Codes that need their own handling:


            - `service_unavailable` (503): a dependency is down. Retry.

            - `answer_model_unavailable` (503): the model that writes the reply could not be reached,
            so the turn has no answer. Retry shortly.

            - `empty_answer` (503): the model returned an empty reply. Retry.

            - `upstream_timeout` (504): an answer or recall ran too long and was stopped. Nothing was
            charged. Retry.

            - `service_not_configured` (503): the deployment is missing configuration. Retrying never
            clears it.

            - `internal_error` (500): a defect. The same request fails the same way again.

            - `agent_not_found`, `project_not_found`, `thread_not_found`: narrower `not_found` codes that
            say which resource is gone.

            '
        request_id:
          type: string
          title: Request Id
          description: 'Server-issued identifier for this request. Include it when reporting a problem.

            '
        details:
          type: string
          title: Details
          description: 'Condition-specific detail. On a 429 (`rate_limit_exceeded`) it names the limit
            that refused. For every scope: wait for `Retry-After`, then retry. Do not resend a non-idempotent
            request automatically.


            - `user`: your own credential''s rate (before sign-in, your client address). Slowing this
            caller clears it.

            - `organization`: the organization''s shared rate. Your organization''s other credentials
            are refused too.

            - `capacity`: a service-wide limit, unrelated to your rate.

            - `ingestion-organization`: your organization is processing as many documents as it may at
            once. The document was not started. The same file is accepted once one finishes.

            - `ingestion-capacity`: as `ingestion-organization`, service-wide.

            - `agent-occupancy`: this discoverable agent has as many users as its owner allows, and you
            are not one of them. `Retry-After` is when the earliest slot frees.


            Waits range from seconds (rate limits) to about ninety seconds (document limits), so read
            `Retry-After`. Treat an unknown scope the same way: wait, then retry. On other statuses this
            field is absent or free text; do not parse it.

            '
      type: object
      required:
      - error
      - code
      - request_id
      title: ErrorResponse
      description: The body of an error response.
    File:
      properties:
        file_id:
          type: string
          title: File Id
          description: The file's id.
        thread_id:
          anyOf:
          - type: string
          - type: 'null'
          title: Thread Id
          description: The thread the file was uploaded into; null when it is not known or the caller
            may not open that thread.
        filename:
          type: string
          title: Filename
          description: The file's name as uploaded.
        media_type:
          type: string
          title: Media Type
          description: The file's media type.
        size_bytes:
          type: integer
          minimum: 0
          title: Size Bytes
          description: The file's size in bytes.
        created_at:
          type: string
          format: date-time
          title: Created At
          description: When the file was uploaded.
        memory_state:
          type: string
          enum:
          - learned
          - available
          title: Memory State
          description: learned when the agent has learned from the file; available when it is kept but
            not yet learned from.
        upload_state:
          anyOf:
          - type: string
            enum:
            - learning
            - resuming
            - partial
            - failed
          - type: 'null'
          title: Upload State
          description: 'Where an unfinished upload stands: `learning`, `resuming` (by itself, after a
            restart), `partial` (stopped partway) or `failed`. null when nothing is unfinished.'
        turns_done:
          anyOf:
          - type: integer
          - type: 'null'
          title: Turns Done
          description: Turns learned so far, or before a partial upload stopped; null when nothing is
            unfinished.
        turns_total:
          anyOf:
          - type: integer
          - type: 'null'
          title: Turns Total
          description: Turns the upload has to learn; null when nothing is unfinished.
        stop_reason:
          anyOf:
          - type: string
            enum:
            - cancelled
            - learning_stopped
            - unreadable
          - type: 'null'
          title: Stop Reason
          description: 'Why a partial or failed upload ended: `cancelled` (it was stopped), `learning_stopped`
            (a section could not be learned; resume to try again) or `unreadable` (try another copy or
            format). null otherwise.'
        figures_unread:
          anyOf:
          - type: integer
          - type: 'null'
          title: Figures Unread
          description: Pictures in the document that could not be read, even when its text was learned
            whole.
        figures_retry:
          anyOf:
          - type: string
            enum:
            - running
            - available
          - type: 'null'
          title: Figures Retry
          description: '`running`: the unread pictures are being read again. `available`: resume with
            `only: "pictures"` to read them again. null when reading them again cannot help.'
        can_finish:
          anyOf:
          - type: boolean
          - type: 'null'
          title: Can Finish
          description: 'For a partial or failed upload: true when the caller may resume it in its upload
            thread, charged only for what is left. When false, resume it in another thread, charged in
            full.'
        finish_blocked:
          anyOf:
          - type: string
            enum:
            - not_yours
            - conversation_gone
          - type: 'null'
          title: Finish Blocked
          description: 'Why `can_finish` is false: `not_yours` (the caller may not open the upload thread)
            or `conversation_gone` (that thread no longer exists). null otherwise.'
        parent_file_id:
          anyOf:
          - type: string
          - type: 'null'
          title: Parent File Id
          description: The document a picture was cut from; null for a file uploaded on its own.
        href:
          type: string
          title: Href
          description: Where to download the file, with the same credentials.
      type: object
      required:
      - file_id
      - thread_id
      - filename
      - media_type
      - size_bytes
      - created_at
      - memory_state
      - upload_state
      - turns_done
      - turns_total
      - stop_reason
      - figures_unread
      - figures_retry
      - can_finish
      - finish_blocked
      - parent_file_id
      - href
      title: File
      description: A file uploaded to an agent, and how far the agent has got with learning it.
    FileRefusal:
      properties:
        code:
          type: string
          title: Code
          description: The error code a call sending only this file would answer.
        message:
          type: string
          title: Message
          description: What went wrong, in a sentence.
        retry_after:
          anyOf:
          - type: integer
          - type: 'null'
          title: Retry After
          description: Seconds after which sending this file again may succeed; null when waiting will
            not help.
      type: object
      required:
      - code
      - message
      - retry_after
      title: FileRefusal
      description: Why one file of the call was not accepted, as a call sending it alone would have been
        told.
    ImageFile:
      properties:
        type:
          type: string
          const: image
          title: Type
          description: Always `image`.
        data:
          anyOf:
          - type: string
            minLength: 1
          - type: 'null'
          title: Data
          description: The image's bytes, base64-encoded. Send this or `file_id`.
        file_id:
          anyOf:
          - type: string
            pattern: ^img_[0-9a-f]{32}$
            description: Server-generated image-source identifier accepted by chat.
          - type: 'null'
          title: File Id
          description: The id of an image this agent already keeps, such as one an earlier answer cited.
            Send this or `data`.
        media_type:
          anyOf:
          - type: string
            maxLength: 200
            minLength: 1
          - type: 'null'
          title: Media Type
          description: The image's media type, such as `image/png`.
        filename:
          anyOf:
          - type: string
            maxLength: 255
            minLength: 1
          - type: 'null'
          title: Filename
          description: The name to keep the image under. Defaults to one from its media type.
      additionalProperties: false
      type: object
      required:
      - type
      title: ImageFile
      description: 'An image in a message: its bytes as base64, or the `file_id` of one this agent keeps.'
    Me:
      properties:
        user:
          $ref: '#/components/schemas/MeUser'
        organization:
          anyOf:
          - $ref: '#/components/schemas/MeOrganization'
          - type: 'null'
          description: The organization the caller is acting in; null until they join one.
        api_key:
          anyOf:
          - $ref: '#/components/schemas/MeApiKey'
          - type: 'null'
          description: The API key the caller called with; null from a browser.
      type: object
      required:
      - user
      - organization
      - api_key
      title: Me
      description: Who the caller is and the organization they are acting in.
    MeApiKey:
      properties:
        key_id:
          type: string
          title: Key Id
          description: The key's id, the part between its prefix and its secret.
        project_id:
          anyOf:
          - type: string
          - type: 'null'
          title: Project Id
          description: The one project the key works in.
        acts_as:
          $ref: '#/components/schemas/MeKeyPrincipal'
          description: The person or service account the key acts as.
      type: object
      required:
      - key_id
      - project_id
      - acts_as
      title: MeApiKey
      description: The API key the caller called with.
    MeKeyPrincipal:
      properties:
        type:
          type: string
          enum:
          - user
          - service_account
          title: Type
          description: '`user` for a person''s key, `service_account` for a service account''s.'
        id:
          type: string
          title: Id
          description: The user id or the service account id.
      type: object
      required:
      - type
      - id
      title: MeKeyPrincipal
      description: Who an API key acts as.
    MeOrganization:
      properties:
        organization_id:
          type: string
          title: Organization Id
          description: The organization's id.
        name:
          anyOf:
          - type: string
          - type: 'null'
          title: Name
          description: The organization's name; null when it is not known.
      type: object
      required:
      - organization_id
      - name
      title: MeOrganization
      description: The organization the caller is acting in.
    MeUser:
      properties:
        user_id:
          type: string
          title: User Id
          description: The caller's user id.
        email:
          type: string
          title: Email
          description: The caller's email address.
        display_name:
          type: string
          title: Display Name
          description: The caller's display name.
      type: object
      required:
      - user_id
      - email
      - display_name
      title: MeUser
      description: The caller.
    Member:
      properties:
        user_id:
          type: string
          title: User Id
          description: The colleague's user id. Pass it to add them to an agent.
        email:
          type: string
          title: Email
          description: The email the colleague signs in with.
        display_name:
          type: string
          title: Display Name
          description: The colleague's display name.
      type: object
      required:
      - user_id
      - email
      - display_name
      title: Member
      description: A colleague in the caller's organization.
    NotLearned:
      properties:
        not_learned_turns:
          items:
            $ref: '#/components/schemas/TurnRange'
          type: array
          title: Not Learned Turns
          description: 'The turns not learned, as inclusive ranges counting from 1. Turn 1 is the first
            observation the job was sent.

            '
        reason:
          type: string
          title: Reason
          description: 'Stable code for why: for example generation_failed, model_unavailable, generation_timeout,
            earlier_turn_failed, queue_full, job_failed (the job hit its own error) or cancelled. Treat
            an unknown code like generation_failed.

            '
        message:
          type: string
          title: Message
          description: A sentence to show a person.
        refunded_credits:
          anyOf:
          - type: string
            pattern: ^-?\d+(\.\d+)?$
          - type: 'null'
          title: Refunded Credits
          description: 'Credits refunded for the input side of these turns, as a decimal string. null
            when nothing was refunded (nothing was charged, or billing is off).

            '
      type: object
      required:
      - not_learned_turns
      - reason
      - message
      - refunded_credits
      title: NotLearned
      description: 'Turns of an observation job that were not learned into memory. They are never learned
        later; send them again.

        '
    Observation:
      properties:
        observation_id:
          type: string
          pattern: ^obs_[0-9A-HJKMNP-TV-Z]{26}$
          title: Observation Id
          description: Server-generated observation identifier.
        status:
          type: string
          enum:
          - queued
          - converting
          - processing
          - interrupted
          - committed
          - failed
          - cancelled
          title: Status
          description: 'queued: waiting behind another file this agent is reading. converting: the file
            is being read. processing: turns are being learned. interrupted: paused by a restart; it resumes
            where it stopped and is not charged again. Poll these after Retry-After. committed, failed
            and cancelled are final.'
        turns_total:
          type: integer
          minimum: 0
          title: Turns Total
          description: Turns to learn. For a file, the turns it was split into; 0 until it has been read.
        turns_processed:
          type: integer
          minimum: 0
          title: Turns Processed
          description: Turns sent for learning so far. Only `committed` means done, even when this equals
            `turns_total`.
        error:
          anyOf:
          - type: string
          - type: 'null'
          title: Error
          description: What went wrong, when status is failed.
        error_code:
          anyOf:
          - type: string
            enum:
            - file_stopped_partway
            - file_sections_not_learned
          - type: 'null'
          title: Error Code
          description: 'Set when a file upload ended before every turn was learned: `file_stopped_partway`
            (it stopped; what was learned is kept) or `file_sections_not_learned` (some sections could
            not be learned after a restart). To learn the rest, resume the file: POST /v2/agents/{agent_id}/files/{file_id}/resume.
            null otherwise.

            '
        kind:
          type: string
          enum:
          - messages
          - file
          title: Kind
          description: Whether the call sent messages or uploaded a file.
        file_id:
          anyOf:
          - type: string
          - type: 'null'
          title: File Id
          description: The file a `file` call uploaded. null for messages, for a file the caller may not
            see, and for some older uploads.
        created_at:
          type: string
          format: date-time
          title: Created At
          description: When the call was accepted.
      type: object
      required:
      - observation_id
      - status
      - turns_total
      - turns_processed
      - error
      - error_code
      - kind
      - file_id
      - created_at
      title: Observation
      description: One `observe` call on a thread, and how far its learning has got.
    ObservationStatus:
      properties:
        observation_id:
          type: string
          pattern: ^obs_[0-9A-HJKMNP-TV-Z]{26}$
          title: Observation Id
          description: Server-generated observation identifier.
        status:
          type: string
          enum:
          - queued
          - converting
          - processing
          - interrupted
          - committed
          - failed
          - cancelled
          title: Status
          description: 'queued: waiting behind another file this agent is reading. converting: the file
            is being read. processing: turns are being learned. interrupted: paused by a restart; it resumes
            where it stopped and is not charged again. Poll these after Retry-After. committed, failed
            and cancelled are final.'
        turns_total:
          type: integer
          minimum: 0
          title: Turns Total
          description: Turns to learn. For a file, the turns it was split into; 0 until it has been read.
        turns_processed:
          type: integer
          minimum: 0
          title: Turns Processed
          description: Turns sent for learning so far. Only `committed` means done, even when this equals
            `turns_total`.
        error:
          anyOf:
          - type: string
          - type: 'null'
          title: Error
          description: What went wrong, when status is failed.
        error_code:
          anyOf:
          - type: string
            enum:
            - file_stopped_partway
            - file_sections_not_learned
          - type: 'null'
          title: Error Code
          description: 'Set when a file upload ended before every turn was learned: `file_stopped_partway`
            (it stopped; what was learned is kept) or `file_sections_not_learned` (some sections could
            not be learned after a restart). To learn the rest, resume the file: POST /v2/agents/{agent_id}/files/{file_id}/resume.
            null otherwise.

            '
        learning:
          anyOf:
          - $ref: '#/components/schemas/NotLearned'
          - type: 'null'
          description: 'Set once a failed or cancelled job settles: which turns were not learned, and
            the refund. null while the job runs, after it commits, and while it is interrupted (it resumes
            by itself).

            '
      type: object
      required:
      - observation_id
      - status
      - turns_total
      - turns_processed
      - error
      - error_code
      - learning
      title: ObservationStatus
      description: How far one `observe` call's learning has got.
    ObserveAccepted:
      properties:
        observation_id:
          anyOf:
          - type: string
          - type: 'null'
          title: Observation Id
          description: 'A message call''s background learning: poll GET .../observe/{observation_id} for
            its progress. Null for a file call, whose `files` name one each.'
        files:
          anyOf:
          - items:
              $ref: '#/components/schemas/ObservedFile'
            type: array
          - type: 'null'
          title: Files
          description: A file call's files, every one in the order sent, each with its own observation.
            The agent reads them in the background one at a time, after any file it is already reading.
            Null for a message call.
      type: object
      required:
      - observation_id
      - files
      title: ObserveAccepted
      description: What an `observe` call accepted. Learning runs in the background.
    ObserveAndRespondV2Request:
      properties:
        speaker_id:
          anyOf:
          - type: string
            maxLength: 200
            minLength: 1
          - type: 'null'
          title: Speaker Id
          description: Your own id for the speaker. Kept on the turn and returned with it.
        timestamp:
          anyOf:
          - type: string
            format: date-time
          - type: 'null'
          title: Timestamp
          description: When the message was said, used to date its memories. Defaults to when the server
            receives it.
        metadata:
          anyOf:
          - $ref: '#/components/schemas/TurnMetadata'
          - type: 'null'
          description: Where the message came from, kept on the turn and returned with it.
        content:
          type: string
          maxLength: 2000000
          minLength: 1
          title: Content
          description: The message for the agent to answer.
        files:
          anyOf:
          - items:
              $ref: '#/components/schemas/ImageFile'
            type: array
            maxItems: 10
            minItems: 1
          - type: 'null'
          title: Files
          description: Images for the agent to look at while it answers.
        speaker:
          anyOf:
          - type: string
            maxLength: 200
            minLength: 1
          - type: 'null'
          title: Speaker
          description: Who said the message, such as a person's name. Required with an API key.
        detail:
          type: string
          enum:
          - brief
          - standard
          - detailed
          title: Detail
          description: 'How long the answer should be: brief (a few sentences), standard, or detailed
            (every relevant fact, date, number and quote). It guides the agent; the answer is never truncated.'
          default: standard
        stream:
          type: boolean
          title: Stream
          description: True to receive the answer as server-sent events (see the 200 response).
          default: false
        include_memories:
          type: boolean
          title: Include Memories
          description: True to return the memories the answer used, in `memories`.
          default: false
        learn_reply:
          type: boolean
          title: Learn Reply
          description: False to learn the message but not the agent's answer.
          default: true
      additionalProperties: false
      type: object
      required:
      - content
      title: ObserveAndRespondV2Request
      description: A `respond` request that also learns the message, and the answer unless `learn_reply`
        is false.
    ObservedFile:
      properties:
        file_id:
          anyOf:
          - type: string
          - type: 'null'
          title: File Id
          description: The id the file is kept under; null when it was refused.
        observation_id:
          anyOf:
          - type: string
          - type: 'null'
          title: Observation Id
          description: This file's background learning; poll GET .../observe/{observation_id}. Null when
            refused.
        duplicate:
          anyOf:
          - type: boolean
          - type: 'null'
          title: Duplicate
          description: 'True when this agent already had these exact bytes, or the call sent them earlier
            in `files`: nothing was read or billed, and the ids are the earlier upload''s. Null when refused.'
        error:
          anyOf:
          - $ref: '#/components/schemas/FileRefusal'
          - type: 'null'
          description: Why this file was not accepted, null when it was; a retry under the same Idempotency-Key
            replays this answer, so resend a refused file in a new call under a new key.
      type: object
      required:
      - file_id
      - observation_id
      - duplicate
      - error
      title: ObservedFile
      description: One file of an `observe` call, in the place it was sent.
    Page_ActivityEntry_:
      properties:
        items:
          items:
            $ref: '#/components/schemas/ActivityEntry'
          type: array
          title: Items
          description: The rows on this page, in the listing's order.
        next_cursor:
          anyOf:
          - type: string
          - type: 'null'
          title: Next Cursor
          description: Pass as `cursor` to read the next page. null on the last page.
      type: object
      required:
      - items
      - next_cursor
      title: Page[ActivityEntry]
      description: One page of a listing, and where the next page starts.
    Page_AgentSummary_:
      properties:
        items:
          items:
            $ref: '#/components/schemas/AgentSummary'
          type: array
          title: Items
          description: The rows on this page, in the listing's order.
        next_cursor:
          anyOf:
          - type: string
          - type: 'null'
          title: Next Cursor
          description: Pass as `cursor` to read the next page. null on the last page.
      type: object
      required:
      - items
      - next_cursor
      title: Page[AgentSummary]
      description: One page of a listing, and where the next page starts.
    Page_File_:
      properties:
        items:
          items:
            $ref: '#/components/schemas/File'
          type: array
          title: Items
          description: The rows on this page, in the listing's order.
        next_cursor:
          anyOf:
          - type: string
          - type: 'null'
          title: Next Cursor
          description: Pass as `cursor` to read the next page. null on the last page.
      type: object
      required:
      - items
      - next_cursor
      title: Page[File]
      description: One page of a listing, and where the next page starts.
    Page_Observation_:
      properties:
        items:
          items:
            $ref: '#/components/schemas/Observation'
          type: array
          title: Items
          description: The rows on this page, in the listing's order.
        next_cursor:
          anyOf:
          - type: string
          - type: 'null'
          title: Next Cursor
          description: Pass as `cursor` to read the next page. null on the last page.
      type: object
      required:
      - items
      - next_cursor
      title: Page[Observation]
      description: One page of a listing, and where the next page starts.
    Page_Thread_:
      properties:
        items:
          items:
            $ref: '#/components/schemas/Thread'
          type: array
          title: Items
          description: The rows on this page, in the listing's order.
        next_cursor:
          anyOf:
          - type: string
          - type: 'null'
          title: Next Cursor
          description: Pass as `cursor` to read the next page. null on the last page.
      type: object
      required:
      - items
      - next_cursor
      title: Page[Thread]
      description: One page of a listing, and where the next page starts.
    Page_Turn_:
      properties:
        items:
          items:
            $ref: '#/components/schemas/Turn'
          type: array
          title: Items
          description: The rows on this page, in the listing's order.
        next_cursor:
          anyOf:
          - type: string
          - type: 'null'
          title: Next Cursor
          description: Pass as `cursor` to read the next page. null on the last page.
      type: object
      required:
      - items
      - next_cursor
      title: Page[Turn]
      description: One page of a listing, and where the next page starts.
    PrincipalRef:
      properties:
        type:
          type: string
          enum:
          - user
          - service_account
          - system
          title: Type
          description: '`user` for a person, `service_account`, or `system`.'
        id:
          type: string
          title: Id
          description: 'Their id: a user id, a service account id, or `system`.'
        display_name:
          anyOf:
          - type: string
          - type: 'null'
          title: Display Name
          description: Their name; null when it is not known.
      type: object
      required:
      - type
      - id
      - display_name
      title: PrincipalRef
      description: 'Who something is: a person, a service account, or the system for what nobody asked
        for.'
    ProjectUsageFilters:
      properties:
        from:
          type: string
          format: date
          title: From
          description: The first day of the range.
        to:
          type: string
          format: date
          title: To
          description: The last day of the range.
        tz:
          type: string
          title: Tz
          description: The time zone the days are bucketed in.
        agent_id:
          anyOf:
          - type: string
          - type: 'null'
          title: Agent Id
          description: The agent filter that was applied; null for none.
        route:
          anyOf:
          - type: string
            enum:
            - observe
            - observe-and-recall
            - recall
            - observe-and-respond
            - respond
          - type: 'null'
          title: Route
          description: The operation filter that was applied; null for none.
        api_key_id:
          anyOf:
          - type: string
          - type: 'null'
          title: Api Key Id
          description: The API key filter that was applied; null for none.
      type: object
      required:
      - from
      - to
      - tz
      - agent_id
      - route
      - api_key_id
      title: ProjectUsageFilters
      description: The filters a project usage read applied.
    ProjectUsageReport:
      properties:
        enabled:
          type: boolean
          title: Enabled
          description: False when this deployment records no credits; every value is then zero.
        filters:
          $ref: '#/components/schemas/ProjectUsageFilters'
          description: The filters the report applied.
        totals:
          $ref: '#/components/schemas/UsageSums'
        daily:
          items:
            $ref: '#/components/schemas/UsageDay'
          type: array
          title: Daily
          description: One bucket per day of the range, zero-filled.
        by_agent:
          items:
            $ref: '#/components/schemas/UsageByAgent'
          type: array
          title: By Agent
          description: Highest credits first. A null `agent_id` groups charges with no recorded agent
            or, when `agent_restricted` is true, every agent the caller cannot reach.
        project_id:
          type: string
          title: Project Id
          description: The project the report covers.
        by_api_key:
          items:
            $ref: '#/components/schemas/UsageByApiKey'
          type: array
          title: By Api Key
          description: Highest credits first.
        by_operation:
          items:
            $ref: '#/components/schemas/UsageByOperation'
          type: array
          title: By Operation
          description: Highest credits first.
      type: object
      required:
      - enabled
      - filters
      - totals
      - daily
      - by_agent
      - project_id
      - by_api_key
      - by_operation
      title: ProjectUsageReport
      description: 'A project''s usage over a range: totals, by day, by agent, by API key and by operation.'
    RecallRequest:
      properties:
        speaker_id:
          anyOf:
          - type: string
            maxLength: 200
            minLength: 1
          - type: 'null'
          title: Speaker Id
          description: Your own id for the speaker. Kept on the turn and returned with it.
        timestamp:
          anyOf:
          - type: string
            format: date-time
          - type: 'null'
          title: Timestamp
          description: When the message was said, used to date its memories. Defaults to when the server
            receives it.
        metadata:
          anyOf:
          - $ref: '#/components/schemas/TurnMetadata'
          - type: 'null'
          description: Where the message came from, kept on the turn and returned with it.
        content:
          type: string
          maxLength: 2000000
          minLength: 1
          title: Content
          description: The message to find memories for.
        speaker:
          anyOf:
          - type: string
            maxLength: 200
            minLength: 1
          - type: 'null'
          title: Speaker
          description: Who said the message, such as a person's name. Required with an API key.
        limit:
          type: integer
          maximum: 100
          minimum: 1
          title: Limit
          description: The most memories to return.
          default: 20
      additionalProperties: false
      type: object
      required:
      - content
      title: RecallRequest
      description: One message to find memories for. Only `observe-and-recall` learns it.
    RecallResponse:
      properties:
        memories:
          items:
            $ref: '#/components/schemas/RecalledMemory'
          type: array
          title: Memories
          description: The memories the agent used for this message, in the order its search found them.
        observation_id:
          anyOf:
          - type: string
            pattern: ^obs_[0-9A-HJKMNP-TV-Z]{26}$
            description: Server-generated observation identifier.
          - type: 'null'
          title: Observation Id
          description: 'Follow the learning of this call''s message (and of the reply, when it is learned)
            with GET /v2/agents/{agent_id}/threads/{thread_id}/observe/{observation_id}. It reports processing,
            then committed, or failed with the reason. null when nothing from this call is learned.

            '
      type: object
      required:
      - memories
      - observation_id
      title: RecallResponse
      description: The memories one message needs.
    RecalledMemory:
      properties:
        turn_id:
          anyOf:
          - type: string
          - type: 'null'
          title: Turn Id
          description: The turn's id, as the agent's memory list shows it; the agent's owner forgets it
            with `DELETE /v2/agents/{agent_id}/memories/{turn_id}`. Null when the turn is not on record.
        speaker:
          anyOf:
          - type: string
          - type: 'null'
          title: Speaker
          description: Who said the turn.
        speaker_id:
          anyOf:
          - type: string
          - type: 'null'
          title: Speaker Id
          description: The `speaker_id` sent with the turn; null when none was sent.
        text:
          type: string
          title: Text
          description: What was said, word for word; the memory's own text when the turn is not on record.
        timestamp:
          anyOf:
          - type: string
          - type: 'null'
          title: Timestamp
          description: 'When the turn was said: the `timestamp` sent with it, or else when the server
            received it.'
        metadata:
          anyOf:
          - additionalProperties: true
            type: object
          - type: 'null'
          title: Metadata
          description: The `metadata` sent with the turn; null when none was sent.
      type: object
      required:
      - turn_id
      - speaker
      - speaker_id
      - text
      - timestamp
      - metadata
      title: RecalledMemory
      description: One memory, shown as the turn it was made from. Each turn appears once.
    RespondRequest:
      properties:
        speaker_id:
          anyOf:
          - type: string
            maxLength: 200
            minLength: 1
          - type: 'null'
          title: Speaker Id
          description: Your own id for the speaker. Kept on the turn and returned with it.
        timestamp:
          anyOf:
          - type: string
            format: date-time
          - type: 'null'
          title: Timestamp
          description: When the message was said, used to date its memories. Defaults to when the server
            receives it.
        metadata:
          anyOf:
          - $ref: '#/components/schemas/TurnMetadata'
          - type: 'null'
          description: Where the message came from, kept on the turn and returned with it.
        content:
          type: string
          maxLength: 2000000
          minLength: 1
          title: Content
          description: The message for the agent to answer.
        files:
          anyOf:
          - items:
              $ref: '#/components/schemas/ImageFile'
            type: array
            maxItems: 10
            minItems: 1
          - type: 'null'
          title: Files
          description: Images for the agent to look at while it answers.
        speaker:
          anyOf:
          - type: string
            maxLength: 200
            minLength: 1
          - type: 'null'
          title: Speaker
          description: Who said the message, such as a person's name. Required with an API key.
        detail:
          type: string
          enum:
          - brief
          - standard
          - detailed
          title: Detail
          description: 'How long the answer should be: brief (a few sentences), standard, or detailed
            (every relevant fact, date, number and quote). It guides the agent; the answer is never truncated.'
          default: standard
        stream:
          type: boolean
          title: Stream
          description: True to receive the answer as server-sent events (see the 200 response).
          default: false
        include_memories:
          type: boolean
          title: Include Memories
          description: True to return the memories the answer used, in `memories`.
          default: false
      additionalProperties: false
      type: object
      required:
      - content
      title: RespondRequest
      description: One message for the agent to answer, with up to 10 images.
    RespondResponse:
      properties:
        answer:
          type: string
          title: Answer
          description: The agent's answer.
        citations:
          items:
            $ref: '#/components/schemas/Citation'
          type: array
          title: Citations
          description: The files the answer drew on.
        observation_id:
          anyOf:
          - type: string
            pattern: ^obs_[0-9A-HJKMNP-TV-Z]{26}$
            description: Server-generated observation identifier.
          - type: 'null'
          title: Observation Id
          description: 'Follow the learning of this call''s message (and of the reply, when it is learned)
            with GET /v2/agents/{agent_id}/threads/{thread_id}/observe/{observation_id}. It reports processing,
            then committed, or failed with the reason. null when nothing from this call is learned.

            '
        memories:
          items:
            $ref: '#/components/schemas/RecalledMemory'
          type: array
          title: Memories
          description: The memories the answer used, as `recall` returns them. Sent only when the request
            set `include_memories`.
      type: object
      required:
      - answer
      - citations
      - observation_id
      title: RespondResponse
      description: The agent's answer to one message.
    ResumeRequest:
      properties:
        only:
          anyOf:
          - type: string
            const: pictures
          - type: 'null'
          title: Only
          description: '`pictures` to read a finished document''s unread pictures again instead of finishing
            its text.'
        thread_id:
          anyOf:
          - type: string
            pattern: ^thread_[0-9A-HJKMNP-TV-Z]{26}$
            description: Server-generated thread identifier.
          - type: 'null'
          title: Thread Id
          description: The thread to read the file in. Omit to resume in the upload thread. Another thread
            reads the whole file again, charged in full.
      additionalProperties: false
      type: object
      title: ResumeRequest
      description: What to resume, and in which thread.
    Thread:
      properties:
        agent_id:
          type: string
          pattern: ^agent_[0-9A-HJKMNP-TV-Z]{26}$
          title: Agent Id
          description: Server-generated agent identifier.
        thread_id:
          type: string
          pattern: ^thread_[0-9A-HJKMNP-TV-Z]{26}$
          title: Thread Id
          description: Server-generated thread identifier.
        status:
          type: string
          enum:
          - ready
          - deleted
          title: Status
          description: ready for a live thread; deleted once it is removed.
        title:
          anyOf:
          - type: string
          - type: 'null'
          title: Title
          description: The thread's title; null when it has none.
        metadata:
          additionalProperties: true
          type: object
          maxProperties: 50
          title: Metadata
          description: 'Opaque caller-defined metadata, at most 50 keys.

            '
        created_at:
          type: string
          format: date-time
          title: Created At
          description: When this was created.
        updated_at:
          type: string
          format: date-time
          title: Updated At
          description: When this was last changed.
      type: object
      required:
      - agent_id
      - thread_id
      - status
      - title
      - metadata
      - created_at
      - updated_at
      title: Thread
      description: A conversation thread of an agent.
    ThreadTurn:
      properties:
        turn_id:
          type: string
          title: Turn Id
          description: The turn's id.
        speaker:
          anyOf:
          - type: string
          - type: 'null'
          title: Speaker
          description: Who said the turn.
        speaker_id:
          anyOf:
          - type: string
          - type: 'null'
          title: Speaker Id
          description: The `speaker_id` sent with the turn; null when none was sent.
        text:
          type: string
          title: Text
          description: What was said.
        timestamp:
          anyOf:
          - type: string
          - type: 'null'
          title: Timestamp
          description: 'When the turn was said: the `timestamp` sent with it, or else when the server
            received it.'
        file_ids:
          items:
            type: string
          type: array
          title: File Ids
          description: The ids of the files the turn came from or refers to.
        metadata:
          anyOf:
          - additionalProperties: true
            type: object
          - type: 'null'
          title: Metadata
          description: The `metadata` sent with the turn; null when none was sent.
        via:
          anyOf:
          - type: string
            enum:
            - observe
            - observe_and_respond
            - observe_and_recall
            - respond
            - recall
          - type: 'null'
          title: Via
          description: 'The call that saved the turn. A respond or recall turn is never learned: it is
            kept so the thread''s history shows every call, and the answer to a later message reads it.
            A learned reply is observe. Null for a turn saved before calls were told apart.'
        unlearned:
          type: boolean
          title: Unlearned
          description: 'True for a turn kept as conversation only and never learned: every respond and
            recall turn, and any turn of an agent that learns nothing.'
          default: false
        memories_recalled:
          anyOf:
          - type: integer
          - type: 'null'
          title: Memories Recalled
          description: How many memories a recall or observe_and_recall turn returned; null for any other
            turn.
      type: object
      required:
      - turn_id
      - speaker
      - speaker_id
      - text
      - timestamp
      - file_ids
      - metadata
      - via
      - unlearned
      - memories_recalled
      title: ThreadTurn
      description: One turn of a thread's history, as it was said, and the call that saved it.
    ThreadWithMessages:
      properties:
        agent_id:
          type: string
          pattern: ^agent_[0-9A-HJKMNP-TV-Z]{26}$
          title: Agent Id
          description: Server-generated agent identifier.
        thread_id:
          type: string
          pattern: ^thread_[0-9A-HJKMNP-TV-Z]{26}$
          title: Thread Id
          description: Server-generated thread identifier.
        status:
          type: string
          enum:
          - ready
          - deleted
          title: Status
          description: ready for a live thread; deleted once it is removed.
        title:
          anyOf:
          - type: string
          - type: 'null'
          title: Title
          description: The thread's title; null when it has none.
        metadata:
          additionalProperties: true
          type: object
          maxProperties: 50
          title: Metadata
          description: 'Opaque caller-defined metadata, at most 50 keys.

            '
        created_at:
          type: string
          format: date-time
          title: Created At
          description: When this was created.
        updated_at:
          type: string
          format: date-time
          title: Updated At
          description: When this was last changed.
        messages:
          items:
            $ref: '#/components/schemas/ThreadTurn'
          type: array
          title: Messages
          description: The thread's latest turns, up to 200. The agent's owner reads older ones with GET
            /agents/{agent_id}/memories?thread_id=.
      type: object
      required:
      - agent_id
      - thread_id
      - status
      - title
      - metadata
      - created_at
      - updated_at
      - messages
      title: ThreadWithMessages
      description: A conversation thread of an agent.
    Turn:
      properties:
        turn_id:
          type: string
          title: Turn Id
          description: The turn's id.
        speaker:
          anyOf:
          - type: string
          - type: 'null'
          title: Speaker
          description: Who said the turn.
        speaker_id:
          anyOf:
          - type: string
          - type: 'null'
          title: Speaker Id
          description: The `speaker_id` sent with the turn; null when none was sent.
        text:
          type: string
          title: Text
          description: What was said.
        timestamp:
          anyOf:
          - type: string
          - type: 'null'
          title: Timestamp
          description: 'When the turn was said: the `timestamp` sent with it, or else when the server
            received it.'
        file_ids:
          items:
            type: string
          type: array
          title: File Ids
          description: The ids of the files the turn came from or refers to.
        metadata:
          anyOf:
          - additionalProperties: true
            type: object
          - type: 'null'
          title: Metadata
          description: The `metadata` sent with the turn; null when none was sent.
        thread_id:
          type: string
          title: Thread Id
          description: The thread the turn was said in.
        state:
          type: string
          enum:
          - learned
          - learning
          - not_learned
          - forgotten
          title: State
          description: 'learned: memories were made from it. learning: still being learned. not_learned:
            no memory could be made from it; send it again. forgotten: its memories were deleted.'
        file_piece:
          type: boolean
          title: File Piece
          description: True when the turn is a piece of an uploaded file; it is deleted with the file.
      type: object
      required:
      - turn_id
      - speaker
      - speaker_id
      - text
      - timestamp
      - file_ids
      - metadata
      - thread_id
      - state
      - file_piece
      title: Turn
      description: One turn of the agent's conversations, as it was said.
    TurnMetadata:
      properties:
        path:
          anyOf:
          - type: string
            maxLength: 1024
            minLength: 1
          - type: 'null'
          title: Path
          description: The path of the file or page the turn came from.
        section:
          anyOf:
          - type: string
            maxLength: 500
            minLength: 1
          - type: 'null'
          title: Section
          description: The section of that source the turn came from.
        page:
          anyOf:
          - type: integer
            maximum: 1000000
            minimum: 1
          - type: 'null'
          title: Page
          description: The page the turn came from, counting from 1.
        parent_id:
          anyOf:
          - type: string
            maxLength: 200
            minLength: 1
          - type: 'null'
          title: Parent Id
          description: The id of the item the turn belongs to, in your own system.
      additionalProperties: true
      type: object
      title: TurnMetadata
      description: 'Where a turn came from: four named keys, and any keys of your own. At most 32 keys
        and 8 KiB as JSON.'
    TurnRange:
      properties:
        first:
          type: integer
          minimum: 1
          title: First
          description: The first turn of the range, counting from 1.
        last:
          type: integer
          minimum: 1
          title: Last
          description: The last turn of the range, counting from 1.
      type: object
      required:
      - first
      - last
      title: TurnRange
      description: A range of turns of an observation job, counting from 1, both ends included.
    UpdateAgentV2Request:
      properties:
        agent_config:
          $ref: '#/components/schemas/AgentConfig'
      additionalProperties: false
      type: object
      required:
      - agent_config
      title: UpdateAgentV2Request
      description: A new config for the agent, replacing the old one whole.
    UpdateThreadRequest:
      properties:
        title:
          anyOf:
          - type: string
            maxLength: 200
            minLength: 1
          - type: 'null'
          title: Title
          description: The new title.
        metadata:
          anyOf:
          - additionalProperties: true
            type: object
            maxProperties: 50
          - type: 'null'
          title: Metadata
          description: 'Opaque caller-defined metadata, at most 50 keys.

            '
      additionalProperties: false
      type: object
      title: UpdateThreadRequest
      description: Partial update. Omitted fields are unchanged.
    UsageByAgent:
      properties:
        requests:
          type: integer
          minimum: 0
          title: Requests
          description: How many requests were charged.
        message_requests:
          type: integer
          minimum: 0
          title: Message Requests
          description: Requests on routes that answer a message (every route but `observe`).
        credits:
          type: string
          pattern: ^-?\d+(\.\d+)?$
          title: Credits
          description: Credits charged, net of refunds.
        refunded_credits:
          type: string
          pattern: ^-?\d+(\.\d+)?$
          title: Refunded Credits
          description: Credits refunded against the charges counted here.
        ingested_tokens:
          type: integer
          minimum: 0
          title: Ingested Tokens
          description: Input tokens of `observe` calls (messages and files).
        input_tokens:
          type: integer
          minimum: 0
          title: Input Tokens
          description: Input tokens of message routes.
        output_tokens:
          type: integer
          minimum: 0
          title: Output Tokens
          description: Output tokens billed.
        total_tokens:
          type: integer
          minimum: 0
          title: Total Tokens
          description: ingested_tokens + input_tokens + output_tokens.
        message_tokens:
          type: integer
          minimum: 0
          title: Message Tokens
          description: input_tokens + output_tokens
        tokens_estimated:
          type: boolean
          title: Tokens Estimated
          description: True when some tokens are estimated from words.
        agent_id:
          anyOf:
          - type: string
          - type: 'null'
          title: Agent Id
          description: The agent; null for the grouped rows described on `by_agent`.
        agent_name:
          anyOf:
          - type: string
          - type: 'null'
          title: Agent Name
          description: The agent's name; null when `agent_id` is null.
        agent_restricted:
          type: boolean
          title: Agent Restricted
          description: True for the one row that sums the agents the caller cannot reach.
          default: false
      type: object
      required:
      - requests
      - message_requests
      - credits
      - refunded_credits
      - ingested_tokens
      - input_tokens
      - output_tokens
      - total_tokens
      - message_tokens
      - tokens_estimated
      - agent_id
      - agent_name
      - agent_restricted
      title: UsageByAgent
      description: Usage summed for one agent.
    UsageByApiKey:
      properties:
        api_key:
          anyOf:
          - $ref: '#/components/schemas/ApiKeyRef'
          - type: 'null'
          description: The key; null for charges made without one.
        credential:
          anyOf:
          - type: string
            enum:
            - session
            - personal_key
            - service_account_key
            - app_key
          - type: 'null'
          enum:
          - session
          - app_key
          - null
          title: Credential
          description: 'Null with a key. Without one: `session` for a person signed in (the console, voice
            and the website playground), `app_key` for an organization''s app key, and null for charges
            recorded before credentials were.'
        requests:
          type: integer
          minimum: 0
          title: Requests
          description: How many requests were charged.
        credits:
          type: string
          pattern: ^-?\d+(\.\d+)?$
          title: Credits
          description: Credits charged, net of refunds.
      type: object
      required:
      - api_key
      - credential
      - requests
      - credits
      title: UsageByApiKey
      description: Usage summed for one API key, or for the charges made without one.
    UsageByOperation:
      properties:
        operation:
          anyOf:
          - type: string
            enum:
            - observe
            - observe-and-recall
            - recall
            - observe-and-respond
            - respond
          - type: string
            const: other
          title: Operation
          description: The operation; `other` sums the charges no operation listed here claims.
        kind:
          anyOf:
          - type: string
            enum:
            - learning
            - recall
            - answering
          - type: 'null'
          title: Kind
          description: '`learning`, `recall` or `answering`: what the operation does. Null for `other`.'
        requests:
          type: integer
          minimum: 0
          title: Requests
          description: How many requests were charged.
        credits:
          type: string
          pattern: ^-?\d+(\.\d+)?$
          title: Credits
          description: Credits charged, net of refunds.
      type: object
      required:
      - operation
      - kind
      - requests
      - credits
      title: UsageByOperation
      description: Usage summed for one operation.
    UsageDay:
      properties:
        date:
          type: string
          format: date
          title: Date
          description: The day, in the report's time zone.
        requests:
          type: integer
          minimum: 0
          title: Requests
          description: How many requests were charged.
        credits:
          type: string
          pattern: ^-?\d+(\.\d+)?$
          title: Credits
          description: Credits charged on this day.
        ingested_tokens:
          type: integer
          minimum: 0
          title: Ingested Tokens
          description: Input tokens of `observe` calls (messages and files).
        input_tokens:
          type: integer
          minimum: 0
          title: Input Tokens
          description: Input tokens of message routes.
        output_tokens:
          type: integer
          minimum: 0
          title: Output Tokens
          description: Output tokens billed.
      type: object
      required:
      - date
      - requests
      - credits
      - ingested_tokens
      - input_tokens
      - output_tokens
      title: UsageDay
      description: Usage on one day.
    UsageSums:
      properties:
        requests:
          type: integer
          minimum: 0
          title: Requests
          description: How many requests were charged.
        message_requests:
          type: integer
          minimum: 0
          title: Message Requests
          description: Requests on routes that answer a message (every route but `observe`).
        credits:
          type: string
          pattern: ^-?\d+(\.\d+)?$
          title: Credits
          description: Credits charged, net of refunds.
        refunded_credits:
          type: string
          pattern: ^-?\d+(\.\d+)?$
          title: Refunded Credits
          description: Credits refunded against the charges counted here.
        ingested_tokens:
          type: integer
          minimum: 0
          title: Ingested Tokens
          description: Input tokens of `observe` calls (messages and files).
        input_tokens:
          type: integer
          minimum: 0
          title: Input Tokens
          description: Input tokens of message routes.
        output_tokens:
          type: integer
          minimum: 0
          title: Output Tokens
          description: Output tokens billed.
        total_tokens:
          type: integer
          minimum: 0
          title: Total Tokens
          description: ingested_tokens + input_tokens + output_tokens.
        message_tokens:
          type: integer
          minimum: 0
          title: Message Tokens
          description: input_tokens + output_tokens
        tokens_estimated:
          type: boolean
          title: Tokens Estimated
          description: True when some tokens are estimated from words.
      type: object
      required:
      - requests
      - message_requests
      - credits
      - refunded_credits
      - ingested_tokens
      - input_tokens
      - output_tokens
      - total_tokens
      - message_tokens
      - tokens_estimated
      title: UsageSums
      description: Usage totals.
    ChatStreamDelta:
      description: 'Data of a delta event: the next piece of the reply.'
      properties:
        delta:
          description: The next piece of the reply text, to append to the earlier pieces.
          title: Delta
          type: string
      required:
      - delta
      title: ChatStreamDelta
      type: object
  securitySchemes:
    projectKey:
      type: http
      scheme: bearer
      description: 'An API key, shaped `spk_<key_id>_<secret><checksum>`, sent as `Authorization: Bearer
        spk_...`. Each key belongs to one project and reaches only that project: an id from another project
        answers 404.


        - A service account''s key runs your product. It acts as the service account, with the role the
        service account holds in the project, and keeps working when people leave. It reaches the project''s
        public agents, never a private one. Only this key may send `X-SP-End-User`.

        - A personal key acts as the person who created it, with their role in the project. It is for
        building and testing: every response carries `X-SP-Warning: personal API key, not for production`,
        and `X-SP-End-User` is refused with 400.


        Keys are created and revoked on the API keys page of the Priors application. No API endpoint creates
        or revokes a service account''s key. A personal key lasts 30, 90, or 365 days (90 by default),
        and a person can hold 10 live personal keys in an organization. A service account''s key lasts
        90 or 365 days (365 by default), and a service account can hold 5 live keys. The secret is shown
        once, at creation, and cannot be recovered.


        A personal key made before projects (`spu_...`) keeps working until it expires, in its organization''s
        Default project.


        Keep keys on your server: a request with a `Sec-Fetch-Site` header is refused with 400, and Priors
        sends no CORS headers.

        '
  headers:
    Retry-After:
      description: Seconds to wait before retrying. Always at least 1.
      required: true
      schema:
        type: integer
        minimum: 1
    X-RateLimit-Limit:
      description: Requests admitted per period by the window closest to its limit.
      schema:
        type: integer
        minimum: 1
    X-RateLimit-Remaining:
      description: Requests left in that window. Zero when that window refused the request.
      schema:
        type: integer
        minimum: 0
    X-RateLimit-Reset:
      description: Unix timestamp (seconds) at which that window admits again.
      schema:
        type: integer
    Cache-Control:
      schema:
        type: string
        examples:
        - private, no-store
    X-Request-Id:
      description: 'Server-issued identifier for this request, the same value as an error body''s `request_id`.
        Include it when reporting a problem.

        '
      schema:
        type: string
    RetryAfterWhenKnown:
      description: 'Seconds to wait before retrying, when the wait is known (an agent being handed over
        during a restart). Absent for an outage with no known end.

        '
      schema:
        type: integer
        minimum: 1
  responses:
    TooManyRequests:
      description: 'A rate limit refused the request. The body''s `code` is `rate_limit_exceeded`, and
        `details` names the limit that refused. Wait the seconds in `Retry-After` before retrying; a sooner
        retry is refused again. The `X-RateLimit-*` headers describe the window closest to its limit,
        which may not be the one that refused.

        '
      headers:
        Retry-After:
          $ref: '#/components/headers/Retry-After'
        X-RateLimit-Limit:
          $ref: '#/components/headers/X-RateLimit-Limit'
        X-RateLimit-Remaining:
          $ref: '#/components/headers/X-RateLimit-Remaining'
        X-RateLimit-Reset:
          $ref: '#/components/headers/X-RateLimit-Reset'
        X-Request-Id:
          $ref: '#/components/headers/X-Request-Id'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    BadRequest:
      description: 'The request is invalid, and resending it unchanged will not help. The body''s `code`
        is `invalid_request`, and `error` says which of these it was:


        - A field is missing, out of range, or in a combination the route refuses.

        - `X-SP-End-User` is sent with a key other than a service account''s, is empty, or is longer than
        255 characters.

        - An API key is sent with a `Sec-Fetch-Site` header, which only a browser sets.

        - A service account''s key creates an agent with `visibility: private`.


        One exception: `images_not_accepted` means the message carried images and this deployment''s answer
        model does not take them. Send the message without its images. Only the routes that answer a message
        and the image upload return it.

        '
      headers:
        X-Request-Id:
          $ref: '#/components/headers/X-Request-Id'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Unauthorized:
      description: Missing or invalid credentials
      headers:
        X-Request-Id:
          $ref: '#/components/headers/X-Request-Id'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    OwnedAgentNotFound:
      description: 'Code `agent_not_found`: the caller owns no agent with this `agent_id`. Only the owner
        may do this, and an agent the caller can reach but does not own answers the same as a missing
        one.

        '
      headers:
        X-Request-Id:
          $ref: '#/components/headers/X-Request-Id'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    MemoryNotFound:
      description: 'Code `agent_not_found`: the caller owns no agent with this `agent_id`. Only the owner
        may do this, and an agent the caller can reach but does not own answers the same as a missing
        one. Code `not_found`: the agent has no turn with this `turn_id`.

        '
      headers:
        X-Request-Id:
          $ref: '#/components/headers/X-Request-Id'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    AgentNotReady:
      description: 'Code `agent_not_ready`: the agent exists, but its dependencies are still starting
        or have failed. Read the agent until its `status` is `ready`, then send the request again.

        '
      headers:
        X-Request-Id:
          $ref: '#/components/headers/X-Request-Id'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    AgentQuotaExceeded:
      description: 'Code `agent_quota_exceeded`: the organization already holds its maximum number of
        live agents, counting every owner. Waiting changes nothing: delete an agent, then create this
        one.

        '
      headers:
        X-Request-Id:
          $ref: '#/components/headers/X-Request-Id'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    ForgetMemoryConflict:
      description: 'The body''s `code` says which state refused the request.


        - `agent_not_ready`: the agent exists, but its dependencies are still starting or have failed.
        Read the agent until its `status` is `ready`, then send the request again.

        - `conflict`: the turn is a piece of an uploaded file, so delete the file instead; or more than
        one turn has this id; or the agent reads another agent''s memories and changes none of them.

        '
      headers:
        X-Request-Id:
          $ref: '#/components/headers/X-Request-Id'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    ServiceUnavailable:
      headers:
        Retry-After:
          $ref: '#/components/headers/RetryAfterWhenKnown'
        X-Request-Id:
          $ref: '#/components/headers/X-Request-Id'
      description: 'A dependency could not complete the request. Check the body''s `code` before retrying:


        - `service_unavailable`: a later attempt may succeed. While a restart hands an agent to a new
        instance, the response carries `Retry-After`, and an upload in progress resumes where it stopped,
        so keep polling.

        - `service_not_configured`: the deployment lacks configuration this route needs. Every attempt
        fails the same way until it is fixed.

        '
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    InternalServerError:
      description: 'The server failed unexpectedly. The body''s `code` is `internal_error`, and its message
        does not name the cause. Quote the body''s `request_id` (the same value as the `X-Request-Id`
        header) when reporting the problem. The same request sent again is not expected to succeed.

        '
      headers:
        X-Request-Id:
          $ref: '#/components/headers/X-Request-Id'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
tags:
- name: Agents
  description: Create, read, update, and delete memory agents.
- name: Threads
  description: 'Conversations under an agent: create them, teach them, and ask them.'
- name: Projects
  description: Your projects, and the calls made with their keys.
servers:
- url: https://app.sapientpriors.com/api
  description: Production
