# Streaming (SSE)

Instead of waiting for the full result, you can receive the run **live** as the Met thinks and answers. Meteor delivers it as a stream of **Server-Sent Events (SSE)**.

## With the SDK

```ts
for await (const ev of met.runs.stream({ input: 'What can I automate?' })) {
  switch (ev.type) {
    case 'run.output':
      process.stdout.write(ev.data);   // incremental text
      break;
    case 'run.completed':
      console.log('\ndone');
      break;
  }
}
```

The SDK parses the stream and hands you typed `{ type, data }` objects. Under the hood it is the same `POST /workspaces/:id/runs` with `stream: true` and `Accept: text/event-stream`.

## Event schema

The stream emits a **closed, versioned** set of events:

| Event | When |
|---|---|
| `run.started` | The run began |
| `run.step` | A step taken by the Met (curated projection of the trace) |
| `run.output` | A fragment of the answer |
| `run.completed` | Finished successfully |
| `run.failed` | Finished with an error |

`run.step` is a **curated** view: it exposes the step type, the iteration, the tool name and the actor — **never** internal prompts, raw tool inputs, provider costs or token counts.

## With curl

```bash
curl -N https://api.met.meteor.com.co/api/v1/workspaces/7/runs \
  -H "Authorization: Bearer $MET_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Accept: text/event-stream" \
  -d '{"input":"Hello","stream":true}'
```

The `-N` flag turns off buffering so you see the events arrive.

> Streaming does not retry automatically: a stream cut halfway through is not transparently resumable. For critical logic, pair the stream with a final `retrieve()` of the run.
