AI Personal Learning
and practical guidance

One API: Multi-model API Management and Load Balancing, Distribution System

General Introduction

One API is an open source interface management and distribution system that supports a variety of big models like OpenAI ChatGPT, Anthropic Claude, Google PaLM 2 & Gemini etc. The system accesses all big models through the standard OpenAI API format, providing load balancing, token management, redemption code management, channel management and other functions. Users can quickly deploy and utilize One API out-of-the-box via Docker.

New API A secondary development version based on One API with support for Midjourney. support for payments and per-model-use charges.

one api branch: changed from songquanpeng/one-api. support more models, add statistics page, improve function call for non-openai models.

One API: Multi-Model API Management and Load Balancing, Distribution System-1


 

Function List

  • API interfaces to access and manage multiple big models: Azure, OpenAI ChatGPT, Anthropic Claude, Google PaLM 2 & Gemini, etc.
  • Provide load balancing function to support multiple channels of access
  • Single API to integrate different language model interfaces
  • Token Management: Set token expiration time, amount, allowed IP ranges, and model access rights
  • Redemption code management: batch generate and export redemption codes to top up accounts
  • Channel management: batch create channels, set up model lists
  • User grouping and channel grouping management
  • View limit details and user invitation rewards
  • Support for mapping interfaces and Cloudflare AI Gateway
  • Customize system name, logo and footer
  • Support multiple user login registration methods: email, Flybook, GitHub, WeChat public number
  • Docker image support for one-click deployment

 

Using Help

Installation and Deployment

The One API supports rapid deployment via Docker. The following deployment commands use SQLite and MySQL:

Deployment commands using SQLite:

docker run --name one-api -d --restart always -p 3000:3000 -e TZ=Asia/Shanghai -v /home/ubuntu/data/one-api:/data justsong/one-api

Use the MySQL deploy command:

docker run --name one-api -d --restart always -p 3000:3000 -e SQL_DSN="root:123456@tcp(localhost:3306)/oneapi" -e TZ=Asia/Shanghai -v /home/ubuntu/data/one-api:/data justsong/one-api

Please modify the database connection parameters as necessary.

Function Operation Guide

  1. token management: In the management interface, users can set the token's expiration time, amount, allowed IP range, and model access rights.
  2. Redemption Code Management: Supports batch generation and export of redemption codes, which can be used by users to top up their accounts.
  3. channel management: Users can create channels in bulk and set up model lists for different channels.
  4. User Grouping and Channel Grouping: Supports setting different multipliers for different groups for easy management.
  5. View Line Breakdown: Users can view detailed credit utilization.
  6. User Invitation Rewards: Earn reward credits by inviting new users.
  7. Customized settings: Users can customize the system name, logo and footer, and even the home page and about page.

usage example

Users can call the One API with the following sample code:

import requests

url = "http://localhost:3000/v1/completions"
headers = {
    "Authorization": "Bearer YOUR_API_KEY",
    "Content-Type": "application/json"
}
data = {
    "model": "gpt-3.5-turbo",
    "prompt": "Hello, world!",
    "max_tokens": 50
}

response = requests.post(url, headers=headers, json=data)
print(response.json())
AI Easy Learning

The layman's guide to getting started with AI

Help you learn how to utilize AI tools at a low cost and from a zero base.AI, like office software, is an essential skill for everyone. Mastering AI will give you an edge in your job search and half the effort in your future work and studies.

View Details>
May not be reproduced without permission:Chief AI Sharing Circle " One API: Multi-model API Management and Load Balancing, Distribution System

Chief AI Sharing Circle

Chief AI Sharing Circle specializes in AI learning, providing comprehensive AI learning content, AI tools and hands-on guidance. Our goal is to help users master AI technology and explore the unlimited potential of AI together through high-quality content and practical experience sharing. Whether you are an AI beginner or a senior expert, this is the ideal place for you to gain knowledge, improve your skills and realize innovation.

Contact Us
en_USEnglish