A complete AI platform that makes multiple models available from a single application. It features an API platform that has been built out to provide a range of AI interactions and applications alongside a React frontend and a mobile application (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. You can check out our roadmap here.
- API Documentation - Live OpenAPI schema at api.polychat.app/openapi (source:
apps/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
This monorepo contains:
- API - OpenAI-compatible API with 40+ models (served via OpenAPI)
- Web App - React-based PWA frontend
- Metrics Dashboard - Usage analytics and monitoring
- Mobile App - iOS application (TestFlight)
- Chat Completions - OpenAI-compatible chat with streaming, tools, and multi-turn conversations (tag:
chat) - 40+ AI Models - Anthropic, OpenAI, Google, Mistral, Meta, and many more (tag:
models) - Code Generation - FIM completions, edit suggestions, and code application (tag:
code) - AI Agents - Custom agents with MCP server integrations (tag:
agents) - RAG & Memories - Vector-based context retrieval with Cloudflare Vectorize (tag:
memories) - Guardrails - Content safety with Llamaguard and Bedrock (tag:
guardrails) - Multiple Auth Methods - OAuth, magic links, passkeys, JWT, API keys (tag:
auth)
- Automated Model Routing - Smart model selection
- AI Podcasting - Generate podcasts with AI
- Drawing Apps - AI-powered creative tools
- Benchmarking - Model performance testing
- Web Search Integration - Internet-grounded responses
- Media Uploads - Images, documents via Cloudflare R2
- Tool Calling - Multi-step function execution
- Web LLM Support - Offline mode for web app
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 all apps in development mode 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
npm run deploy
# Deploy individual applications
npm run deploy:app
npm run deploy:api
npm run deploy:metricsThe complete API documentation lives in the OpenAPI schema defined in apps/api/src/openapi/documentation.ts and served at api.polychat.app.
curl https://api.polychat.app/v1/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.
