Skip to content

A multi-model AI chat platform built to be a complete solution for your own personal assistant or an ai assistant service offering.

License

Notifications You must be signed in to change notification settings

nicholasgriffintn/ai-platform

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

AI Platform

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.

A screenshot of a chat in the frontend application

Quick Links

Example Chats

Here are some example chats that you can try out:

What's Included

This monorepo contains:

Features

Core API Features

  • 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)

Additional Features

  • 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

Usage Limits

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.

Setup and Installation

Getting Started

  1. Clone the repository

  2. Install dependencies

    pnpm install
  3. Configure environment variables:

    • Copy .dev.vars.example to .dev.vars in all the apps directories that have them.
    • Copy wrangler.jsonc.example to wrangler.jsonc in all the apps directories that have them.
    • Adjust with your API keys and configuration values.
  4. 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

Deployment

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:metrics

API Documentation

The complete API documentation lives in the OpenAPI schema defined in apps/api/src/openapi/documentation.ts and served at api.polychat.app.

Quick Example

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

Database Management

The application uses a Cloudflare D1 database with Drizzle ORM for schema management and migrations.

Running 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:prod

To generate a new migration, run:

pnpm run db:generate

Monitoring and Analytics

The 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.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the terms of the license included in the repository.

About

A multi-model AI chat platform built to be a complete solution for your own personal assistant or an ai assistant service offering.

Topics

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Contributors 5

Languages