Send a message to the agent and stream the response.
This endpoint streams Server-Sent Events (SSE) back to the client as the agent processes the message through its workflow.
SSE Event Types:
Args: request: FastAPI request with tenant context session_id: Session identifier payload: Message request
Returns: StreamingResponse with SSE events
Raises: NotFoundError: If session not found
Example:
curl -N -X POST http://localhost:8000/v1/agents/sessions/ses_abc123/messages \
-H "Authorization: Bearer {api_key}" \
-H "X-Namespace: {namespace_id}" \
-H "Content-Type: application/json" \
-d '{
"content": "Find videos about machine learning",
"stream": true
}'
# SSE Output:
event: thinking
data: {"step": "analyze_query", "message": "Analyzing your request..."}
event: tool_call
data: {"tool_name": "execute_retriever", "inputs": {...}}
event: tool_result
data: {"tool_name": "execute_retriever", "success": true, "output": {...}}
event: message
data: {"content": "I found 5 videos about machine learning..."}
event: done
data: {"latency_ms": 1250.5}
REQUIRED: Bearer token authentication using your API key. Format: 'Bearer sk_xxxxxxxxxxxxx'. You can create API keys in the Mixpeek dashboard under Organization Settings.
REQUIRED: Namespace identifier for scoping this request. All resources (collections, buckets, taxonomies, etc.) are scoped to a namespace. You can provide either the namespace name or namespace ID. Format: ns_xxxxxxxxxxxxx (ID) or a custom name like 'my-namespace'
Session ID
Request payload for sending a message to the agent.
Attributes: content: Message text content metadata: Optional message metadata stream: Whether to stream response as SSE (default: True)
Note: When stream=True, the response will be Server-Sent Events (SSE). When stream=False, the response will be a MessageResponse object.
Example: ```python # Streaming request (SSE) request = SendMessageRequest( content="Find videos about machine learning", stream=True )
# Non-streaming request
request = SendMessageRequest(
content="Find videos about machine learning",
stream=False
)
```Successful Response