Chat with agent (streaming)
/agent/stream-chatSend a message to an agent and receive the response as a Server-Sent Events (SSE) stream. Events include message_start, content_delta, tool_use, tool_result, message_end, and error.
Header parameters
X-Phenoml-On-Behalf-OfstringoptionalOptional header for on-behalf-of authentication. Used when making requests on behalf of another user or entity. Must be in the format: Patient/{uuid} or Practitioner/{uuid}
X-Phenoml-Fhir-ProviderstringoptionalOptional header for FHIR provider authentication. Contains credentials in the format {fhir_provider_id}:{oauth2_token}. Multiple FHIR provider integrations can be provided as comma-separated values.
Body parameters
messagestringrequiredThe message to send to the agent
contextstringoptionalOptional context for the conversation
session_idstringoptionalOptional session ID for conversation continuity. Only one request may be active for a session at a time; overlapping turns for the same session return 409 Conflict.
agent_idstringrequiredThe ID of the agent to chat with
enhanced_reasoningbooleanoptionaldefault falseEnable enhanced reasoning capabilities. Increases latency but improves response quality and reliability.
Streaming chat response. Each frame is a standard SSE record
(event: line + data: JSON line). The example shows a single
content_delta payload — multiple frames stream until message_end.
Response fields
typestringoptionalThe event type
message_startcontent_deltatool_usetool_resultmessage_enderrorsession_idstringoptionalChat session ID
contentstringoptionalIncremental text content (present in content_delta events)
successbooleanoptionalWhether the operation was successful
messagestringoptionalStatus message
function_namestringoptionalTool/function name (present in tool_use and tool_result events)
function_argsobjectoptionalTool arguments (present in tool_use events)
function_resultobjectoptionalTool execution result (present in tool_result events)