1 line
18 KiB
JSON
1 line
18 KiB
JSON
{"repo": "baoming-qi/new-api-bom", "files": {"README.md": {"0006f9f083309ed7ed0e6f3897282d2d07ce1474": {"t": 1785596141.3675213, "n": 17464, "h": "72a83557ebbaf6e8", "c": "<div align=\"center\">\n\n\n\n# New API\n\n🍥 **Next-Generation LLM Gateway and AI Asset Management System**\n\n<p align=\"center\">\n <a href=\"./README.zh_CN.md\">简体中文</a> |\n <a href=\"./README.zh_TW.md\">繁體中文</a> |\n <strong>English</strong> |\n <a href=\"./README.fr.md\">Français</a> |\n <a href=\"./README.ja.md\">日本語</a>\n</p>\n\n<p align=\"center\">\n <a href=\"https://raw.githubusercontent.com/Calcium-Ion/new-api/main/LICENSE\">\n <img src=\"https://img.shields.io/github/license/Calcium-Ion/new-api?color=brightgreen\" alt=\"license\">\n </a><!--\n --><a href=\"https://github.com/Calcium-Ion/new-api/releases/latest\">\n <img src=\"https://img.shields.io/github/v/release/Calcium-Ion/new-api?color=brightgreen&include_prereleases\" alt=\"release\">\n </a><!--\n --><a href=\"https://hub.docker.com/r/CalciumIon/new-api\">\n <img src=\"https://img.shields.io/badge/docker-dockerHub-blue\" alt=\"docker\">\n </a><!--\n --><a href=\"https://goreportcard.com/report/github.com/Calcium-Ion/new-api\">\n <img src=\"https://goreportcard.com/badge/github.com/Calcium-Ion/new-api\" alt=\"GoReportCard\">\n </a>\n</p>\n\n<p align=\"center\">\n <a href=\"https://trendshift.io/repositories/8227\" target=\"_blank\">\n <img src=\"https://trendshift.io/api/badge/repositories/8227\" alt=\"Calcium-Ion%2Fnew-api | Trendshift\" style=\"width: 250px; height: 55px;\" width=\"250\" height=\"55\"/>\n </a>\n <br>\n <a href=\"https://hellogithub.com/repository/QuantumNous/new-api\" target=\"_blank\">\n <img src=\"https://api.hellogithub.com/v1/widgets/recommend.svg?rid=539ac4217e69431684ad4a0bab768811&claim_uid=tbFPfKIDHpc4TzR\" alt=\"Featured|HelloGitHub\" style=\"width: 250px; height: 54px;\" width=\"250\" height=\"54\" />\n </a><!--\n --><a href=\"https://www.producthunt.com/products/new-api/launches/new-api?embed=true&utm_source=badge-featured&utm_medium=badge&utm_campaign=badge-new-api\" target=\"_blank\" rel=\"noopener noreferrer\">\n <img src=\"https://api.producthunt.com/widgets/embed-image/v1/featured.svg?post_id=1047693&theme=light&t=1769577875005\" alt=\"New API - All-in-one AI asset management gateway. | Product Hunt\" style=\"width: 250px; height: 54px;\" width=\"250\" height=\"54\" />\n </a>\n</p>\n\n<p align=\"center\">\n <a href=\"#-quick-start\">Quick Start</a> •\n <a href=\"#-key-features\">Key Features</a> •\n <a href=\"#-deployment\">Deployment</a> •\n <a href=\"#-documentation\">Documentation</a> •\n <a href=\"#-help-support\">Help</a>\n</p>\n\n</div>\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<p align=\"center\">\n <em>No particular order</em>\n</p>\n\n<p align=\"center\">\n <a href=\"https://www.cherry-ai.com/\" target=\"_blank\">\n <img src=\"./docs/images/cherry-studio.png\" alt=\"Cherry Studio\" height=\"80\" />\n </a><!--\n --><a href=\"https://github.com/iOfficeAI/AionUi/\" target=\"_blank\">\n <img src=\"./docs/images/aionui.png\" alt=\"Aion UI\" height=\"80\" />\n </a><!--\n --><a href=\"https://bda.pku.edu.cn/\" target=\"_blank\">\n <img src=\"./docs/images/pku.png\" alt=\"Peking University\" height=\"80\" />\n </a><!--\n --><a href=\"https://www.compshare.cn/?ytag=GPU_yy_gh_newapi\" target=\"_blank\">\n <img src=\"./docs/images/ucloud.png\" alt=\"UCloud\" height=\"80\" />\n </a><!--\n --><a href=\"https://www.aliyun.com/\" target=\"_blank\">\n <img src=\"./docs/images/aliyun.png\" alt=\"Alibaba Cloud\" height=\"80\" />\n </a><!--\n --><a href=\"https://io.net/\" target=\"_blank\">\n <img src=\"./docs/images/io-net.png\" alt=\"IO.NET\" height=\"80\" />\n </a>\n</p>\n\n---\n\n## 🙏 Special Thanks\n\n<p align=\"center\">\n <a href=\"https://www.jetbrains.com/?from=new-api\" target=\"_blank\">\n <img src=\"https://resources.jetbrains.com/storage/products/company/brand/logos/jb_beam.png\" alt=\"JetBrains Logo\" width=\"120\" />\n </a>\n</p>\n\n<p align=\"center\">\n <strong>Thanks to <a href=\"https://www.jetbrains.com/?from=new-api\">JetBrains</a> for providing free open-source development license for this project</strong>\n</p>\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<details>\n<summary><strong>Using Docker Commands</strong></summary>\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</details>\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<div align=\"center\">\n\n### 📖 [Official Documentation](https://docs.newapi.pro/en/docs) | [](https://deepwiki.com/QuantumNous/new-api)\n\n</div>\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<details>\n<summary>View detailed configuration</summary>\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</details>\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<details>\n<summary>View complete interface list</summary>\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</details>\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<details>\n<summary>Common environment variable configuration</summary>\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</details>\n\n### 🔧 Deployment Methods\n\n<details>\n<summary><strong>Method 1: Docker Compose (Recommended)</strong></summary>\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</details>\n\n<details>\n<summary><strong>Method 2: Docker Commands</strong></summary>\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</details>\n\n<details>\n<summary><strong>Method 3: BaoTa Panel</strong></summary>\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</details>\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<div align=\"center\">\n\n[](https://star-history.com/#Calcium-Ion/new-api&Date)\n\n</div>\n\n---\n\n<div align=\"center\">\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\n<sub>Built with ❤️ by QuantumNous</sub>\n\n</div>\n"}}}} |