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

# Stream events

> Watch an agent's reply arrive in real time.

Delivered over **Server-Sent Events** (`text/event-stream`) — browser-friendly (`EventSource`, `httpx-sse`, …). For scripts or agent loops, `GET /messages/{id}/chunk` (long-poll) is easier.

The stream emits four event types, then closes:

* `message.delta` — the next piece of the reply's text
* `message.tool_use` / `message.tool_result` — a tool started / finished (shown per the stream's `tool_visibility`, see below)
* `message.completed` / `message.failed` — the reply is done; the server then closes the stream

It's `text/event-stream`, **not JSON** — don't parse it as JSON, and `curl` will appear to "hang" (a healthy open connection). No `Last-Event-ID` resume yet; reconnect with a fresh subscription.

### Controlling what the stream shows

By default the stream reports tool **names** (`tool_visibility=names_only`) and
hides the agent's reasoning (`thinking_visibility=none`). Append query params to
change that for a subscription:

* `?tool_visibility=none|names_only|full` — hide tool activity, show tool names
  only, or show full tool inputs and results.
* `?thinking_visibility=none|summary|full` — hide the agent's reasoning,
  summarize it, or stream it in full.

File references the agent produces are emitted regardless of `tool_visibility`,
so you never miss a result by turning tools down.


## OpenAPI

````yaml api-reference/openapi.json GET /messages/{message_id}/stream
openapi: 3.1.0
info:
  title: Biomni Public API — V0
  description: >-
    The public API for **Biomni** — the AI agent platform for clinical genomics
    (variant annotation, ClinVar lookups, PMID-cited literature, and project
    file drives). Create projects and Tasks, send messages to the agent, stream
    its replies, manage files, and check your usage — all from your own code.


    **Authentication**: send `Authorization: Bearer <your-api-key>`. The adapter
    forwards your key straight to Biomni; it never stores it.


    **Safe retries**: send `Idempotency-Key: <token>` on POST endpoints
    (`/projects`, `/tasks`, `/messages`, `/files/uploads`) so a retried request
    won't create a duplicate.
  version: 0.1.0
servers:
  - url: https://api.phylo.bio/api/v1
security: []
paths:
  /messages/{message_id}/stream:
    get:
      tags:
        - stream
      summary: Stream events
      description: Watch an agent's reply arrive in real time.
      operationId: stream_message_messages__message_id__stream_get
      parameters:
        - name: message_id
          in: path
          required: true
          schema:
            type: string
            title: Message Id
      responses:
        '200':
          description: >-
            SSE stream open (text/event-stream). Server emits `message.delta`,
            `message.tool_use`, `message.tool_result`, then `message.completed`
            or `message.failed` and closes.
          content:
            text/event-stream:
              example: >
                event: message.delta

                data:
                {"message_id":"msg_1a0ef0fa8e26","delta":{"type":"text","text":"Looking
                up ClinVar…"}}


                event: message.completed

                data: {"message_id":"msg_1a0ef0fa8e26","status":"completed"}
      security:
        - bearerAuth: []
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: Requires an API key. See the Authentication guide.

````