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.
Core Events:
intent: Intent classification result (emitted first)
{intent, confidence, category, reasoning, context_scope}thinking: Agent is analyzing/planning
{step, message}tool_call: Agent is calling a tool
{tool_name, tool_call_id, inputs}tool_result: Tool execution completed
{tool_name, tool_call_id, success, output, latency_ms}token: Response token (streaming)
{content}message: Final response content
{content, message_id, is_final}session_name: Auto-generated session name (first message only)
{session_name}done: Processing complete
{latency_ms, tool_calls_made, message_id, retriever_summary, data_accessed_via_retriever}error: Error occurred
{message, recoverable}Retriever Events (IMPORTANT - Primary Data Pathway):
retriever_execution: Retriever was used for data access
{tool_name, execution_id, retriever_id, is_adhoc, documents_returned, latency_ms, message}pipeline_config: Ad-hoc retriever configuration
{tool_name, config, message}Retriever Summary in done Event:
{
"retriever_summary": {
"used_retrievers": true,
"retriever_count": 2,
"saved_retrievers": 1,
"adhoc_retrievers": 1,
"total_documents": 25,
"executions": [...]
},
"data_accessed_via_retriever": true
}
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: intent
data: {"intent": "retriever_search", "confidence": 0.92, "category": "retriever"}
event: thinking
data: {"step": "processing", "message": "Analyzing your request..."}
event: tool_call
data: {"tool_name": "execute_retriever", "tool_call_id": "run_abc", "inputs": {...}}
event: tool_result
data: {"tool_name": "execute_retriever", "success": true, "output": {...}}
event: retriever_execution
data: {"tool_name": "execute_retriever", "is_adhoc": false, "documents_returned": 5}
event: message
data: {"content": "I found 5 videos about machine learning...", "is_final": true}
event: done
data: {"latency_ms": 1250.5, "data_accessed_via_retriever": true, "retriever_summary": {...}}
REQUIRED: Bearer token authentication using your API key. Format: 'Bearer sk_xxxxxxxxxxxxx'. You can create API keys in the Mixpeek dashboard under Organization Settings.
"Bearer YOUR_API_KEY"
"Bearer YOUR_STRIPE_API_KEY"
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'
"ns_abc123def456"
"production"
"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