src/gaia/ui/Overview
The Agent UI SDK is the Python backend that powers the GAIA Agent UI. It provides:- FastAPI REST server with session, chat, document, and memory endpoints
- SQLite database for persistent sessions, messages, and document metadata
- SSE streaming for real-time chat responses
- RAG integration for document Q&A
- Memory dashboard with knowledge browser, tool stats, and observability (Memory SDK)
- Pydantic models for request/response validation
4200 by default and serves both the Electron desktop app and browser-based clients.
Quick Start
Start the Server
Use the Database Directly
Core Classes
ChatDatabase
The persistence layer for all Agent UI data. Uses SQLite with WAL mode for concurrent read access.Session Methods
Message Methods
Document Methods
Statistics
create_app()
Factory function that creates and configures the FastAPI application with all endpoints.app.state and is accessible in tests:
Pydantic Models
All request and response bodies use Pydantic models fromgaia.ui.models.
System
Sessions
Chat
Messages
Documents
REST API Endpoints
System
GET /api/system/status
GET /api/system/status
GET /api/health
GET /api/health
POST /api/system/load-model
POST /api/system/load-model
202 immediately; loading proceeds in the background. Poll GET /api/system/status to detect when loading completes.Request:POST /api/system/download-model
POST /api/system/download-model
202 immediately; the download proceeds in the background. Poll GET /api/system/status to detect when the model becomes available. Set force to true to re-download even if the file already exists (repairs corrupted or incomplete downloads).Request:GET /api/settings
GET /api/settings
PUT /api/settings
PUT /api/settings
custom_model to a model ID to override the default, or to an empty string / null to clear the override and revert to the default model.Request:GET /api/settings.Sessions
POST /api/sessions
POST /api/sessions
SessionResponseGET /api/sessions
GET /api/sessions
limit (default 50), offset (default 0)Response: SessionListResponseGET /api/sessions/{session_id}
GET /api/sessions/{session_id}
SessionResponsePUT /api/sessions/{session_id}
PUT /api/sessions/{session_id}
DELETE /api/sessions/{session_id}
DELETE /api/sessions/{session_id}
GET /api/sessions/{session_id}/messages
GET /api/sessions/{session_id}/messages
limit (default 100), offset (default 0)Response: MessageListResponseGET /api/sessions/{session_id}/export
GET /api/sessions/{session_id}/export
format (“markdown” or “json”, default “markdown”)Chat
POST /api/chat/send
POST /api/chat/send
stream: true, the server returns a text/event-stream response. Each line follows the SSE format data: <JSON>. The SSEOutputHandler (src/gaia/ui/sse_handler.py) bridges agent console events to the following typed events:Thinking and Progressresult_data variants in tool_result:- File list:
{"type": "file_list", "files": [...], "total": int}— up to 20 file entries - Search results:
{"type": "search_results", "count": int, "scores": float[], "previews": string[]}— top 5 chunk previews (200 chars each)
command_output shape in tool_result:Documents
GET /api/documents
GET /api/documents
POST /api/documents/upload-path
POST /api/documents/upload-path
DocumentResponseDELETE /api/documents/{doc_id}
DELETE /api/documents/{doc_id}
POST /api/sessions/{session_id}/documents
POST /api/sessions/{session_id}/documents
DELETE /api/sessions/{session_id}/documents/{doc_id}
DELETE /api/sessions/{session_id}/documents/{doc_id}
Files
POST /api/files/open
POST /api/files/open
open, and on Linux it uses xdg-open. Symbolic links are rejected for security.Request:POST /api/files/upload
POST /api/files/upload
POST /api/documents/upload instead if you want the
file indexed for Q&A.GET /api/files/browse
GET /api/files/browse
GET /api/files/search
GET /api/files/search
GET /api/files/preview
GET /api/files/preview
GET /api/files/image
GET /api/files/image
Agents
GET /api/agents
GET /api/agents
AgentRegistry — built-in agents plus any
custom agents discovered under ~/.gaia/agents/. See
plugin-registry for the registration format.GET /api/agents/{agent_id}
GET /api/agents/{agent_id}
source = builtin or custom_python).MCP
The MCP router manages external Model Context Protocol servers the agent can connect to.GET /api/mcp/servers
GET /api/mcp/servers
POST /api/mcp/servers
POST /api/mcp/servers
DELETE /api/mcp/servers/{name}
DELETE /api/mcp/servers/{name}
POST /api/mcp/servers/{name}/enable
POST /api/mcp/servers/{name}/enable
POST /api/mcp/servers/{name}/disable
POST /api/mcp/servers/{name}/disable
GET /api/mcp/servers/{name}/tools
GET /api/mcp/servers/{name}/tools
GET /api/mcp/catalog
GET /api/mcp/catalog
GET /api/mcp/status
GET /api/mcp/status
Tunnel
Expose the local Agent UI over the internet via an ngrok/Cloudflare tunnel. Used to reach the UI from a phone.POST /api/tunnel/start
POST /api/tunnel/start
POST /api/tunnel/stop
POST /api/tunnel/stop
GET /api/tunnel/status
GET /api/tunnel/status
Chat (advanced)
POST /api/chat/confirm-tool
POST /api/chat/confirm-tool
confirmation_required_tools() set (the generic base set merged with the
agent’s own CONFIRMATION_REQUIRED_TOOLS) triggers the agent to pause,
the UI prompts the user and posts the outcome (approve / deny) back on
this endpoint.Documents (advanced)
POST /api/documents/upload
POST /api/documents/upload
GET /api/documents/monitor/status
GET /api/documents/monitor/status
document_monitor.py file-watcher.GET /api/documents/{doc_id}/status
GET /api/documents/{doc_id}/status
POST /api/documents/{doc_id}/cancel
POST /api/documents/{doc_id}/cancel
POST /api/documents/index-folder
POST /api/documents/index-folder
Sessions (advanced)
DELETE /api/sessions/{session_id}/messages/{message_id}
DELETE /api/sessions/{session_id}/messages/{message_id}
DELETE /api/sessions/{session_id}/messages/{message_id}/and-below
DELETE /api/sessions/{session_id}/messages/{message_id}/and-below
System (advanced)
GET /api/system/tasks
GET /api/system/tasks
src/gaia/ui/dispatch.py.Memory
The Memory endpoints expose the agent’s persistent knowledge system. See the Memory SDK Reference for the underlyingMemoryStore and MemoryMixin APIs.
GET /api/memory/stats
GET /api/memory/stats
GET /api/memory/knowledge
GET /api/memory/knowledge
POST /api/memory/knowledge
POST /api/memory/knowledge
source='user' and confidence=0.8.Request:PUT /api/memory/knowledge/{knowledge_id}
PUT /api/memory/knowledge/{knowledge_id}
DELETE /api/memory/knowledge/{knowledge_id}
DELETE /api/memory/knowledge/{knowledge_id}
GET /api/memory/upcoming
GET /api/memory/upcoming
days (default 7)Response:GET /api/memory/entities
GET /api/memory/entities
GET /api/memory/tools
GET /api/memory/tools
GET /api/memory/conversations
GET /api/memory/conversations
limit (default 20)GET /api/memory/conversations/{session_id}
GET /api/memory/conversations/{session_id}
GET /api/memory/activity
GET /api/memory/activity
days (default 30)Response:GET /api/memory/embedding-coverage
GET /api/memory/embedding-coverage
POST /api/memory/consolidate
POST /api/memory/consolidate
POST /api/memory/reconcile
POST /api/memory/reconcile
POST /api/memory/rebuild-embeddings
POST /api/memory/rebuild-embeddings
POST /api/memory/rebuild-fts
POST /api/memory/rebuild-fts
Database Schema
The Agent UI uses SQLite with four tables:indexing_status, file_mtime, agent_steps, and inference_stats
columns (plus the settings table) are added via migrations for databases
created before these existed. New databases include them in the initial schema.Testing
Unit Testing with In-Memory Database
Database Testing
Integration with the Agent
The Agent UI server delegates to the GAIA Agent for LLM communication and tool execution:npm Package
GAIA Agent UI is also available as an npm package for quick installation:gaia-ui CLI command:
gaia-ui automatically installs the Python backend (uv, Python 3.12, amd-gaia) if not already present. On subsequent runs, it auto-updates if the version doesn’t match.
Package Contents
The npm package includes:Release Management
The package version is sourced fromsrc/gaia/version.py (single source of truth for all of GAIA):
v* trigger the automated npm publish workflow.
Related
- User Guide — Desktop app usage, features, and troubleshooting
- Agent SDK — Core Agent SDK with memory and RAG
- RAG SDK — Document indexing and retrieval
- Desktop App Installation — Download and install instructions