Overview
The/api/chat endpoint provides a streaming conversational AI interface with access to memory storage, web search, and powerful Windows MCP tools for desktop automation. This endpoint supports multi-turn conversations with persistent memory and tool calling capabilities.
This endpoint returns Server-Sent Events (SSE) for streaming responses.
Endpoint
Authentication
Requires authentication via cookies or Authorization header. Alternatively, acceptsuserId in request body for internal calls.
Request Body
Array of conversation messages. Each message should follow the AI SDK UIMessage format with
role, content, and optional parts.Optional conversation ID for persisting chat history. If provided and the conversation doesn’t exist, a new one will be created with an auto-generated title.
Language model to use for the chat. Defaults to the system’s default model if not specified.
User identifier. Used as fallback if authentication via cookies/headers is not available. Required for internal API calls.
Response
Returns a Server-Sent Events (SSE) stream with JSON payloads containing:Event type. Can be
text, tool-call, tool-result, reasoning, etc.The actual content based on the event type (text chunk, tool call details, etc.)
Unique message or event ID.
Available Tools
The chat endpoint provides access to several powerful tools:Memory Tools
Web Search
Windows MCP Tools
Desktop automation tools for controlling Windows applications:- State-Tool: Capture current desktop state and interactive elements
- Click-Tool: Click at specific coordinates
- Type-Tool: Type text at coordinates
- Move-Tool: Move mouse cursor
- Drag-Tool: Drag and drop operations
- Scroll-Tool: Scroll at specific locations
- Shortcut-Tool: Execute keyboard shortcuts
- App-Tool: Launch, resize, or switch applications
- Powershell-Tool: Execute PowerShell commands
- Wait-Tool: Pause execution for UI loading
- Scrape-Tool: Fetch content from URLs or browser tabs
MCP tools are dynamically loaded and may vary based on your configuration.
Example Request
Example Response Stream
Error Responses
Returned when
messages parameter is missing or invalid.Returned when authentication fails.
Features
- Streaming Responses: Real-time text generation via SSE
- Tool Calling: Automatic tool invocation with step-by-step reasoning
- Memory System: Persistent user context across conversations
- Desktop Automation: Control Windows applications via MCP tools
- Conversation Persistence: Automatic saving of messages and chat history
- Auto-generated Titles: Conversations are titled based on first user message
- Stop Conditions: Automatically stops after 20 steps to prevent infinite loops