Self-hosting
You can deploy Nya AI on your own server for complete control over your data and costs.
We recommend using Docker Compose for deployment. You can refer to the docker-compose.example.yml for the compose file.
Architecture Overview
Core Components:
- db: Postgres 18 with the zhparser extension as the database
- server: Nya AI's API backend, the core of the entire architecture, based on bun
- web: Provides static resources for the frontend and acts as a reverse proxy, based on caddy
- zero-cache: Sync engine for handling client data queries and mutation requests
Other Dependencies:
- S3 Object Storage: Any S3-compatible object storage service
- SearXNG: A metasearch engine used for the web search feature. The SearXNG instance must allow JSON formatted search requests
Environment Variables
Here are the main environment variables for nyaai-server:
| Variable Name | Required | Description |
|---|---|---|
SITE_NAME | Yes | Site Name |
FRONT_URL | Yes | Public URL of the user frontend (e.g., https://example.com) |
ADMIN_URL | Yes | Public URL of the admin panel (e.g., https://admin.example.com) |
BETTER_AUTH_SECRET | Yes | Better Auth encryption secret. Please use a long random string |
DATABASE_URL | Yes | PostgreSQL connection string |
S3_ACCESS_KEY_ID | Yes | S3-compatible storage access key ID |
S3_SECRET_ACCESS_KEY | Yes | S3-compatible storage secret access key |
S3_ENDPOINT | Yes | S3-compatible storage endpoint, e.g., s3.<region>.backblazeb2.com |
S3_BUCKET | Yes | Name of the S3-compatible storage bucket |
SEARXNG_URL | Yes | URL of the SearXNG instance used for web search |
OPENAI_BASE_URL | No | Base URL of OpenAI-compatible providers, required if configuring platform models |
OPENAI_API_KEY | No | API Key of the OpenAI-compatible provider |
SMTP_USER, SMTP_PASSWORD, SMTP_HOST, SMTP_FROM, SMTP_PORT, SMTP_SECURE | No | SMTP-related variables. Required if sending verification emails or password reset emails |
REQUIRE_EMAIL_VERIFICATION | No | Set to true to mandate email address verification |
GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET | No | Google OAuth-related variables. Required for Google OAuth login |
GITHUB_CLIENT_ID, GITHUB_CLIENT_SECRET | No | GitHub OAuth-related variables. Required for GitHub OAuth login |
STRIPE_SECRET_KEY | No | Stripe API key. Required if using Stripe for payments |
STRIPE_WEBHOOK_SECRET | No | Stripe Webhook secret. Required if using Stripe for payments |
Quick Start
After configuring docker-compose.yaml and the environment variables, run docker compose up -d to start the services.
Nya AI exposes two ports externally:
8080from web: User frontend interface8081from web: Admin panel interface
The first user to log in to the admin panel automatically gains administrator privileges. For security reasons, it's recommended not to expose the admin port to the public network.