> ## Documentation Index
> Fetch the complete documentation index at: https://docs.beta.adapter.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Ask Stream

> Ask a question and stream the answering

<Snippet file="api/knowledge/ask-stream.mdx" />


## OpenAPI

````yaml POST /v1/knowledge/ask/stream
openapi: 3.1.0
info:
  title: Adapter API
  description: Connect and sync data from any SaaS tool.
  version: 0.1.0
servers:
  - url: https://api.adapter.com
security:
  - ApiKeyAuth: []
tags:
  - name: connections
    description: Manage OAuth connections to data sources.
paths:
  /v1/knowledge/ask/stream:
    post:
      tags:
        - knowledge
      summary: Ask Stream
      description: Ask a question and stream the answering
      operationId: ask_stream
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PublicAskRequest'
        required: true
      responses:
        '200':
          description: >-
            Server-Sent Events stream. Each SSE message is one JSON
            `AskStreamEvent`; the stream closes after the final `answer` or
            `error` event. Experimental — ignore unknown event types.
          content:
            application/json:
              schema:
                oneOf:
                  - $ref: '#/components/schemas/AskStreamStatusEvent'
                  - $ref: '#/components/schemas/AskStreamIterationStartEvent'
                  - $ref: '#/components/schemas/AskStreamIterationEndEvent'
                  - $ref: '#/components/schemas/AskStreamThinkingEvent'
                  - $ref: '#/components/schemas/AskStreamToolStartEvent'
                  - $ref: '#/components/schemas/AskStreamToolEndEvent'
                  - $ref: '#/components/schemas/AskStreamAnswerEvent'
                  - $ref: '#/components/schemas/AskStreamErrorEvent'
                title: Response 200 Ask Stream
                discriminator:
                  propertyName: type
                  mapping:
                    status:
                      $ref: '#/components/schemas/AskStreamStatusEvent'
                    iteration_start:
                      $ref: '#/components/schemas/AskStreamIterationStartEvent'
                    iteration_end:
                      $ref: '#/components/schemas/AskStreamIterationEndEvent'
                    thinking:
                      $ref: '#/components/schemas/AskStreamThinkingEvent'
                    tool_start:
                      $ref: '#/components/schemas/AskStreamToolStartEvent'
                    tool_end:
                      $ref: '#/components/schemas/AskStreamToolEndEvent'
                    answer:
                      $ref: '#/components/schemas/AskStreamAnswerEvent'
                    error:
                      $ref: '#/components/schemas/AskStreamErrorEvent'
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AuthenticationErrorModel'
          description: Unauthorized
        '403':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PermissionDeniedErrorModel'
          description: Forbidden
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
        '429':
          description: >-
            Rate limit exceeded for the caller's tier. RFC 9457 problem+json
            body; IETF RateLimit-* headers and Retry-After are set.
          headers:
            Retry-After:
              description: Seconds to wait before retrying (RFC 9110).
              schema:
                type: integer
            RateLimit-Limit:
              description: Requests allowed per window.
              schema:
                type: integer
            RateLimit-Remaining:
              description: Requests remaining in the current window.
              schema:
                type: integer
            RateLimit-Reset:
              description: Delta-seconds until the window resets.
              schema:
                type: integer
            RateLimit-Policy:
              description: Active policy, e.g. '5;w=60'.
              schema:
                type: string
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/RateLimitProblemDetail'
            application/json:
              schema:
                $ref: '#/components/schemas/RateLimitProblemDetail'
        '500':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InternalServerErrorModel'
          description: Internal Server Error
        '503':
          description: Service Unavailable
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ServiceUnavailableErrorModel'
components:
  schemas:
    PublicAskRequest:
      properties:
        query:
          type: string
          maxLength: 2000
          minLength: 1
          title: Query
          examples:
            - What are our top blockers for Q1?
        timezone:
          anyOf:
            - type: string
            - type: 'null'
          title: Timezone
          description: >-
            IANA timezone identifier (e.g. "America/New_York") for resolving
            relative

            time references like "today" or "last week". Defaults to UTC.
          examples:
            - America/New_York
        metadata:
          anyOf:
            - additionalProperties:
                type: string
              type: object
              maxProperties: 20
            - type: 'null'
          title: Metadata
          description: >-
            Restrict the evidence the model can ground its answer in to rows
            whose `metadata` contains ALL the given key/value pairs
            (AND-of-exact-match). Max 20 keys; string values only.
          examples:
            - env: staging
      additionalProperties: false
      type: object
      required:
        - query
      title: PublicAskRequest
    AskStreamStatusEvent:
      properties:
        type:
          type: string
          const: status
          title: Type
        message:
          type: string
          title: Message
      type: object
      required:
        - type
        - message
      title: AskStreamStatusEvent
    AskStreamIterationStartEvent:
      properties:
        type:
          type: string
          const: iteration_start
          title: Type
        number:
          type: integer
          title: Number
      type: object
      required:
        - type
        - number
      title: AskStreamIterationStartEvent
    AskStreamIterationEndEvent:
      properties:
        type:
          type: string
          const: iteration_end
          title: Type
        number:
          type: integer
          title: Number
        llm_ms:
          type: integer
          title: Llm Ms
        input_tokens:
          type: integer
          title: Input Tokens
        output_tokens:
          type: integer
          title: Output Tokens
        tool_call_count:
          type: integer
          title: Tool Call Count
      type: object
      required:
        - type
        - number
        - llm_ms
        - input_tokens
        - output_tokens
        - tool_call_count
      title: AskStreamIterationEndEvent
    AskStreamThinkingEvent:
      properties:
        type:
          type: string
          const: thinking
          title: Type
        iteration:
          type: integer
          title: Iteration
        text:
          type: string
          title: Text
      type: object
      required:
        - type
        - iteration
        - text
      title: AskStreamThinkingEvent
    AskStreamToolStartEvent:
      properties:
        type:
          type: string
          const: tool_start
          title: Type
        id:
          type: string
          title: Id
        name:
          type: string
          title: Name
        arguments:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Arguments
        iteration:
          type: integer
          title: Iteration
      type: object
      required:
        - type
        - id
        - name
        - iteration
      title: AskStreamToolStartEvent
    AskStreamToolEndEvent:
      properties:
        type:
          type: string
          const: tool_end
          title: Type
        id:
          type: string
          title: Id
        name:
          type: string
          title: Name
        elapsed_ms:
          type: integer
          title: Elapsed Ms
        result_preview:
          type: string
          title: Result Preview
        result_chars:
          type: integer
          title: Result Chars
        truncated:
          type: boolean
          title: Truncated
      type: object
      required:
        - type
        - id
        - name
        - elapsed_ms
        - result_preview
        - result_chars
        - truncated
      title: AskStreamToolEndEvent
    AskStreamAnswerEvent:
      properties:
        type:
          type: string
          const: answer
          title: Type
        response:
          type: string
          title: Response
        citations:
          items:
            $ref: '#/components/schemas/Citation'
          type: array
          title: Citations
        truncated:
          type: boolean
          title: Truncated
        metadata:
          anyOf:
            - $ref: '#/components/schemas/PublicAskMetadata'
            - type: 'null'
      type: object
      required:
        - type
        - response
        - citations
        - truncated
      title: AskStreamAnswerEvent
    AskStreamErrorEvent:
      properties:
        type:
          type: string
          const: error
          title: Type
        message:
          type: string
          title: Message
      type: object
      required:
        - type
        - message
      title: AskStreamErrorEvent
    AuthenticationErrorModel:
      properties:
        error_code:
          type: string
          const: authentication_error
          title: Error Code
          default: authentication_error
        message:
          type: string
          title: Message
          default: Invalid or missing credentials.
        details:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Details
      type: object
      title: AuthenticationErrorModel
    PermissionDeniedErrorModel:
      properties:
        error_code:
          type: string
          const: permission_denied
          title: Error Code
          default: permission_denied
        message:
          type: string
          title: Message
          default: You do not have permission to perform this action.
        details:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Details
      type: object
      title: PermissionDeniedErrorModel
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    RateLimitProblemDetail:
      properties:
        type:
          type: string
          title: Type
          description: >-
            Stable problem-type URI, e.g.
            '{api_base_url}/errors/rate_limit_exceeded'.
        title:
          type: string
          const: Too Many Requests
          title: Title
          default: Too Many Requests
        status:
          type: integer
          const: 429
          title: Status
          default: 429
        detail:
          type: string
          title: Detail
          description: Human-readable explanation, including the retry hint.
        error_code:
          type: string
          const: rate_limit_exceeded
          title: Error Code
          default: rate_limit_exceeded
        endpoint:
          type: string
          title: Endpoint
          description: Logical endpoint the limit applies to (e.g. 'ask', 'search').
        tier:
          type: string
          title: Tier
          description: The caller's billing tier (e.g. 'free').
        limit:
          type: integer
          title: Limit
          description: Requests allowed per window for this tier + endpoint.
        remaining:
          type: integer
          title: Remaining
          description: Requests remaining in the current window (0 when blocked).
        window_seconds:
          type: integer
          title: Window Seconds
          description: Length of the fixed rate-limit window, in seconds.
        retry_after:
          type: integer
          title: Retry After
          description: Seconds to wait before retrying (mirrors the Retry-After header).
        instance:
          anyOf:
            - type: string
            - type: 'null'
          title: Instance
          description: The request path that was limited.
      type: object
      required:
        - type
        - detail
        - endpoint
        - tier
        - limit
        - remaining
        - window_seconds
        - retry_after
      title: RateLimitProblemDetail
      description: >-
        The 429 response body, exactly as ``RateLimitError.problem_detail``
        renders it —

        RFC 9457 Problem Details, served as ``application/problem+json``
        alongside the IETF

        ``RateLimit-*`` headers and ``Retry-After``. (Distinct from the legacy

        ``RateLimitErrorModel`` shape, which does not match what the handler
        emits.)
    InternalServerErrorModel:
      properties:
        error_code:
          type: string
          const: internal_server_error
          title: Error Code
          default: internal_server_error
        message:
          type: string
          title: Message
          default: An unexpected error occurred.
        details:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Details
      type: object
      title: InternalServerErrorModel
    ServiceUnavailableErrorModel:
      properties:
        error_code:
          type: string
          const: service_unavailable
          title: Error Code
          default: service_unavailable
        message:
          type: string
          title: Message
          default: >-
            The service is currently experiencing issues. Please try again
            later.
        details:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Details
      type: object
      title: ServiceUnavailableErrorModel
    Citation:
      properties:
        entity:
          additionalProperties: true
          type: object
          title: Entity
        type:
          type: string
          title: Type
      type: object
      required:
        - entity
        - type
      title: Citation
      description: |-
        A citation grounding the answer in a specific entity from your connected
        data. `type` is the entity type (e.g. "person", "calendar_event",
        "receipt") — citations in one response typically span multiple types.
        `entity` carries the full hydrated record so clients render it without a
        second lookup.
    PublicAskMetadata:
      properties:
        total_examined:
          type: integer
          title: Total Examined
          description: How many entities were seen during answering.
        examined:
          anyOf:
            - items:
                $ref: '#/components/schemas/ExaminedRecord'
              type: array
            - type: 'null'
          title: Examined
          description: >-
            Records the agent examined while answering, most relevant first:
            cited records, then individually read, then most engaged. Present
            only when the request set `include_examined`; capped at 200 entries
            (`total_examined` is the uncapped count). Experimental — shape may
            change.
      type: object
      required:
        - total_examined
      title: PublicAskMetadata
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
    ExaminedRecord:
      properties:
        access_count:
          type: integer
          minimum: 0
          title: Access Count
          description: >-
            Times a tool call surfaced this record. This is intentionally loose

            product-compatible accounting: cancellation can mean a surfaced
            record

            was not delivered to a model call.
        cited:
          type: boolean
          title: Cited
          description: The final answer cited this record (matched by id or urn).
        id:
          type: string
          title: Id
          description: >-
            Id as the agent saw it: a row `_id` from `execute_query`, or a
            search

            hit's `evidence_key`.
        urn:
          anyOf:
            - type: string
            - type: 'null'
          title: Urn
          description: URN, when the surfacing tool exposed one (search hits carry it).
      type: object
      required:
        - access_count
        - cited
        - id
      title: ExaminedRecord
      description: >-
        **Experimental.** One record the agent examined while answering.
        Recorded

        server-side at tool-execution time — never produced by the model.
  securitySchemes:
    ApiKeyAuth:
      type: http
      scheme: bearer
      description: Pass your `pk_live_...` API key as a Bearer token.

````