Sem descrição

Apple\Apple 1c67dd3c31 📕docs: Update the content in `README.en.md` and the structure of the docs directory há 10 meses atrás
.github 6187656aa9 chore: Update GitHub Actions workflows and refactor adaptor logic for Docker image builds há 11 meses atrás
bin d84b0b0f5d chore: add model parameter to the time_test script (#245) há 2 anos atrás
common 32cd890b6e feat: 增加sendcloud邮件服务器的支持 (#947) há 10 meses atrás
constant fd6838e690 feat: enable error logging configuration in docker-compose and application há 10 meses atrás
controller 425feb88d8 feat: support /v1/responses API há 10 meses atrás
docs 1c67dd3c31 📕docs: Update the content in `README.en.md` and the structure of the docs directory há 10 meses atrás
dto 48af027903 Merge pull request #1020 from QuantumNous/v1responses há 10 meses atrás
middleware a03c615fa4 Merge remote-tracking branch 'new-api/main' into gpt-image há 10 meses atrás
model da6423de33 refactor: Reducing the lock duration to the minimum necessary time in CacheGetRandomSatisfiedChannel function há 10 meses atrás
relay 419a056fbf refactor: remove unnecessary call to helper.Done and adjust data rendering in ClaudeChunkData há 10 meses atrás
router 425feb88d8 feat: support /v1/responses API há 10 meses atrás
service e097d5a538 feat: add video URL support in MediaContent and update token counting logic há 10 meses atrás
setting fe37718259 fix: update audio ratio logic for model names in GetAudioRatio function há 10 meses atrás
web 3def2bbd30 fix: EditUser text error há 10 meses atrás
.dockerignore 006bc37231 refactor: access_token auth há 1 ano atrás
.env.example bf80d71ddf feat: Add Gemini version settings configuration support (close #568) há 1 ano atrás
.gitignore 75570af967 chore: update .gitignore and docker-compose.yml to include tiktoken_cache directory há 11 meses atrás
Dockerfile 81591f20e0 refactor: Optimize Dockerfile for Go build process há 1 ano atrás
LICENSE fcb8506679 Update LICENSE há 1 ano atrás
README.en.md 1c67dd3c31 📕docs: Update the content in `README.en.md` and the structure of the docs directory há 10 meses atrás
README.md 1c67dd3c31 📕docs: Update the content in `README.en.md` and the structure of the docs directory há 10 meses atrás
VERSION 7e80e2da3a fix: add a blank VERSION file (#135) há 2 anos atrás
docker-compose.yml fd6838e690 feat: enable error logging configuration in docker-compose and application há 10 meses atrás
go.mod bd48f43410 feat: claude relay há 1 ano atrás
go.sum c433af284c feat: add oidc support há 1 ano atrás
main.go e097d5a538 feat: add video URL support in MediaContent and update token counting logic há 10 meses atrás
makefile 6e54f01435 update makefile há 1 ano atrás
one-api.service c6717307d0 chore: update one-api.service há 2 anos atrás

README.en.md

中文 | English

new-api

New API

🍥 Next-Generation Large Model Gateway and AI Asset Management System

<img src="https://img.shields.io/github/license/Calcium-Ion/new-api?color=brightgreen" alt="license">

<img src="https://img.shields.io/github/v/release/Calcium-Ion/new-api?color=brightgreen&include_prereleases" alt="release">

<img src="https://img.shields.io/badge/docker-ghcr.io-blue" alt="docker">

<img src="https://img.shields.io/badge/docker-dockerHub-blue" alt="docker">

<img src="https://goreportcard.com/badge/github.com/Calcium-Ion/new-api" alt="GoReportCard">

📝 Project Description

[!NOTE]
This is an open-source project developed based on One API

[!IMPORTANT]

📚 Documentation

For detailed documentation, please visit our official Wiki: https://docs.newapi.pro/

✨ Key Features

New API offers a wide range of features, please refer to Features Introduction for details:

  1. 🎨 Brand new UI interface
  2. 🌍 Multi-language support
  3. 💰 Online recharge functionality (YiPay)
  4. 🔍 Support for querying usage quotas with keys (works with neko-api-key-tool)
  5. 🔄 Compatible with the original One API database
  6. 💵 Support for pay-per-use model pricing
  7. ⚖️ Support for weighted random channel selection
  8. 📈 Data dashboard (console)
  9. 🔒 Token grouping and model restrictions
  10. 🤖 Support for more authorization login methods (LinuxDO, Telegram, OIDC)
  11. 🔄 Support for Rerank models (Cohere and Jina), API Documentation
  12. ⚡ Support for OpenAI Realtime API (including Azure channels), API Documentation
  13. ⚡ Support for Claude Messages format, API Documentation
  14. Support for entering chat interface via /chat2link route
  15. 🧠 Support for setting reasoning effort through model name suffixes:
    1. OpenAI o-series models
      • Add -high suffix for high reasoning effort (e.g.: o3-mini-high)
      • Add -medium suffix for medium reasoning effort (e.g.: o3-mini-medium)
      • Add -low suffix for low reasoning effort (e.g.: o3-mini-low)
    2. Claude thinking models
      • Add -thinking suffix to enable thinking mode (e.g.: claude-3-7-sonnet-20250219-thinking)
  16. 🔄 Thinking-to-content functionality
  17. 🔄 Model rate limiting for users
  18. 💰 Cache billing support, which allows billing at a set ratio when cache is hit:
    1. Set the Prompt Cache Ratio option in System Settings-Operation Settings
    2. Set Prompt Cache Ratio in the channel, range 0-1, e.g., setting to 0.5 means billing at 50% when cache is hit
    3. Supported channels:
      • OpenAI
      • Azure
      • DeepSeek
      • Claude

Model Support

This version supports multiple models, please refer to API Documentation-Relay Interface for details:

  1. Third-party models gpts (gpt-4-gizmo-*)
  2. Third-party channel Midjourney-Proxy(Plus) interface, API Documentation
  3. Third-party channel Suno API interface, API Documentation
  4. Custom channels, supporting full call address input
  5. Rerank models (Cohere and Jina), API Documentation
  6. Claude Messages format, API Documentation
  7. Dify, currently only supports chatflow

Environment Variable Configuration

For detailed configuration instructions, please refer to Installation Guide-Environment Variables Configuration:

  • GENERATE_DEFAULT_TOKEN: Whether to generate initial tokens for newly registered users, default is false
  • STREAMING_TIMEOUT: Streaming response timeout, default is 60 seconds
  • DIFY_DEBUG: Whether to output workflow and node information for Dify channels, default is true
  • FORCE_STREAM_OPTION: Whether to override client stream_options parameter, default is true
  • GET_MEDIA_TOKEN: Whether to count image tokens, default is true
  • GET_MEDIA_TOKEN_NOT_STREAM: Whether to count image tokens in non-streaming cases, default is true
  • UPDATE_TASK: Whether to update asynchronous tasks (Midjourney, Suno), default is true
  • COHERE_SAFETY_SETTING: Cohere model safety settings, options are NONE, CONTEXTUAL, STRICT, default is NONE
  • GEMINI_VISION_MAX_IMAGE_NUM: Maximum number of images for Gemini models, default is 16
  • MAX_FILE_DOWNLOAD_MB: Maximum file download size in MB, default is 20
  • CRYPTO_SECRET: Encryption key used for encrypting database content
  • AZURE_DEFAULT_API_VERSION: Azure channel default API version, default is 2024-12-01-preview
  • NOTIFICATION_LIMIT_DURATION_MINUTE: Notification limit duration, default is 10 minutes
  • NOTIFY_LIMIT_COUNT: Maximum number of user notifications within the specified duration, default is 2

Deployment

For detailed deployment guides, please refer to Installation Guide-Deployment Methods:

[!TIP] Latest Docker image: calciumion/new-api:latest

Multi-machine Deployment Considerations

  • Environment variable SESSION_SECRET must be set, otherwise login status will be inconsistent across multiple machines
  • If sharing Redis, CRYPTO_SECRET must be set, otherwise Redis content cannot be accessed across multiple machines

Deployment Requirements

  • Local database (default): SQLite (Docker deployment must mount the /data directory)
  • Remote database: MySQL version >= 5.7.8, PgSQL version >= 9.6

Deployment Methods

Using BaoTa Panel Docker Feature

Install BaoTa Panel (version 9.2.0 or above), find New-API in the application store and install it. Tutorial with images

Using Docker Compose (Recommended)

# Download the project
git clone https://github.com/Calcium-Ion/new-api.git
cd new-api
# Edit docker-compose.yml as needed
# Start
docker-compose up -d

Using Docker Image Directly

# Using SQLite
docker 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

# Using MySQL
docker 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

Channel Retry and Cache

Channel retry functionality has been implemented, you can set the number of retries in Settings->Operation Settings->General Settings. It is recommended to enable caching.

Cache Configuration Method

  1. REDIS_CONN_STRING: Set Redis as cache
  2. MEMORY_CACHE_ENABLED: Enable memory cache (no need to set manually if Redis is set)

API Documentation

For detailed API documentation, please refer to API Documentation:

Related Projects

Other projects based on New API:

  • new-api-horizon: High-performance optimized version of New API
  • VoAPI: Frontend beautified version based on New API

Help and Support

If you have any questions, please refer to Help and Support:

🌟 Star History

Star History Chart