Go to file
xiezhouwei b63f75ade4 feat: add captcha verification for login form
- Add /api/captcha endpoint with captcha generation/verification service
- Add captcha_enabled option in system settings (model/option.go)
- Add captcha display and refresh logic in LoginForm
- Fix captcha not showing on Chrome due to Semi UI Form.Input suffix
  incompatibility; refactored to standalone flex layout
- Fix stale localStorage cache preventing captcha rendering on first visit
  by proactively fetching /api/status on LoginForm mount
- Add captcha_enabled toggle in admin SystemSetting panel
- Add i18n keys for captcha-related text (zh-CN, en)
2026-06-05 13:57:13 +08:00
bin Initial commit 2026-06-03 10:01:10 +08:00
common feat: add captcha verification for login form 2026-06-05 13:57:13 +08:00
constant Initial commit 2026-06-03 10:01:10 +08:00
controller feat: add captcha verification for login form 2026-06-05 13:57:13 +08:00
docs Initial commit 2026-06-03 10:01:10 +08:00
dto Initial commit 2026-06-03 10:01:10 +08:00
electron Initial commit 2026-06-03 10:01:10 +08:00
i18n Initial commit 2026-06-03 10:01:10 +08:00
logger Initial commit 2026-06-03 10:01:10 +08:00
middleware feat: 操作日志功能实现及字段级diff优化 2026-06-04 15:17:59 +08:00
model feat: add captcha verification for login form 2026-06-05 13:57:13 +08:00
oauth Initial commit 2026-06-03 10:01:10 +08:00
pkg Initial commit 2026-06-03 10:01:10 +08:00
relay Initial commit 2026-06-03 10:01:10 +08:00
router feat: add captcha verification for login form 2026-06-05 13:57:13 +08:00
service feat: add captcha verification for login form 2026-06-05 13:57:13 +08:00
setting Initial commit 2026-06-03 10:01:10 +08:00
types Initial commit 2026-06-03 10:01:10 +08:00
web feat: add captcha verification for login form 2026-06-05 13:57:13 +08:00
.cursorrules Initial commit 2026-06-03 10:01:10 +08:00
.dockerignore Initial commit 2026-06-03 10:01:10 +08:00
.env.example Initial commit 2026-06-03 10:01:10 +08:00
.gitattributes Initial commit 2026-06-03 10:01:10 +08:00
.gitignore Remove .codebuddy from tracking and add to .gitignore 2026-06-03 10:15:09 +08:00
AGENTS.md Initial commit 2026-06-03 10:01:10 +08:00
CLAUDE.md Initial commit 2026-06-03 10:01:10 +08:00
Dockerfile feat: 操作日志功能实现及字段级diff优化 2026-06-04 15:17:59 +08:00
LICENSE Initial commit 2026-06-03 10:01:10 +08:00
NOTICE Initial commit 2026-06-03 10:01:10 +08:00
README.fr.md Initial commit 2026-06-03 10:01:10 +08:00
README.ja.md Initial commit 2026-06-03 10:01:10 +08:00
README.md Initial commit 2026-06-03 10:01:10 +08:00
README.zh_CN.md Initial commit 2026-06-03 10:01:10 +08:00
README.zh_TW.md Initial commit 2026-06-03 10:01:10 +08:00
TokenFactory_Architecture_Doc.docx Initial commit 2026-06-03 10:01:10 +08:00
TokenFactory_Architecture_Doc_CN.docx Initial commit 2026-06-03 10:01:10 +08:00
VERSION Initial commit 2026-06-03 10:01:10 +08:00
docker-compose.local.yml Initial commit 2026-06-03 10:01:10 +08:00
docker-compose.yml feat: 操作日志功能实现及字段级diff优化 2026-06-04 15:17:59 +08:00
go.mod Initial commit 2026-06-03 10:01:10 +08:00
go.sum Initial commit 2026-06-03 10:01:10 +08:00
main.go Initial commit 2026-06-03 10:01:10 +08:00
makefile Initial commit 2026-06-03 10:01:10 +08:00
new-api.service Initial commit 2026-06-03 10:01:10 +08:00
package-lock.json Initial commit 2026-06-03 10:01:10 +08:00

README.md

token-factory

TokenFactory

AI gateway you self-host: route many model providers through one API surface, with users, keys, quotas, and an admin UI.


Upstream (required reading)

TokenFactory is derived from the QuantumNous/new-api project (“New API”). That repository is the authoritative upstream for design, protocol coverage, and community history. This fork may diverge; for behavior and APIs, treat upstream docs as the baseline and verify against your build.

Upstream repository github.com/QuantumNous/new-api
License GNU AGPL v3.0 — same for modifications here; see NOTICE
Network use If you offer a modified version over a network to others, AGPL-3.0 section 13 requires you to provide the corresponding full source under the same license.

简体中文 | 繁體中文 | English | Français | 日本語

AGPL-3.0   Upstream: QuantumNous/new-api   This repository

Quick StartDocumentationLanguagesDeploymentLicenseHelp

About this repository

TokenFactory is a self-hosted control plane for aggregating upstream AI vendors: one place to configure channels, map models, enforce access, and observe usage. You run the binary (or container), point clients at it, and manage everything from the web console.

This README describes this forks packaging and pointers. It does not replace the upstream feature list or legal notices—those remain tied to QuantumNous/new-api and the license files in this tree.

Compliance & disclaimer

  • Use only in line with provider terms (e.g. OpenAI Terms of Use) and applicable law. No illegal or abusive use.
  • In China, follow registration and compliance rules for generative AI services (e.g. 《生成式人工智能服务管理暂行办法》); do not offer unregistered public generative AI services where prohibited.
  • No warranty: treat this as self-supported infrastructure unless you arrange your own support.

Quick Start

# Clone the project
git clone https://github.com/QuantumNous/token-factory.git
cd token-factory

# Edit docker-compose.yml configuration
nano docker-compose.yml

# Start the service
docker-compose up -d
Using Docker Commands
# Pull the latest image
docker pull ghcr.io/fyinfor/token-factory:latest

# Using SQLite (default)
docker run --name token-factory -d --restart always \
  -p 3000:3000 \
  -e TZ=Asia/Shanghai \
  -v ./data:/data \
  ghcr.io/fyinfor/token-factory:latest

# Using MySQL
docker run --name token-factory -d --restart always \
  -p 3000:3000 \
  -e SQL_DSN="root:123456@tcp(localhost:3306)/oneapi" \
  -e TZ=Asia/Shanghai \
  -v ./data:/data \
  ghcr.io/fyinfor/token-factory:latest

💡 Tip: -v ./data:/data will save data in the data folder of the current directory, you can also change it to an absolute path like -v /your/custom/path:/data


When the stack is healthy, open http://localhost:3000. More install paths (bare metal, panels, etc.): installation docs.


Documentation

The QuantumNous/new-api ecosystem publishes the reference manuals for APIs, models, and operations. TokenFactory tracks that stack; use the docs as the source of truth and validate against your build.

Manual (EN / ZH) docs.newapi.pro — English · 简体中文
Environment variables Configuration reference
Relay / REST API API documentation
Feature overview Features introduction
FAQ & community FAQ · Channels
Deep dive (third-party) DeepWiki — QuantumNous/new-api

This repository: report fork-specific bugs (packaging, defaults, CI) here. If the behavior matches upstream, reproduce on QuantumNous/new-api and follow their contribution guidelines.


What you get (at a glance)

Capabilities come from the upstream codebase; this is a summary, not an exhaustive spec:

  • Relay — many vendor adapters behind a unified API surface (OpenAI-compatible and other formats per upstream).
  • Console — channels, model mapping, users, keys, usage and billing configuration.
  • Policies — quotas, rate limits, retries, and optional cache when Redis is enabled.
  • Storage — SQLite, MySQL, or PostgreSQL; optional Redis for sessions/cache/crypto as documented upstream.

For model-by-model and endpoint-by-endpoint detail, use the API docs and QuantumNous/new-api releases.


Supported languages

Code Language
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
en English
fr French
ru Russian
ja Japanese
vi Vietnamese
id Indonesian
ms Malay
th Thai
sw Swahili

Deployment

[!TIP] Latest Docker image: ghcr.io/fyinfor/token-factory:latest

📋 Deployment Requirements

Component Requirement
Local database SQLite (Docker must mount /data directory)
Remote database MySQL ≥ 5.7.8 or PostgreSQL ≥ 9.6
Container engine Docker / Docker Compose

⚙️ Environment Variable Configuration

Common environment variable configuration
Variable Name Description Default Value
SESSION_SECRET Session secret (required for multi-machine deployment) -
CRYPTO_SECRET Encryption secret (required for Redis) -
SQL_DSN Database connection string -
REDIS_CONN_STRING Redis connection string -
STREAMING_TIMEOUT Streaming timeout (seconds) 300
STREAM_SCANNER_MAX_BUFFER_MB Max per-line buffer (MB) for the stream scanner; increase when upstream sends huge image/base64 payloads 64
MAX_REQUEST_BODY_MB Max request body size (MB, counted after decompression; prevents huge requests/zip bombs from exhausting memory). Exceeding it returns 413 32
AZURE_DEFAULT_API_VERSION Azure API version 2025-04-01-preview
ERROR_LOG_ENABLED Error log switch false
PYROSCOPE_URL Pyroscope server address -
PYROSCOPE_APP_NAME Pyroscope application name token-factory
PYROSCOPE_BASIC_AUTH_USER Pyroscope basic auth user -
PYROSCOPE_BASIC_AUTH_PASSWORD Pyroscope basic auth password -
PYROSCOPE_MUTEX_RATE Pyroscope mutex sampling rate 5
PYROSCOPE_BLOCK_RATE Pyroscope block sampling rate 5
HOSTNAME Hostname tag for Pyroscope token-factory

📖 Complete configuration: Environment Variables Documentation

🔧 Deployment Methods

Docker Compose: use the Quick Start commands above (clone → edit docker-compose.ymldocker-compose up -d).

Alternative: plain Docker run

Using SQLite:

docker run --name token-factory -d --restart always \
  -p 3000:3000 \
  -e TZ=Asia/Shanghai \
  -v ./data:/data \
  ghcr.io/fyinfor/token-factory:latest

Using MySQL:

docker run --name token-factory -d --restart always \
  -p 3000:3000 \
  -e SQL_DSN="root:123456@tcp(localhost:3306)/oneapi" \
  -e TZ=Asia/Shanghai \
  -v ./data:/data \
  ghcr.io/fyinfor/token-factory:latest

💡 Path explanation:

  • ./data:/data - Relative path, data saved in the data folder of the current directory
  • You can also use absolute path, e.g.: /your/custom/path:/data
BaoTa Panel
  1. Install BaoTa Panel (≥ 9.2.0 version)
  2. Search for TokenFactory in the application store
  3. One-click installation

📖 Tutorial with images

⚠️ Multi-machine Deployment Considerations

[!WARNING]

  • Must set SESSION_SECRET - Otherwise login status inconsistent
  • Shared Redis must set CRYPTO_SECRET - Otherwise data cannot be decrypted

🔄 Channel Retry and Cache

Retry configuration: Settings → Operation Settings → General Settings → Failure Retry Count

Cache configuration:

  • REDIS_CONN_STRING: Redis cache (recommended)
  • MEMORY_CACHE_ENABLED: Memory cache

Lineage

Repository Role
QuantumNous/new-api Upstream — New API (AGPL-3.0). Start here for history, issues that are not fork-specific, and feature design.
One API Earlier MIT-licensed codebase in the same family tree.
Midjourney-Proxy Optional Midjourney integration (see upstream docs).

Tools maintained around the ecosystem (e.g. neko-api-key-tool) are documented upstream.


Help

📖 Documentation Resources

Resource Link
📘 FAQ FAQ
💬 Community Interaction Communication Channels
🐛 Issue Feedback Issue Feedback
📚 Complete Documentation Official Documentation

🤝 Contribution Guide

Welcome all forms of contribution!

  • 🐛 Report Bugs
  • 💡 Propose New Features
  • 📝 Improve Documentation
  • 🔧 Submit Code

License

This project (TokenFactory) is licensed under the GNU Affero General Public License v3.0 (AGPLv3). Modifications and further derivatives remain under AGPL-3.0 unless you obtain a separate commercial license from the copyright holders.

Attribution: TokenFactory is derived from QuantumNous/new-api (New API), which is also under AGPL-3.0. The project chain includes One API (MIT License) as an earlier base. Please retain upstream notices and this repositorys LICENSE and NOTICE. Under AGPL-3.0 section 13, if you run a modified version as a network service for others, you must offer them the corresponding complete source code under the same license.

If your organization's policies do not permit the use of AGPLv3-licensed software, or if you wish to avoid the open-source obligations of AGPLv3, please contact us at: support@quantumnous.com


TokenFactory — self-hosted AI gateway (this fork).

Upstream: QuantumNous/new-api · Docs: docs.newapi.pro · This repo: issues

The New API project is developed by QuantumNous and contributors. JetBrains supports open-source development through free IDE licenses.