Introduction to OS Chat
Relevant source files
The following files were used as context for generating this wiki page:
OS Chat is a free, open-source AI personal assistant platform designed to provide a comprehensive alternative to proprietary chat interfaces. It integrates over 50 language models from various providers, including OpenAI, Anthropic, Google, and Meta, into a single, unified interface. Beyond standard chat capabilities, the system emphasizes automation through background agents and deep service integrations with tools like Gmail, Notion, and GitHub.
The platform is built on a modern full-stack architecture utilizing TanStack Start for the frontend and Convex for real-time backend operations. It prioritizes data portability and user privacy, offering encrypted API key storage and the ability to self-host the entire stack.
Sources: README.md:12-25, CLAUDE.md:38-45, src/components/structured-data.tsx:21-25
System Architecture
OS Chat employs a specialized architecture to handle real-time AI streaming and background task execution across a variety of providers.
High-Level Architecture Flow
The following diagram illustrates the relationship between the frontend framework, the serverless backend, and external AI/Service providers.
The architecture uses TanStack Start for SSR and file-based routing, while Convex provides the serverless infrastructure for database operations, authentication, and file storage.
Sources: CLAUDE.md:65-92, README.md:104-120
Core Components
| Component | Technology | Role |
|---|---|---|
| Frontend Framework | TanStack Start (React 19) | Handles SSR, UI components, and client-side logic. |
| Backend / DB | Convex | Provides real-time subscriptions, serverless functions, and storage. |
| AI Integration | Vercel AI SDK v6 | Manages model switching, streaming, and tool calling. |
| Service Connector | Composio | Bridges the AI models to third-party services like Gmail and Slack. |
| State Management | Zustand / TanStack Query | Manages persisted local state and server state caching. |
Sources: CLAUDE.md:38-60, README.md:112-118
AI and Model Management
The system acts as a multi-model gateway, allowing users to switch between different AI capabilities within the same conversation thread.
Model Selection and Processing
The src/components/chat/chat.tsx file manages the selection and validation of models. The handleModelChange function allows users to update the model for an existing chat, which then persists via a Convex mutation.
Persona and Prompting System
OS Chat uses a structured persona system defined in src/lib/prompt_config.ts. Each persona (e.g., Researcher, Software Engineer, Teacher) is defined by a specific system prompt that shapes the AI's communication style and expertise.
- System Prompt Construction: The
buildSystemPromptfunction dynamically assembles instructions including user traits, timezone data, formatting rules, and tool-calling capabilities. - Formatting Rules: The system enforces specific LaTeX math wrapping (
$$) and code block identifiers to ensure consistent output.
Sources: src/lib/prompt_config.ts:32-100, src/lib/prompt_config.ts:347-385
Background Agents and Automation
One of the project's defining features is the ability to deploy "Background Agents" that operate autonomously outside of an active user session.
Scheduled Execution Logic
The execution of background tasks is handled in convex/scheduled_ai.ts. This system supports one-time, daily, and weekly schedules with timezone awareness.
Key Automation Features
- Email Notifications: Summaries of completed tasks are sent via Resend, utilizing a monospace terminal-style template for readability.
- Autonomous Tool Use: Agents utilize the
create_agenttool to interact with connected services (Gmail, Calendar) without real-time user intervention. - Memory Persistence: The system uses Redis via
ScheduledAgentMemoryto maintain "working memory" and history across different scheduled runs of the same task.
Sources: convex/email.ts:85-115, convex/scheduled_ai.ts:233-255
Security and Data Privacy
OS Chat implements a multi-layered security model to protect user data and sensitive API keys.
Data Protection Standards
- Encryption: API keys are encrypted using AES-GCM 256-bit encryption with PBKDF2 key derivation (100,000 iterations).
- Authentication: Secured through Google OAuth via Convex Auth.
- Rate Limiting: The system enforces limits based on user status (e.g., 5 messages/day for anonymous users, 20 for authenticated).
Sources: src/routes/security.tsx:28-45, src/routes/privacy.tsx:112-125
User Isolation
Data access is restricted through server-side validation. Each user-specific encryption key ensures that data remains isolated within the multi-tenant environment provided by Convex.
Sources: src/routes/security.tsx:40-45, src/routes/privacy.tsx:128-135
Technical Summary
OS Chat serves as a robust platform for both real-time AI interaction and complex background automation. By leveraging TanStack Start and Convex, it provides a high-performance, real-time experience while maintaining a modular architecture that easily accommodates new AI models and service integrations. Its focus on open-source transparency and rigorous security practices makes it a viable choice for users seeking a personalized AI assistant they can control.
Sources: README.md:143-155, src/components/structured-data.tsx:35-55 assistant
Relevant source files
The following files were used as context for generating this wiki page:
OS Chat is an open-source AI personal assistant platform designed to integrate multiple large language models (LLMs) with advanced automation and service connectors. It provides a unified interface for accessing over 50 AI models from providers such as OpenAI, Anthropic, Google, and Meta, while offering powerful features like background agents and third-party service integrations (e.g., Gmail, Notion, GitHub).
The project is architected as a full-stack React application utilizing TanStack Start for server-side rendering (SSR) and Convex as a real-time serverless backend. It prioritizes privacy through encrypted API key storage and offers a self-hostable alternative to proprietary AI chat platforms.
Sources: README.md:12-25, CLAUDE.md:38-45, src/components/structured-data.tsx:21-30
System Architecture
The architecture of OS Chat is divided into a high-performance frontend and a real-time reactive backend, connected via the Convex protocol.
Frontend Architecture
The frontend is built on TanStack Start, which combines file-based routing, server-side rendering, and efficient data fetching.
- Framework: React 19 with TanStack Start for full-stack capabilities.
- Routing: TanStack Router handles type-safe, file-based routing.
- State Management: Zustand is used for complex persisted state (like themes), while TanStack Query + Convex manages server-side state.
- UI Components: Built using Tailwind CSS v4, Radix UI, and shadcn/ui.
Sources: CLAUDE.md:65-80, README.md:104-120
Backend Architecture (Convex)
Convex serves as the primary backend, providing a real-time database and serverless execution environment.
The backend utilizes modular table definitions and functions to ensure data consistency and real-time updates across all connected clients.
Sources: CLAUDE.md:82-96, src/components/chat/chat.tsx:812-850
Core Features and AI Integration
OS Chat leverages the Vercel AI SDK v6 to manage model switching, streaming, and advanced tool calling.
Multi-Model Support
The platform supports a vast array of models, categorized by their capabilities:
- Text & Reasoning: OpenAI (o3, GPT-5), Anthropic (Claude 4.5), Google (Gemini 2.5), and DeepSeek.
- Image Generation: Flux Schnell, Imagen 4, and GPT Image 1.5.
- Multi-modal: Capability to process text, images, and reasoning across supported models.
Sources: README.md:66-98, CLAUDE.md:98-112
Background Agents and Automation
A key differentiator is the Background Agent system, which allows users to schedule tasks for autonomous execution.
Background agents utilize a specific executeTask action in convex/scheduled_ai.ts that manages task status, chat creation for execution logs, and automated email notifications upon completion.
Sources: convex/scheduled_ai.ts:25-80, convex/scheduled_ai.ts:315-350, README.md:38-46
Security and Data Privacy
OS Chat implements rigorous security measures to protect user data and sensitive credentials.
Security Implementation Details
| Feature | Implementation |
|---|---|
| API Key Encryption | AES-GCM 256-bit with PBKDF2 (100,000 iterations) |
| Data in Transit | HTTPS/TLS 1.3 encryption for all communications |
| Authentication | Google OAuth via Convex Auth |
| User Isolation | User-specific encryption keys and server-side validation |
| Rate Limiting | 5 msgs/day (Anonymous), 20 msgs/day (Authenticated) |
Sources: src/routes/security.tsx:28-45, src/routes/privacy.tsx:112-125
Personalization and Personas
Users can customize their experience through "Personas," which are predefined system prompts that shape the AI's behavior.
System Prompt Construction
The system prompt is dynamically built using the buildSystemPrompt function in src/lib/prompt_config.ts. It incorporates:
- User Profile: Name, occupation, and personal traits.
- Context: Current date, time, and user timezone.
- Capabilities: Enabled integrations (Gmail, Notion) and search status.
- Formatting Rules: Instructions for LaTeX, code blocks, and counting restrictions.
Sources: src/lib/prompt_config.ts:32-100, src/lib/prompt_config.ts:347-400
Technical Requirements & Deployment
The project is built for high performance and modern deployment workflows.
- Build Tool: Vite 8 and Bun for package management.
- Object Storage: Cloudflare R2 for file attachments.
- Caching: Upstash Redis for background agent memory and stream resuming.
- Hosting: Optimized for Vercel with DDoS protection.
Sources: CLAUDE.md:38-60, README.md:122-135
Summary
OS Chat represents a sophisticated implementation of a multi-model AI interface. By combining real-time backend capabilities with scheduled background agents and a flexible persona system, it offers a robust framework for personal productivity and automated workflows. The project's architecture ensures technical scalability while its security policies maintain high standards for user data protection.
Sources: README.md:204-210, src/components/structured-data.tsx:35-50