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

# Stream Job

> Receive live job updates via Server-Sent Events

Establishes an SSE connection that emits job updates until completion. Useful for real-time dashboards or CLI workflows.

## Example

```bash theme={null}
curl -N -H "Authorization: Bearer $TOKENKIT_API_KEY" \
  https://api.tokenkit.co/v1/jobs/job_123/stream
```

## Event types

* `status`: initial state (`queued`, `processing`, etc.)
* `log`: operational messages
* `result`: final job output (mirrors the `output` field from the polling endpoint)
* `error`: error string when the job fails
* `end`: terminal state (`succeeded` or `failed`)
* `ping`: keep-alive heartbeat every 15 seconds

## Headers

TokenKit sets SSE-friendly headers to prevent caching:

```
Cache-Control: no-cache, no-transform
X-Accel-Buffering: no
Connection: keep-alive
```

Clients may resume streams by supplying `Last-Event-ID`. The server tracks log IDs to avoid replaying old entries.

## Errors

* Missing job ID or invalid credential -> `400`/`401`
* Unknown job for the current client -> `404`

When an error occurs, the stream emits an `error` event and closes with `end: failed`.


## OpenAPI

````yaml GET /v1/jobs/{job_id}/stream
openapi: 3.1.0
info:
  title: TokenKit
  description: >-
    Building image agents and tools, with APIs for businesses that want to put
    them to work.
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://api.tokenkit.co
security:
  - bearerAuth: []
paths:
  /v1/jobs/{job_id}/stream:
    get:
      description: Stream job updates via Server-Sent Events.
      parameters:
        - name: job_id
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: SSE stream
          content:
            text/event-stream:
              schema:
                type: string
        '400':
          description: Bad request or missing credentials
        '404':
          description: Job not found
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````