Polychat is an experimental multi-model AI assistant platform. It brings chat, agents, retrieval, generated media, code assistance, and workflow-style apps into one Cloudflare-backed API with React web and iOS clients (In Development).
Check out my write up on this project here. I've also launched a version of this to try out at polychat.app.
Note
Please note that this project is still in active development so there are a few features that are not yet fully working or fully imagined. I'm also constantly testing stuff and re working, this is meant to be a playground for me.
- API Documentation - Live OpenAPI schema at api.polychat.app/openapi (served from
apps/api/src/index.ts, with tags inapps/api/src/openapi/documentation.ts) - Example Chats - See what's possible
- Getting Started - Set up your own instance
- Features - What's included
Here are some example chats that you can try out:
- Generation of a new React component
- Code generation and execution
- Web search integration
- Perplexity Deep Research
- Combined artifact previews
- Markdown formatting
- Search Grounding
- Multi-model responses
- Saved memories (RAG)
- Retrieved memories (RAG)
- Multi Step Tool Calls
- Multi Step MCP Calls
- Agent to agent delegation
- Image Generation
- Council
This monorepo contains:
- API - OpenAI-style API for chat, agents, models, tools, memories, media, realtime sessions, payments, and webhooks
- Web App - React-based PWA frontend for chat, shared conversations, generated artefacts, and focused app workflows
- Sandbox Worker - Automated coding worker built on Cloudflare Sandboxes
- Metrics Dashboard - Usage analytics and monitoring
- Training Worker - Internal Worker for API-managed model training and deployment jobs
- Mobile App - iOS application (In Development) (TestFlight)
- Chat Completions - OpenAI-style chat with streaming, tools, multimodal message parts, stored conversations, sharing, feedback, and token counting (tag:
chat) - Multi-provider Model Library - Anthropic, OpenAI, Google, Mistral, Meta, Bedrock, Groq, DeepSeek, Perplexity, Replicate, xAI, and many more through the provider registry (tag:
models) - Code Assistance - FIM completions, next-edit suggestions, apply-edit support, and sandboxed implementation workflows (tag:
code) - Agents & Delegation - Custom agents, shared agents, MCP server integrations, agent-to-agent delegation, and approval-aware tool flows (tag:
agents) - RAG & Memories - Vector-based context retrieval, memory groups, synthesis tasks, and namespace-aware retrieval with Cloudflare Vectorize (tag:
memories) - Tools & Dynamic Apps - Searchable function tools, dynamic app execution, reusable app responses, and app sharing (tags:
tools,dynamic-apps,apps) - Media & Realtime - Uploads, audio transcription and speech, image/video/music generation, screenshots, OCR, and realtime transcription sessions (tags:
uploads,audio,realtime) - Guardrails & Auth - Content safety checks, OAuth, magic links, passkeys, JWT, API keys, plan checks, Stripe subscriptions, rate limiting, CSRF, and security headers (tags:
guardrails,auth,plans,stripe)
- Automated Model Routing - Smart model selection
- AI Council - Multi-perspective debate mode with selectable council members and synthesis
- Canvas - Multi-model image and video generation with shared prompt controls
- Replicate App - Run media and multimodal predictions from Replicate models
- Sandbox App - Connect GitHub repositories and stream implementation, review, test, or bug-fix runs
- Strudel Music Patterns - Generate and edit code-based music patterns
- Podcast, Article, and Note Workflows - Transcribe, summarise, report, format, and regenerate content
- Drawing Apps - Create drawings and ask AI to enhance or guess them
- Web LLM Support - Local/offline chat mode in the web app
- Metrics Dashboard - Usage, model performance, costs, and user activity monitoring
The Sandbox Worker uses Cloudflare Sandboxes to run AI-powered code generation tasks against GitHub repositories. This enables automated feature implementation triggered via GitHub comments or the web UI.
I wrote more about this in my blog post here.
How it works:
- Install the GitHub App on your repository
- Start an implementation, review, test, or bug-fix run from the web UI or GitHub workflow
- The AI generates a plan and executes commands in an isolated sandbox
- Progress streams back to the app while results are prepared for review
Key capabilities:
- Isolated command execution with security restrictions
- Real-time progress streaming via SSE
- Git operations (clone, branch, commit)
- Web UI for installation, run history, instructions, pausing, cancellation, and task tracking
See all features in the OpenAPI reference → api.polychat.app/openapi
Polychat is configured with usage limits to prevent abuse. These limits are as follows:
- 10 standard messages per day for unauthenticated users
- 50 standard messages per day for authenticated users
- 200 pro tokens per day for authenticated users
Pro tokens are calculated based on a multiplier of the cost of the model. For example, if a model costs $0.01 per 1000 input tokens and $0.05 per 1000 output tokens, then the pro token limit is 200 * (0.01 + 0.05) / 2 = 6.
This equates to around:
- Expensive models (9x): ~22 messages
- Mid-tier models (3x): ~66 messages
- Cheaper models (1-2x): 100-200 messages
If you are providing your own service and would like to change these limits, you can do so by changing the USAGE_CONFIG object in the apps/api/src/constants/app.ts file.
-
Clone the repository
-
Install dependencies
pnpm install
-
Configure environment variables:
- Copy
.dev.vars.exampleto.dev.varsin all the apps directories that have them. - Copy
wrangler.jsonc.exampletowrangler.jsoncin all the apps directories that have them. - Adjust with your API keys and configuration values.
- Copy
-
Start the development servers:
# Start the API and web app pnpm run dev # Or start individual apps pnpm run dev:app pnpm run dev:api pnpm run dev:metrics
The applications are designed to be deployed to Cloudflare:
# Deploy all applications
pnpm run deploy
# Deploy individual applications
pnpm run deploy:app
pnpm run deploy:api
pnpm run deploy:metricsThe complete API documentation is generated by the API worker and served at api.polychat.app. Route registration lives in apps/api/src/index.ts, with tag descriptions in apps/api/src/openapi/documentation.ts.
curl https://api.polychat.app/chat/completions \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-3-5-sonnet-20241022",
"messages": [
{"role": "user", "content": "Hello!"}
]
}'View full API reference → api.polychat.app
The application uses a Cloudflare D1 database with Drizzle ORM for schema management and migrations.
cd apps/api
# Migrate to the local database
pnpm run db:migrate:local
# Migrate to the preview database
pnpm run db:migrate:preview
# Migrate to the production database
pnpm run db:migrate:prodTo generate a new migration, run:
pnpm run db:generateThe metrics application provides dashboards for monitoring:
- API usage and performance
- Model performance and costs
- User activity and engagement
Access the metrics dashboard at metrics.polychat.app.
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the terms of the license included in the repository.
