{"repo": "baoming-qi/new-api-bom", "files": {"README.md": {"0006f9f083309ed7ed0e6f3897282d2d07ce1474": {"t": 1785596141.3675213, "n": 17464, "h": "72a83557ebbaf6e8", "c": "
\n\n![new-api](/web/public/logo.png)\n\n# New API\n\n๐Ÿฅ **Next-Generation LLM Gateway and AI Asset Management System**\n\n

\n ็ฎ€ไฝ“ไธญๆ–‡ |\n ็น้ซ”ไธญๆ–‡ |\n English |\n Franรงais |\n ๆ—ฅๆœฌ่ชž\n

\n\n

\n \n \"license\"\n \n \"release\"\n \n \"docker\"\n \n \"GoReportCard\"\n \n

\n\n

\n \n \"Calcium-Ion%2Fnew-api\n \n
\n \n \"Featured๏ฝœHelloGitHub\"\n \n \"New\n \n

\n\n

\n Quick Start โ€ข\n Key Features โ€ข\n Deployment โ€ข\n Documentation โ€ข\n Help\n

\n\n
\n\n## ๐Ÿ“ Project Description\n\n> [!IMPORTANT]\n> - This project is for personal learning purposes only, with no guarantee of stability or technical support\n> - Users must comply with OpenAI's [Terms of Use](https://openai.com/policies/terms-of-use) and **applicable laws and regulations**, and must not use it for illegal purposes\n> - According to the [ใ€ŠInterim Measures for the Management of Generative Artificial Intelligence Servicesใ€‹](http://www.cac.gov.cn/2023-07/13/c_1690898327029107.htm), please do not provide any unregistered generative AI services to the public in China.\n\n---\n\n## ๐Ÿค Trusted Partners\n\n

\n No particular order\n

\n\n

\n \n \"Cherry\n \n \"Aion\n \n \"Peking\n \n \"UCloud\"\n \n \"Alibaba\n \n \"IO.NET\"\n \n

\n\n---\n\n## ๐Ÿ™ Special Thanks\n\n

\n \n \"JetBrains\n \n

\n\n

\n Thanks to JetBrains for providing free open-source development license for this project\n

\n\n---\n\n## ๐Ÿš€ Quick Start\n\n### Using Docker Compose (Recommended)\n\n```bash\n# Clone the project\ngit clone https://github.com/QuantumNous/new-api.git\ncd new-api\n\n# Edit docker-compose.yml configuration\nnano docker-compose.yml\n\n# Start the service\ndocker-compose up -d\n```\n\n
\nUsing Docker Commands\n\n```bash\n# Pull the latest image\ndocker pull calciumion/new-api:latest\n\n# Using SQLite (default)\ndocker run --name new-api -d --restart always \\\n -p 3000:3000 \\\n -e TZ=Asia/Shanghai \\\n -v ./data:/data \\\n calciumion/new-api:latest\n\n# Using MySQL\ndocker run --name new-api -d --restart always \\\n -p 3000:3000 \\\n -e SQL_DSN=\"root:123456@tcp(localhost:3306)/oneapi\" \\\n -e TZ=Asia/Shanghai \\\n -v ./data:/data \\\n calciumion/new-api:latest\n```\n\n> **๐Ÿ’ก 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`\n\n
\n\n---\n\n๐ŸŽ‰ After deployment is complete, visit `http://localhost:3000` to start using!\n\n๐Ÿ“– For more deployment methods, please refer to [Deployment Guide](https://docs.newapi.pro/en/docs/installation)\n\n---\n\n## ๐Ÿ“š Documentation\n\n
\n\n### ๐Ÿ“– [Official Documentation](https://docs.newapi.pro/en/docs) | [![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/QuantumNous/new-api)\n\n
\n\n**Quick Navigation:**\n\n| Category | Link |\n|------|------|\n| ๐Ÿš€ Deployment Guide | [Installation Documentation](https://docs.newapi.pro/en/docs/installation) |\n| โš™๏ธ Environment Configuration | [Environment Variables](https://docs.newapi.pro/en/docs/installation/config-maintenance/environment-variables) |\n| ๐Ÿ“ก API Documentation | [API Documentation](https://docs.newapi.pro/en/docs/api) |\n| โ“ FAQ | [FAQ](https://docs.newapi.pro/en/docs/support/faq) |\n| ๐Ÿ’ฌ Community Interaction | [Communication Channels](https://docs.newapi.pro/en/docs/support/community-interaction) |\n\n---\n\n## โœจ Key Features\n\n> For detailed features, please refer to [Features Introduction](https://docs.newapi.pro/en/docs/guide/wiki/basic-concepts/features-introduction)\n\n### ๐ŸŽจ Core Functions\n\n| Feature | Description |\n|------|------|\n| ๐ŸŽจ New UI | Modern user interface design |\n| ๐ŸŒ Multi-language | Supports Simplified Chinese, Traditional Chinese, English, French, Japanese |\n| ๐Ÿ”„ Data Compatibility | Fully compatible with the original One API database |\n| ๐Ÿ“ˆ Data Dashboard | Visual console and statistical analysis |\n| ๐Ÿ”’ Permission Management | Token grouping, model restrictions, user management |\n\n### ๐Ÿ’ฐ Payment and Billing\n\n- โœ… Online recharge (EPay, Stripe)\n- โœ… Pay-per-use model pricing\n- โœ… Cache billing support (OpenAI, Azure, DeepSeek, Claude, Qwen and all supported models)\n- โœ… Flexible billing policy configuration\n\n### ๐Ÿ” Authorization and Security\n\n- ๐Ÿ˜ˆ Discord authorization login\n- ๐Ÿค– LinuxDO authorization login\n- ๐Ÿ“ฑ Telegram authorization login\n- ๐Ÿ”‘ OIDC unified authentication\n- ๐Ÿ” Key quota query usage (with [neko-api-key-tool](https://github.com/Calcium-Ion/neko-api-key-tool))\n\n### ๐Ÿš€ Advanced Features\n\n**API Format Support:**\n- โšก [OpenAI Responses](https://docs.newapi.pro/en/docs/api/ai-model/chat/openai/create-response)\n- โšก [OpenAI Realtime API](https://docs.newapi.pro/en/docs/api/ai-model/realtime/create-realtime-session) (including Azure)\n- โšก [Claude Messages](https://docs.newapi.pro/en/docs/api/ai-model/chat/create-message)\n- โšก [Google Gemini](https://doc.newapi.pro/en/api/google-gemini-chat)\n- ๐Ÿ”„ [Rerank Models](https://docs.newapi.pro/en/docs/api/ai-model/rerank/create-rerank) (Cohere, Jina)\n\n**Intelligent Routing:**\n- โš–๏ธ Channel weighted random\n- ๐Ÿ”„ Automatic retry on failure\n- ๐Ÿšฆ User-level model rate limiting\n\n**Format Conversion:**\n- ๐Ÿ”„ **OpenAI Compatible โ‡„ Claude Messages**\n- ๐Ÿ”„ **OpenAI Compatible โ†’ Google Gemini**\n- ๐Ÿ”„ **Google Gemini โ†’ OpenAI Compatible** - Text only, function calling not supported yet\n- ๐Ÿšง **OpenAI Compatible โ‡„ OpenAI Responses** - In development\n- ๐Ÿ”„ **Thinking-to-content functionality**\n\n**Reasoning Effort Support:**\n\n
\nView detailed configuration\n\n**OpenAI series models:**\n- `o3-mini-high` - High reasoning effort\n- `o3-mini-medium` - Medium reasoning effort\n- `o3-mini-low` - Low reasoning effort\n- `gpt-5-high` - High reasoning effort\n- `gpt-5-medium` - Medium reasoning effort\n- `gpt-5-low` - Low reasoning effort\n\n**Claude thinking models:**\n- `claude-3-7-sonnet-20250219-thinking` - Enable thinking mode\n\n**Google Gemini series models:**\n- `gemini-2.5-flash-thinking` - Enable thinking mode\n- `gemini-2.5-flash-nothinking` - Disable thinking mode\n- `gemini-2.5-pro-thinking` - Enable thinking mode\n- `gemini-2.5-pro-thinking-128` - Enable thinking mode with thinking budget of 128 tokens\n- You can also append `-low`, `-medium`, or `-high` to any Gemini model name to request the corresponding reasoning effort (no extra thinking-budget suffix needed).\n\n
\n\n---\n\n## ๐Ÿค– Model Support\n\n> For details, please refer to [API Documentation - Relay Interface](https://docs.newapi.pro/en/docs/api)\n\n| Model Type | Description | Documentation |\n|---------|------|------|\n| ๐Ÿค– OpenAI-Compatible | OpenAI compatible models | [Documentation](https://docs.newapi.pro/en/docs/api/ai-model/chat/openai/createchatcompletion) |\n| ๐Ÿค– OpenAI Responses | OpenAI Responses format | [Documentation](https://docs.newapi.pro/en/docs/api/ai-model/chat/openai/createresponse) |\n| ๐ŸŽจ Midjourney-Proxy | [Midjourney-Proxy(Plus)](https://github.com/novicezk/midjourney-proxy) | [Documentation](https://doc.newapi.pro/api/midjourney-proxy-image) |\n| ๐ŸŽต Suno-API | [Suno API](https://github.com/Suno-API/Suno-API) | [Documentation](https://doc.newapi.pro/api/suno-music) |\n| ๐Ÿ”„ Rerank | Cohere, Jina | [Documentation](https://docs.newapi.pro/en/docs/api/ai-model/rerank/creatererank) |\n| ๐Ÿ’ฌ Claude | Messages format | [Documentation](https://docs.newapi.pro/en/docs/api/ai-model/chat/createmessage) |\n| ๐ŸŒ Gemini | Google Gemini format | [Documentation](https://docs.newapi.pro/en/docs/api/ai-model/chat/gemini/geminirelayv1beta) |\n| ๐Ÿ”ง Dify | ChatFlow mode | - |\n| ๐ŸŽฏ Custom | Supports complete call address | - |\n\n### ๐Ÿ“ก Supported Interfaces\n\n
\nView complete interface list\n\n- [Chat Interface (Chat Completions)](https://docs.newapi.pro/en/docs/api/ai-model/chat/openai/createchatcompletion)\n- [Response Interface (Responses)](https://docs.newapi.pro/en/docs/api/ai-model/chat/openai/createresponse)\n- [Image Interface (Image)](https://docs.newapi.pro/en/docs/api/ai-model/images/openai/post-v1-images-generations)\n- [Audio Interface (Audio)](https://docs.newapi.pro/en/docs/api/ai-model/audio/openai/create-transcription)\n- [Video Interface (Video)](https://docs.newapi.pro/en/docs/api/ai-model/audio/openai/createspeech)\n- [Embedding Interface (Embeddings)](https://docs.newapi.pro/en/docs/api/ai-model/embeddings/createembedding)\n- [Rerank Interface (Rerank)](https://docs.newapi.pro/en/docs/api/ai-model/rerank/creatererank)\n- [Realtime Conversation (Realtime)](https://docs.newapi.pro/en/docs/api/ai-model/realtime/createrealtimesession)\n- [Claude Chat](https://docs.newapi.pro/en/docs/api/ai-model/chat/createmessage)\n- [Google Gemini Chat](https://docs.newapi.pro/en/docs/api/ai-model/chat/gemini/geminirelayv1beta)\n\n
\n\n---\n\n## ๐Ÿšข Deployment\n\n> [!TIP]\n> **Latest Docker image:** `calciumion/new-api:latest`\n\n### ๐Ÿ“‹ Deployment Requirements\n\n| Component | Requirement |\n|------|------|\n| **Local database** | SQLite (Docker must mount `/data` directory)|\n| **Remote database** | MySQL โ‰ฅ 5.7.8 or PostgreSQL โ‰ฅ 9.6 |\n| **Container engine** | Docker / Docker Compose |\n\n### โš™๏ธ Environment Variable Configuration\n\n
\nCommon environment variable configuration\n\n| Variable Name | Description | Default Value |\n|--------|------|--------|\n| `SESSION_SECRET` | Session secret (required for multi-machine deployment) | - |\n| `CRYPTO_SECRET` | Encryption secret (required for Redis) | - |\n| `SQL_DSN` | Database connection string | - |\n| `REDIS_CONN_STRING` | Redis connection string | - |\n| `STREAMING_TIMEOUT` | Streaming timeout (seconds) | `300` |\n| `STREAM_SCANNER_MAX_BUFFER_MB` | Max per-line buffer (MB) for the stream scanner; increase when upstream sends huge image/base64 payloads | `64` |\n| `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` |\n| `AZURE_DEFAULT_API_VERSION` | Azure API version | `2025-04-01-preview` |\n| `ERROR_LOG_ENABLED` | Error log switch | `false` |\n| `PYROSCOPE_URL` | Pyroscope server address | - |\n| `PYROSCOPE_APP_NAME` | Pyroscope application name | `new-api` |\n| `PYROSCOPE_BASIC_AUTH_USER` | Pyroscope basic auth user | - |\n| `PYROSCOPE_BASIC_AUTH_PASSWORD` | Pyroscope basic auth password | - |\n| `PYROSCOPE_MUTEX_RATE` | Pyroscope mutex sampling rate | `5` |\n| `PYROSCOPE_BLOCK_RATE` | Pyroscope block sampling rate | `5` |\n| `HOSTNAME` | Hostname tag for Pyroscope | `new-api` |\n\n๐Ÿ“– **Complete configuration:** [Environment Variables Documentation](https://docs.newapi.pro/en/docs/installation/config-maintenance/environment-variables)\n\n
\n\n### ๐Ÿ”ง Deployment Methods\n\n
\nMethod 1: Docker Compose (Recommended)\n\n```bash\n# Clone the project\ngit clone https://github.com/QuantumNous/new-api.git\ncd new-api\n\n# Edit configuration\nnano docker-compose.yml\n\n# Start service\ndocker-compose up -d\n```\n\n
\n\n
\nMethod 2: Docker Commands\n\n**Using SQLite:**\n```bash\ndocker run --name new-api -d --restart always \\\n -p 3000:3000 \\\n -e TZ=Asia/Shanghai \\\n -v ./data:/data \\\n calciumion/new-api:latest\n```\n\n**Using MySQL:**\n```bash\ndocker run --name new-api -d --restart always \\\n -p 3000:3000 \\\n -e SQL_DSN=\"root:123456@tcp(localhost:3306)/oneapi\" \\\n -e TZ=Asia/Shanghai \\\n -v ./data:/data \\\n calciumion/new-api:latest\n```\n\n> **๐Ÿ’ก Path explanation:**\n> - `./data:/data` - Relative path, data saved in the data folder of the current directory\n> - You can also use absolute path, e.g.: `/your/custom/path:/data`\n\n
\n\n
\nMethod 3: BaoTa Panel\n\n1. Install BaoTa Panel (โ‰ฅ 9.2.0 version)\n2. Search for **New-API** in the application store\n3. One-click installation\n\n๐Ÿ“– [Tutorial with images](./docs/BT.md)\n\n
\n\n### โš ๏ธ Multi-machine Deployment Considerations\n\n> [!WARNING]\n> - **Must set** `SESSION_SECRET` - Otherwise login status inconsistent\n> - **Shared Redis must set** `CRYPTO_SECRET` - Otherwise data cannot be decrypted\n\n### ๐Ÿ”„ Channel Retry and Cache\n\n**Retry configuration:** `Settings โ†’ Operation Settings โ†’ General Settings โ†’ Failure Retry Count`\n\n**Cache configuration:**\n- `REDIS_CONN_STRING`: Redis cache (recommended)\n- `MEMORY_CACHE_ENABLED`: Memory cache\n\n---\n\n## ๐Ÿ”— Related Projects\n\n### Upstream Projects\n\n| Project | Description |\n|------|------|\n| [One API](https://github.com/songquanpeng/one-api) | Original project base |\n| [Midjourney-Proxy](https://github.com/novicezk/midjourney-proxy) | Midjourney interface support |\n\n### Supporting Tools\n\n| Project | Description |\n|------|------|\n| [neko-api-key-tool](https://github.com/Calcium-Ion/neko-api-key-tool) | Key quota query tool |\n| [new-api-horizon](https://github.com/Calcium-Ion/new-api-horizon) | New API high-performance optimized version |\n\n---\n\n## ๐Ÿ’ฌ Help Support\n\n### ๐Ÿ“– Documentation Resources\n\n| Resource | Link |\n|------|------|\n| ๐Ÿ“˜ FAQ | [FAQ](https://docs.newapi.pro/en/docs/support/faq) |\n| ๐Ÿ’ฌ Community Interaction | [Communication Channels](https://docs.newapi.pro/en/docs/support/community-interaction) |\n| ๐Ÿ› Issue Feedback | [Issue Feedback](https://docs.newapi.pro/en/docs/support/feedback-issues) |\n| ๐Ÿ“š Complete Documentation | [Official Documentation](https://docs.newapi.pro/en/docs) |\n\n### ๐Ÿค Contribution Guide\n\nWelcome all forms of contribution!\n\n- ๐Ÿ› Report Bugs\n- ๐Ÿ’ก Propose New Features\n- ๐Ÿ“ Improve Documentation\n- ๐Ÿ”ง Submit Code\n\n---\n\n## ๐Ÿ“œ License\n\nThis project is licensed under the [GNU Affero General Public License v3.0 (AGPLv3)](./LICENSE).\n\nThis is an open-source project developed based on [One API](https://github.com/songquanpeng/one-api) (MIT License).\n\nIf 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](mailto:support@quantumnous.com)\n\n---\n\n## ๐ŸŒŸ Star History\n\n
\n\n[![Star History Chart](https://api.star-history.com/svg?repos=Calcium-Ion/new-api&type=Date)](https://star-history.com/#Calcium-Ion/new-api&Date)\n\n
\n\n---\n\n
\n\n### ๐Ÿ’– Thank you for using New API\n\nIf this project is helpful to you, welcome to give us a โญ๏ธ Star๏ผ\n\n**[Official Documentation](https://docs.newapi.pro/en/docs)** โ€ข **[Issue Feedback](https://github.com/Calcium-Ion/new-api/issues)** โ€ข **[Latest Release](https://github.com/Calcium-Ion/new-api/releases)**\n\nBuilt with โค๏ธ by QuantumNous\n\n
\n"}}}}