Skip to main content
Native HASP chat endpoint. Streams by default. Requires the ai:chat scope.

Request

Body parameters

Non-streaming response

When stream: false:

Streaming response (SSE)

When stream: true (default), the response is a standard text/event-stream. Each event follows this envelope:
Each event is a standard SSE frame: an event: line naming the type and a data: line carrying a flat JSON payload. There is no envelope object and no id: line — the payload fields listed below are at the top level of data.

Event sequence

A successful run emits:
  1. run.started — inference initiated
  2. message.delta (repeated) — content chunks as they arrive
  3. tool_call / provider_tool.completed (as they occur) — tool activity during the turn
  4. run.completed — run finished, with final usage and credits
heartbeat may be interleaved at any point to keep the connection alive. On failure, error is emitted instead of run.completed.

Event types

run.started

message.delta

tool_call

provider_tool.completed

heartbeat

Emitted when the stream has been idle, so intermediaries do not drop the connection. Carries no payload — ignore it.

run.completed

finish_reason is the normalized reason; stop_reason_raw is the provider-native value, which is finer-grained (finish_reason collapses end-of-turn and stop-sequence together).

Error events

There is no run.failed event. A failure mid-stream emits error and the stream ends:

Consuming the stream (JavaScript)

Switch on the event: line, not on a field inside data — the payload has no type field.

Cancellation

Close the SSE connection to cancel. The server detects the disconnect and halts the upstream call. No additional API call is needed, and no further events are emitted.

Models

The endpoint serves both Anthropic and OpenAI models. Premium (opt-in) models must be enabled by an org admin in Settings → AI Workspace → Models before requests using them are accepted. Requests for a model your org has not enabled return 403 MODEL_ACCESS_DENIED.

Error codes