{"id":15109679,"url":"https://github.com/calcium-ion/new-api","last_synced_at":"2025-04-03T06:00:30.864Z","repository":{"id":206566553,"uuid":"717197250","full_name":"Calcium-Ion/new-api","owner":"Calcium-Ion","description":"AI模型接口管理与分发系统，支持将多种大模型转为统一格式调用，支持OpenAI、Claude等格式，可供个人或者企业内部管理与分发渠道使用，本项目基于One API二次开发。🍥 The next-generation LLM gateway and AI asset management system supports multiple languages.","archived":false,"fork":false,"pushed_at":"2025-03-31T14:46:36.000Z","size":4772,"stargazers_count":6465,"open_issues_count":154,"forks_count":1281,"subscribers_count":34,"default_branch":"main","last_synced_at":"2025-04-03T05:13:13.681Z","etag":null,"topics":["ai-gateway","claude","deepseek","gemini","openai","rerank"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Calcium-Ion.png","metadata":{"files":{"readme":"README.en.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":null,"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":["https://afdian.com/a/new-api"]}},"created_at":"2023-11-10T19:33:36.000Z","updated_at":"2025-04-03T04:09:16.000Z","dependencies_parsed_at":"2024-07-05T19:11:40.744Z","dependency_job_id":"f8f53122-23e1-4ff2-8d6c-f263cea91541","html_url":"https://github.com/Calcium-Ion/new-api","commit_stats":null,"previous_names":["calcium-ion/new-api"],"tags_count":351,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Calcium-Ion%2Fnew-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Calcium-Ion%2Fnew-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Calcium-Ion%2Fnew-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Calcium-Ion%2Fnew-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Calcium-Ion","download_url":"https://codeload.github.com/Calcium-Ion/new-api/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246944389,"owners_count":20858773,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai-gateway","claude","deepseek","gemini","openai","rerank"],"created_at":"2024-09-25T23:21:19.987Z","updated_at":"2025-04-03T06:00:30.837Z","avatar_url":"https://github.com/Calcium-Ion.png","language":"Go","funding_links":["https://afdian.com/a/new-api"],"categories":["Openai"],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\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\u003ca href=\"https://trendshift.io/repositories/8227\" target=\"_blank\"\u003e\u003cimg src=\"https://trendshift.io/api/badge/repositories/8227\" alt=\"Calcium-Ion%2Fnew-api | Trendshift\" style=\"width: 250px; height: 55px;\" width=\"250\" height=\"55\"/\u003e\u003c/a\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://raw.githubusercontent.com/Calcium-Ion/new-api/main/LICENSE\"\u003e\n    \u003cimg src=\"https://img.shields.io/github/license/Calcium-Ion/new-api?color=brightgreen\" alt=\"license\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/Calcium-Ion/new-api/releases/latest\"\u003e\n    \u003cimg src=\"https://img.shields.io/github/v/release/Calcium-Ion/new-api?color=brightgreen\u0026include_prereleases\" alt=\"release\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/users/Calcium-Ion/packages/container/package/new-api\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/docker-ghcr.io-blue\" alt=\"docker\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://hub.docker.com/r/CalciumIon/new-api\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/docker-dockerHub-blue\" alt=\"docker\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://goreportcard.com/report/github.com/Calcium-Ion/new-api\"\u003e\n    \u003cimg src=\"https://goreportcard.com/badge/github.com/Calcium-Ion/new-api\" alt=\"GoReportCard\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\u003c/div\u003e\n\n## 📝 Project Description\n\n\u003e [!NOTE]  \n\u003e This is an open-source project developed based on [One API](https://github.com/songquanpeng/one-api)\n\n\u003e [!IMPORTANT]  \n\u003e - Users must comply with OpenAI's [Terms of Use](https://openai.com/policies/terms-of-use) and relevant laws and regulations. Not to be used for illegal purposes.\n\u003e - This project is for personal learning only. Stability is not guaranteed, and no technical support is provided.\n\n## ✨ Key Features\n\n1. 🎨 New UI interface (some interfaces pending update)\n2. 🌍 Multi-language support (work in progress)\n3. 🎨 Added [Midjourney-Proxy(Plus)](https://github.com/novicezk/midjourney-proxy) interface support, [Integration Guide](Midjourney.md)\n4. 💰 Online recharge support, configurable in system settings:\n    - [x] EasyPay\n5. 🔍 Query usage quota by key:\n    - Works with [neko-api-key-tool](https://github.com/Calcium-Ion/neko-api-key-tool)\n6. 📑 Configurable items per page in pagination\n7. 🔄 Compatible with original One API database (one-api.db)\n8. 💵 Support per-request model pricing, configurable in System Settings - Operation Settings\n9. ⚖️ Support channel **weighted random** selection\n10. 📈 Data dashboard (console)\n11. 🔒 Configurable model access per token\n12. 🤖 Telegram authorization login support:\n    1. System Settings - Configure Login Registration - Allow Telegram Login\n    2. Send /setdomain command to [@Botfather](https://t.me/botfather)\n    3. Select your bot, then enter http(s)://your-website/login\n    4. Telegram Bot name is the bot username without @\n13. 🎵 Added [Suno API](https://github.com/Suno-API/Suno-API) interface support, [Integration Guide](Suno.md)\n14. 🔄 Support for Rerank models, compatible with Cohere and Jina, can integrate with Dify, [Integration Guide](Rerank.md)\n15. ⚡ **[OpenAI Realtime API](https://platform.openai.com/docs/guides/realtime/integration)** - Support for OpenAI's Realtime API, including Azure channels\n16. 🧠 Support for setting reasoning effort through model name suffix:\n    - Add suffix `-high` to set high reasoning effort (e.g., `o3-mini-high`)\n    - Add suffix `-medium` to set medium reasoning effort\n    - Add suffix `-low` to set low reasoning effort\n17. 🔄 Thinking to content option `thinking_to_content` in `Channel-\u003eEdit-\u003eChannel Extra Settings`, default is `false`, when `true`, the `reasoning_content` of the thinking content will be converted to `\u003cthink\u003e` tags and concatenated to the content returned.\n18. 🔄 Model rate limit, support setting total request limit and successful request limit in `System Settings-\u003eRate Limit Settings`\n19. 💰 Cache billing support, when enabled can charge a configurable ratio for cache hits:\n    1. Set `Prompt Cache Ratio` in `System Settings -\u003e Operation Settings`\n    2. Set `Prompt Cache Ratio` in channel settings, range 0-1 (e.g., 0.5 means 50% charge on cache hits)\n    3. Supported channels:\n        - [x] OpenAI\n        - [x] Azure \n        - [x] DeepSeek\n        - [ ] Claude\n\n## Model Support\nThis version additionally supports:\n1. Third-party model **gpts** (gpt-4-gizmo-*)\n2. [Midjourney-Proxy(Plus)](https://github.com/novicezk/midjourney-proxy) interface, [Integration Guide](Midjourney.md)\n3. Custom channels with full API URL support\n4. [Suno API](https://github.com/Suno-API/Suno-API) interface, [Integration Guide](Suno.md)\n5. Rerank models, supporting [Cohere](https://cohere.ai/) and [Jina](https://jina.ai/), [Integration Guide](Rerank.md)\n6. Dify\n\nYou can add custom models gpt-4-gizmo-* in channels. These are third-party models and cannot be called with official OpenAI keys.\n\n## Additional Configurations Beyond One API\n- `GENERATE_DEFAULT_TOKEN`: Generate initial token for new users, default `false`\n- `STREAMING_TIMEOUT`: Set streaming response timeout, default 60 seconds\n- `DIFY_DEBUG`: Output workflow and node info to client for Dify channel, default `true`\n- `FORCE_STREAM_OPTION`: Override client stream_options parameter, default `true`\n- `GET_MEDIA_TOKEN`: Calculate image tokens, default `true`\n- `GET_MEDIA_TOKEN_NOT_STREAM`: Calculate image tokens in non-stream mode, default `true`\n- `UPDATE_TASK`: Update async tasks (Midjourney, Suno), default `true`\n- `GEMINI_MODEL_MAP`: Specify Gemini model versions (v1/v1beta), format: \"model:version\", comma-separated\n- `COHERE_SAFETY_SETTING`: Cohere model [safety settings](https://docs.cohere.com/docs/safety-modes#overview), options: `NONE`, `CONTEXTUAL`, `STRICT`, default `NONE`\n- `GEMINI_VISION_MAX_IMAGE_NUM`: Gemini model maximum image number, default `16`, set to `-1` to disable\n- `MAX_FILE_DOWNLOAD_MB`: Maximum file download size in MB, default `20`\n- `CRYPTO_SECRET`: Encryption key for encrypting database content\n- `AZURE_DEFAULT_API_VERSION`: Azure channel default API version, if not specified in channel settings, use this version, default `2024-12-01-preview`\n- `NOTIFICATION_LIMIT_DURATION_MINUTE`: Duration of notification limit in minutes, default `10`\n- `NOTIFY_LIMIT_COUNT`: Maximum number of user notifications in the specified duration, default `2`\n\n## Deployment\n\n\u003e [!TIP]\n\u003e Latest Docker image: `calciumion/new-api:latest`  \n\u003e Default account: root, password: 123456\n\n### Multi-Server Deployment\n- Must set `SESSION_SECRET` environment variable, otherwise login state will not be consistent across multiple servers.\n- If using a public Redis, must set `CRYPTO_SECRET` environment variable, otherwise Redis content will not be able to be obtained in multi-server deployment.\n\n### Requirements\n- Local database (default): SQLite (Docker deployment must mount `/data` directory)\n- Remote database: MySQL \u003e= 5.7.8, PgSQL \u003e= 9.6\n\n### Deployment with BT Panel\nInstall BT Panel (**version 9.2.0** or above) from [BT Panel Official Website](https://www.bt.cn/new/download.html), choose the stable version script to download and install.  \nAfter installation, log in to BT Panel and click Docker in the menu bar. First-time access will prompt to install Docker service. Click Install Now and follow the prompts to complete installation.  \nAfter installation, find **New-API** in the app store, click install, configure basic options to complete installation.  \n[Pictorial Guide](BT.md)\n\n### Docker Deployment\n\n### Using Docker Compose (Recommended)\n```shell\n# Clone project\ngit clone https://github.com/Calcium-Ion/new-api.git\ncd new-api\n# Edit docker-compose.yml as needed\n# nano docker-compose.yml\n# vim docker-compose.yml\n# Start\ndocker-compose up -d\n```\n\n#### Update Version\n```shell\ndocker-compose pull\ndocker-compose up -d\n```\n\n### Direct Docker Image Usage\n```shell\n# SQLite deployment:\ndocker run --name new-api -d --restart always -p 3000:3000 -e TZ=Asia/Shanghai -v /home/ubuntu/data/new-api:/data calciumion/new-api:latest\n\n# MySQL deployment (add -e SQL_DSN=\"root:123456@tcp(localhost:3306)/oneapi\"), modify database connection parameters as needed\n# Example:\ndocker run --name new-api -d --restart always -p 3000:3000 -e SQL_DSN=\"root:123456@tcp(localhost:3306)/oneapi\" -e TZ=Asia/Shanghai -v /home/ubuntu/data/new-api:/data calciumion/new-api:latest\n```\n\n#### Update Version\n```shell\n# Pull the latest image\ndocker pull calciumion/new-api:latest\n# Stop and remove the old container\ndocker stop new-api\ndocker rm new-api\n# Run the new container with the same parameters as before\ndocker run --name new-api -d --restart always -p 3000:3000 -e TZ=Asia/Shanghai -v /home/ubuntu/data/new-api:/data calciumion/new-api:latest\n```\n\nAlternatively, you can use Watchtower for automatic updates (not recommended, may cause database incompatibility):\n```shell\ndocker run --rm -v /var/run/docker.sock:/var/run/docker.sock containrrr/watchtower -cR\n```\n\n## Channel Retry\nChannel retry is implemented, configurable in `Settings-\u003eOperation Settings-\u003eGeneral Settings`. **Cache recommended**.  \nIf retry is enabled, the system will automatically use the next priority channel for the same request after a failed request.\n\n### Cache Configuration\n1. `REDIS_CONN_STRING`: Use Redis as cache\n    + Example: `REDIS_CONN_STRING=redis://default:redispw@localhost:49153`\n2. `MEMORY_CACHE_ENABLED`: Enable memory cache, default `false`\n    + Example: `MEMORY_CACHE_ENABLED=true`\n\n### Why Some Errors Don't Retry\nError codes 400, 504, 524 won't retry\n### To Enable Retry for 400\nIn `Channel-\u003eEdit`, set `Status Code Override` to:\n```json\n{\n  \"400\": \"500\"\n}\n```\n\n## Integration Guides\n- [Midjourney Integration](Midjourney.md)\n- [Suno Integration](Suno.md)\n\n## Related Projects\n- [One API](https://github.com/songquanpeng/one-api): Original project\n- [Midjourney-Proxy](https://github.com/novicezk/midjourney-proxy): Midjourney interface support\n- [chatnio](https://github.com/Deeptrain-Community/chatnio): Next-gen AI B/C solution\n- [neko-api-key-tool](https://github.com/Calcium-Ion/neko-api-key-tool): Query usage quota by key\n\n## 🌟 Star History\n\n[![Star History Chart](https://api.star-history.com/svg?repos=Calcium-Ion/new-api\u0026type=Date)](https://star-history.com/#Calcium-Ion/new-api\u0026Date)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcalcium-ion%2Fnew-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcalcium-ion%2Fnew-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcalcium-ion%2Fnew-api/lists"}