CoAI.Dev Documentation
repository·main·Indexed 27 days ago
https://github.com/coaidev/coaiA comprehensive AIGC business solution combining a chat UI with a backend for model management, API proxying, and multi-tenant billing. It features an OpenAI-compatible API proxy, administrative tools for user and quota management, and deployment options via Docker, Zeabur, BTPanel, and AlibabaCloud ComputeNest.
What's inside CoAI.Dev
- CoAI.Dev is a next-generation AIGC (AI Generated Content) one-stop business solution. It combines the user-facing capabilities of Next Web with the powerful backend management and API distribution of One API. It is designed for developers and businesses to deploy a full-featured AI chat interface with advanced backend management, billing, and model proxying.
Overview of CoAI.Dev features
mainCoAI.Dev is an all-in-one AIGC commercial solution that combines the capabilities of Next Web and One API.
Key features include:
- Extensive Model Support: Compatible with OpenAI, Anthropic, Gemini, Midjourney, and many others, including support for private LLMs.
- Advanced UI/UX: Responsive design (PC/Pad/Mobile) using Shadcn UI and Tremor Charts, with light/dark mode and custom color support.
- Rich Markdown: Supports LaTeX, Mermaid diagrams, tables, code highlighting, and progress bars.
- Image Generation: Supports OpenAI DALL-E, Midjourney (including U/V/R actions), and Stable Diffusion.
- File Parsing & OCR: Out-of-the-box support for PDF, Docx, Pptx, Excel, and images. Integrates with S3, R2, and MinIO for cloud storage.
- Web Search: Integrated with SearXNG for searching via Google, Bing, DuckDuckGo, etc.
- Commercial Features: Supports subscription and elastic billing (per token or per request), gift codes, exchange codes, and a comprehensive admin dashboard.
- Channel Management: Enterprise-grade management including priority settings, weight-based load balancing, user grouping, automatic retries, and model redirection.
- OpenAI Compatible Proxy: Acts as a proxy for various models using the OpenAI API standard.
CoAI.Dev Technology Stack
mainCoAI.Dev is built using the following technologies:
- Frontend: React, Redux, Radix UI, Tailwind CSS
- Backend: Golang, Gin, Redis, MySQL
- Application Features: PWA, WebSocket
Deploy CoAI.Dev via Docker Compose
mainDocker Compose is the recommended installation method. Depending on your requirements, use one of the following commands:
Standard Installation (Recommended):
docker-compose up -dStable Version: To use the stable version instead of the latest:
docker-compose -f docker-compose.stable.yaml up -dAutomatic Updates with Watchtower: To use Watchtower for automatic image updates:
docker-compose -f docker-compose.watch.yaml up -dCompile and Install from Source
mainTo build CoAI.Dev manually, you need
pnpm(for the frontend) andgo(for the backend). The default port after successful compilation is8094.Build Steps:
- Clone the repository and enter the
chatniodirectory. - Build the frontend in the
appdirectory usingpnpm. - Build the backend using
go. - Run the binary (e.g., using
nohupfor background execution).
Note: Configuration settings in
~/config/config.yamlcan be overridden using environment variables (e.g.,MYSQL_HOSToverridesmysql.host).git clone https://github.com/coaidev/coai.git cd chatnio cd app npm install -g pnpm pnpm install pnpm build cd .. go build -o chatnio # Run in background nohup ./chatnio > output.log &- Clone the repository and enter the
Install via Docker (Lightweight Runtime)
mainUse this method if you want to use external MySQL or RDS services. After running, the service is accessible at
http://localhost:8094.Important Configuration Notes:
- Use
programzmh/chatnio:stableinstead ofprogramzmh/chatnio:latestfor the stable version. --network hostallows the container to use the host's network.SECRET: A random string used as the JWT secret key. Change this for security.SERVE_STATIC: Set totrueto enable static file serving.- Volume mounts:
~/configfor config,~/logsfor logs, and~/storagefor generated files.
Environment Variables:
MYSQL_HOST,MYSQL_PORT,MYSQL_DB,MYSQL_USER,MYSQL_PASSWORDREDIS_HOST,REDIS_PORTSECRET(JWT secret)SERVE_STATIC(boolean)
Manual Update Procedure:
docker stop chatnio docker rm chatnio docker pull programzmh/chatnio:latestdocker run -d --name chatnio \ --network host \ -v ~/config:/config \ -v ~/logs:/logs \ -v ~/storage:/storage \ -e MYSQL_HOST=localhost \ -e MYSQL_PORT=3306 \ -e MYSQL_DB=chatnio \ -e MYSQL_USER=root \ -e MYSQL_PASSWORD=chatnio123456 \ -e REDIS_HOST=localhost \ -e REDIS_PORT=6379 \ -e SECRET=secret \ -e SERVE_STATIC=true \ programzmh/chatnio:latest- Use
Install via Docker Compose (Recommended)
mainThe recommended way to run CoAI.Dev is using Docker Compose. After a successful run, the service is accessible at
http://localhost:8000.Deployment Commands:
- Standard deployment:
docker-compose up -d - Stable version:
docker-compose -f docker-compose.stable.yaml up -d - Automatic updates via Watchtower:
docker-compose -f docker-compose.watch.yaml up -d
Manual Update Procedure: If you are not using Watchtower, update the services using:
docker-compose down docker-compose pull docker-compose up -dData Persistence (Mount Directories):
- MySQL:
~/db - Redis:
~/redis - Configuration:
~/config
git clone --depth=1 --branch=main --single-branch https://github.com/coaidev/coai.git cd chatnio docker-compose up -d- Standard deployment:
Deploy via Zeabur (One-Click)
mainDeploy CoAI.Dev to Zeabur with a single click.
- Click the
Deploybutton on the Zeabur template page and enter your desired domain name. - Wait for deployment to complete.
- Access the domain. Use the default administrator credentials to log in and follow the prompts to change your password.
Default Credentials:
- Username:
root - Password:
chatnio123456
https://zeabur.com/templates/M86XJI- Click the
Compile and Install CoAI from Source
mainTo build CoAI manually, you need
pnpmandgoinstalled on your system. The default port after successful deployment is8094(http://localhost:8094).Build Steps
git clone https://github.com/coaidev/coai.git cd chatnio cd app npm install -g pnpm pnpm install pnpm build cd .. go build -o chatnioRunning the Application
You can run the binary using
nohupto keep it running in the background, or use a service manager likesystemd:nohup ./chatnio > output.log &Configuration
Configuration is managed via
~/config/config.yaml. You can override configuration items using environment variables. For example, theMYSQL_HOSTenvironment variable will override themysql.hostconfiguration key.git clone https://github.com/coaidev/coai.git cd chatnio cd app npm install -g pnpm pnpm install pnpm build cd .. go build -o chatnio nohup ./chatnio > output.log &Deploy CoAI via Docker Compose (Recommended)
mainThe recommended way to deploy CoAI is using Docker Compose. By default, the service will be accessible at
http://localhost:8000.Deployment Commands
To run the latest version:
git clone --depth=1 --branch=main --single-branch https://github.com/coaidev/coai.git cd chatnio docker-compose up -dVersion Variants
- Stable Version: Use
docker-compose -f docker-compose.stable.yaml up -d. - Automatic Updates: Use
docker-compose -f docker-compose.watch.yaml up -dto enable Watchtower for automatic updates.
Manual Updates
If you are not using the Watchtower configuration, update manually with:
docker-compose down docker-compose pull docker-compose up -dData Persistence
- MySQL database:
~/db - Redis database:
~/redis - Configuration files:
~/config
- Stable Version: Use
Deploy CoAI.Dev via Docker
mainFor a lightweight runtime, you can use standard Docker installation. This is commonly used when connecting to external services like MySQL or RDS.Use Model Mapping for Channels
mainModel mapping allows you to redirect user requests for one model name to a different model name supported by your upstream provider.
Syntax:
[from]>[to](one mapping per line).from: The model name requested by the user.to: The actual model name sent to the upstream provider.
Examples:
gpt-4-all>gpt-4: When a user requestsgpt-4-all, the backend sends a request forgpt-4to the upstream.!gpt-4-all>gpt-4: Adding a!prefix prevents the channel from being used for the originalgpt-4requests, making it exclusive to the mapped model.
gpt-4-all>gpt-4 !gpt-4-all>gpt-4