PlatformGuard

Streaming

Tokens as they're generated, with the analysis up front.

stream() returns server-sent events: a metadata event with the user's state, safety decision and timing before the first token, then the tokens, then done. If a gate blocks, the stream says so and ends.

POST /api/sdk/process/stream

data: {"type":"metadata","data":{"user":{"mood":0.31},
       "safety":{"action":"PROCEED"},"timing":{"delay_ms":4200}}}

data: {"type":"token","data":{"content":"That"}}
data: {"type":"token","data":{"content":" sounds"}}
data: {"type":"token","data":{"content":" hard."}}

data: [DONE]
metadata firsttokensblocked ends the stream
Illustration of a streamed response
In code

Stream a reply

python
for event in client.stream("user_42", "Walk me through it"):
    if event["type"] == "metadata":          # arrives before any text
        print("mood:", event["data"]["user"]["mood"])
    elif event["type"] == "token":
        print(event["data"]["content"], end="", flush=True)
    elif event["type"] == "blocked":
        print("\n[blocked]", event["data"]["message"])
        break
Events

What comes down the stream

  • metadata: state, safety, timing and style before the first token
  • token: the next piece of the reply
  • blocked: a gate stopped the reply
  • error and done, so you can close cleanly

Streaming questions

Something else? Ask us.

Every AI should know who it's talking to.

The safety and human-oversight layer for emotional AI: user state across sessions, risk alerts, safety gates and human takeover, with every decision explained.