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

# Stream a run

> Returns the run's stored state as server-sent events, then closes. Requires `runs_read`. Never calls the model, so it cannot charge.

The body is one snapshot: a `state` event (`{run_id, state}`), then, only when the run is `completed` or `failed`, a `terminal` event with `run_id`, `state`, `input_digest` and `output_digest` (possibly `null`). A completed run's `terminal` event adds `kind` and the whole `verdict` or `decision`. There are no partial-answer events, no `id:` or `retry:` fields, and `Last-Event-ID` is not read. The stream does not wait for a `pending` run: request it again, or poll `GET /v1/runs/{run_id}`. Errors before the stream starts are JSON. See [Streaming](/guides/streaming).



## OpenAPI

````yaml /api-reference/openapi.json get /v1/runs/{run_id}/stream
openapi: 3.1.0
info:
  title: OpenType API
  version: 0.1.0
  license:
    name: Apache-2.0
  description: >-
    The OpenType HTTP API: decision runs on Neon 1.1, API keys, usage, quota and
    billing. Every `/v1` route takes `Authorization: Bearer <credential>`, where
    the credential is an API key (`otsk_` followed by 64 hex characters) or a
    console session token. Amounts are integers in micro-USD (1,000,000 = 1 US
    dollar). Errors share one envelope, `{"error": {"code", "message",
    "request_id"}}`. Stripe is named only where it hosts checkout, the billing
    portal and receipts.
servers:
  - url: https://api.opentype.dev
    description: Production
  - url: https://api.opentype.dev
    description: Production
security:
  - bearer: []
  - bearer: []
tags:
  - name: runs
    description: Create, list, retrieve and stream runs.
  - name: keys
    description: Create, list, rotate and revoke API keys.
  - name: usage
    description: Usage rollups, the daily series, the ledger and quota.
  - name: billing
    description: Credit balance, checkout, the billing portal and auto-recharge.
  - name: health
    description: Public liveness and readiness checks.
  - name: router
    description: >-
      Model Router: classify a task with Neon 1.1 and pick a model from the
      benchmark catalog.
paths:
  /v1/runs/{run_id}/stream:
    get:
      tags:
        - runs
      summary: Stream a run
      description: >-
        Returns the run's stored state as server-sent events, then closes.
        Requires `runs_read`. Never calls the model, so it cannot charge.


        The body is one snapshot: a `state` event (`{run_id, state}`), then,
        only when the run is `completed` or `failed`, a `terminal` event with
        `run_id`, `state`, `input_digest` and `output_digest` (possibly `null`).
        A completed run's `terminal` event adds `kind` and the whole `verdict`
        or `decision`. There are no partial-answer events, no `id:` or `retry:`
        fields, and `Last-Event-ID` is not read. The stream does not wait for a
        `pending` run: request it again, or poll `GET /v1/runs/{run_id}`. Errors
        before the stream starts are JSON. See [Streaming](/guides/streaming).
      operationId: stream_run
      parameters:
        - name: run_id
          in: path
          description: >-
            `run_` followed by 32 hex characters, as the API returns it. The
            hyphenated form the usage routes return is also accepted.
          required: true
          schema:
            type: string
      responses:
        '200':
          description: >-
            `text/event-stream`, sent with `cache-control: no-cache, no-store`.
            Each frame is `event: <name>` and one `data:` line of JSON.
          content:
            text/event-stream: {}
        '400':
          description: '`invalid_run_id`: not `run_` followed by a UUID.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RunsErrorBody'
        '401':
          description: >-
            `missing_credentials` (no bearer credential) or `invalid_credential`
            (malformed, unknown or revoked).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RunsErrorBody'
        '403':
          description: >-
            `scope_denied`: the credential lacks `runs_read`. A session without
            an organization gets `no_active_organization`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RunsErrorBody'
        '404':
          description: '`run_not_found`: no run with this id in your organization.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RunsErrorBody'
        '429':
          description: >-
            Your organization is sending too many requests at once. Retry with
            backoff.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RunsErrorBody'
        '500':
          description: '`internal_error`: an unexpected failure. Report the `request_id`.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RunsErrorBody'
        '503':
          description: >-
            `database_unavailable` or `not_configured`. Also
            `auth_not_configured` or `trust_keys_unavailable` when credentials
            cannot be verified.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RunsErrorBody'
      security:
        - bearer: []
        - bearer: []
components:
  schemas:
    RunsErrorBody:
      type: object
      description: The error envelope, shared by every route. Branch on `error.code`.
      required:
        - error
      properties:
        error:
          $ref: '#/components/schemas/RunsErrorDetail'
    RunsErrorDetail:
      type: object
      required:
        - code
        - message
        - request_id
      properties:
        code:
          type: string
          description: Stable snake_case code. The only field to branch on.
        message:
          type: string
        request_id:
          type: string
        violations:
          type: array
          items:
            type: string
          description: >-
            Only on `verdict_schema_violation`: up to 10 JSON Pointers into the
            rejected document.
  securitySchemes:
    bearer:
      type: http
      scheme: bearer
      description: An API key (otsk_ + 64 hex) or a console session token.

````