Skip to Content
kosemdocs
ReferenceAPIAgents

Stream agent events

Streams an agent as it works, as server-sent events: first the transcript's events after after, then each new event as it is added, its answer as it writes it, and the agent whenever it changes. Reconnect with the last sequence seen as after to miss nothing. The stream lasts until the caller ends it, or 15 minutes, when kosem ends it for the caller to reconnect; a heartbeat arrives after 15 seconds of silence. Skip events you do not know.

GET
/v1/projects/{project}/agents/{agent}/events/stream

Streams an agent as it works, as server-sent events: first the transcript's events after after, then each new event as it is added, its answer as it writes it, and the agent whenever it changes.

Reconnect with the last sequence seen as after to miss nothing. The stream lasts until the caller ends it, or 15 minutes, when kosem ends it for the caller to reconnect; a heartbeat arrives after 15 seconds of silence. Skip events you do not know.

Authorization

bearer
headerAuthorizationBearer <token>

An access token, or an API key.

Path Parameters

project*string

The project's ID.

Match^prj_[0-7][0-9a-hjkmnp-tv-z]{25}$
agent*string

The agent's ID.

Match^ags_[0-7][0-9a-hjkmnp-tv-z]{25}$

Query Parameters

after?integer

The sequence of the last event the caller has seen; the stream starts after it. 0, the default, streams the whole transcript.

Formatint64
Range0 <= value

Response Body

Server-sent events, each one of these; an error event ends a stream that failed after it started.

text/event-stream
  1. response
[index: integer]?|||||
Example Request
curl -X GET 'https://api.kosem.ai/v1/projects/string/agents/string/events/stream'
Example Response
[
  {
    "data": {
      "activityTime": "2019-08-24T14:15:22Z",
      "awaitingCalls": [
        "string"
      ],
      "config": {
        "environment": {
          "diskGib": 0,
          "env": {
            "property1": "string",
            "property2": "string"
          },
          "idleTimeoutSeconds": 0,
          "image": "string",
          "memoryMib": 0,
          "runnerPool": "string",
          "secrets": [
            {
              "credential": "string",
              "env": "string",
              "file": "string",
              "scope": {
                "property1": null,
                "property2": null
              },
              "secret": "string",
              "state": "ACTIVE",
              "stateReason": "string"
            }
          ],
          "stoppedTtlSeconds": 0,
          "vcpus": 0
        },
        "instructions": "string",
        "maxModelCalls": 0,
        "model": "string",
        "reasoningEffort": "",
        "tools": [
          "string"
        ]
      },
      "createTime": "2019-08-24T14:15:22Z",
      "creator": "string",
      "environment": {
        "diskGib": 0,
        "environment": "string",
        "memoryMib": 0,
        "state": "PROVISIONING",
        "stateReason": "string",
        "updateTime": "2019-08-24T14:15:22Z",
        "vcpus": 0
      },
      "jobs": [
        {
          "command": "string",
          "job": "string",
          "startTime": "2019-08-24T14:15:22Z"
        }
      ],
      "lastSequence": 0,
      "lastStop": {
        "message": "string",
        "reason": "END_TURN"
      },
      "name": "string",
      "state": "IDLE",
      "title": "string",
      "unread": true,
      "updateTime": "2019-08-24T14:15:22Z",
      "usage": {
        "webSearches": 0
      },
      "visibility": "PROJECT"
    },
    "event": "agent"
  }
]