AI Personal Learning
and practical guidance

Deploying OneAPI without servers? | OneAPI Deployment User Guide

preamble

 

Some time ago, I hoarded some APIs in my hand, which I don't use much, mainly for the AI summary function of the blog. My brain often forgets the account passwords of these platforms, which made me decide to use OneAPI for unified management. Despite the thorough tutorials provided by the authors of OneAPI, some users (including myself) encountered a few hiccups when deploying it. Therefore, after a successful deployment, I decided to write this detailed deployment guide for those who are not well versed in the basics.


 

 

Projects

 

OneAPI project is an open interface management and distribution system that supports a variety of large-scale language models such as OpenAI's ChatGPT, Azure, Anthropic Claude, Google PaLM 2 & Gemini etc. It is intended for key management and redistribution, can be deployed via a single executable or Docker, and provides a simple and unified API to access different large language models. The system is open source, under the MIT license, and provides features such as model support, token management, and user group management. For deployment and configuration instructions, users should refer to the project's GitHub repositories and documentation

 

 

Project Build

 

This project provides Docker images to simplify the deployment process. We can deploy more easily.

By default, a SQLite database is used, and if the SQL_DSN environment variable is not set, the database files are stored in the path specified by the Docker container. If the SQL_DSN environment variable is set, the application will connect to the MySQL or PostgreSQL database you specify. This is so that our previous changes are not lost when we redeploy or pull the image.

 

intend

  • Free container platforms that support Docker, such as Render or Zeabur.
  • MySQL or PostgreSQL database (optional, recommended for data persistence).
  • A domain name (optional).

 

Deployment steps

  • Hugging Face : Fast but does not support bound domain names, domestic access may be limited.
  • Render : Bundled domains are supported, registration may require a bundled credit card.
  • Koyeb : Bundled domains are supported, upgrade plan required.
  • Zeabur : Fast access, Chinese support, Docker image deployment requires an upgrade plan.

 

Deployment process

huggingface Deployment

 

1. Copy the Docker image

click on a buttonOne-click Mirror Copy ,Configure THEME (interface theme such as default or berry) and SQL_DSN (database connection). I will list them in detail below.

Deploying OneAPI without a server? | OneAPI Deployment User Guide-1

 

The effects of the different themes are as follows, pick according to your preference.

 

Default Theme

Deploying OneAPI without a server? | OneAPI Deployment User Guide-2

 

berry Theme

Deploying OneAPI without a server? | OneAPI Deployment User Guide-3

 

2. Database configuration

  • Use a free database service such as aiven or Planetscale, or the free databases that come with Render and Koyeb; configure the environment variable SQL_DSN for the project.
  • MySQL Example. SQL_DSN=root:123456@tcp(localhost:3306)/oneapi
  • PostgreSQL Examples. SQL_DSN=postgres://postgres:123456@localhost:5432/oneapi

 

2.1register and log inWe're in. aiven platform, register or log in to your account.

Deploying OneAPI without a server? | OneAPI Deployment User Guide-4

 

2.2Fill in the informationSelect Personal Services and fill in the basic information.

Deploying OneAPI without a server? | OneAPI Deployment User Guide-5

 

2.3Select databaseSelect MySQL database or PostgreSQL database.

Deploying OneAPI without a server? | OneAPI Deployment User Guide-6

 

2.4Database ConfigurationCheck the free plan, select the service area, and finally click Create.

Deploying OneAPI without a server? | OneAPI Deployment User Guide-7

 

2.5Final configurationMemorize the information in the chart and tap skip all the way through. It doesn't matter if you don't memorize them, we can see them after skipping them all.

Deploying OneAPI without a server? | OneAPI Deployment User Guide-8

 

3. Fill in the variables

 

Based on the database information in the figure we get this:

Service URI.
mysql://CLICK_TO:REVEAL_PASSWORD@mysql-12a9c26-jonastech007-2d92.b.aivencloud.com:10906/defaultdb?ssl-mode=必需

Host.
mysql-12a9c26-jonastech007-2d92.b.aivencloud.com

Port.
10906

Users:
avnadmin

Password:
AVNS_QV8niFI8YW48vKqxi3R

Our link address should be written like this: username:password@tcp(Host:Port)/database name

We ended up with avnadmin:AVNS_QV8niFI8YW48vKqxi3R@tcp(mysql-12a9c26-jonastech007-2d92.b.aivencloud.com:10906)/defaultdb

Fill this link into the variable and finally click copy to space Duplicate Space

Deploying OneAPI without a server? | OneAPI Deployment User Guide-9

 

Deploying OneAPI without a server? | OneAPI Deployment User Guide-10

 

 

4. Access

 

At this point we can find the settings by clicking on the top right corner of theEmbed this SpaceAccess to our services is provided through the link below.

Deploying OneAPI without a server? | OneAPI Deployment User Guide-11

 

Deploying OneAPI without a server? | OneAPI Deployment User Guide-12

 

Koyeb deployment

 

1. Click to enterKoyeb After logging in and registering on the official website, click Create Web Service to select the docker image.

Deploying OneAPI without a server? | OneAPI Deployment User Guide-13

 

Deploying OneAPI without a server? | OneAPI Deployment User Guide-14

 

2. In the input box, type justsong/one-api:latest , if you don't know where this comes from, you can check the open source project'scompose.ymlThe

version: '3.4'

services.
one-api.
image: "${REGISTRY:-docker.io}/justsong/one-api:latest"
container_name: one-api
restart: always
command: --log-dir /app/logs
ports.
- "3000:3000"
volumes.
- . /data/oneapi:/data
- . /logs:/app/logs
environment.
- SQL_DSN=oneapi:123456@tcp(db:3306)/one-api # Modify this line or comment it out to use SQLite as the database
- REDIS_CONN_STRING=redis://redis
- SESSION_SECRET=random_string # Modify to random string
- TZ=Asia/Shanghai
# - NODE_TYPE=slave # Uncomment this line for slave nodes in multicomputer deployments
# - SYNC_FREQUENCY=60 # Uncomment this line if you need to periodically load data from the database

 

${REGISTRY:-docker.io} is an environment variable expression indicating that if the environment variable REGISTRY is not set, the default docker.io (Docker Hub) is used.
justsong/one-api:latest specifies the name and label of the image, where justsong is the name of the user or organization on the Docker Hub, one-api is the image name, and latest indicates that the latest version of this image is used.

Deploying OneAPI without a server? | OneAPI Deployment User Guide-15

 

3. Set the necessary variables and region information and click the Deploy button.

Deploying OneAPI without a server? | OneAPI Deployment User Guide-16

 

4. Waiting for the deployment to complete, we can click on this address to access our One API.

Deploying OneAPI without a server? | OneAPI Deployment User Guide-17

 

Deploying OneAPI without a server? | OneAPI Deployment User Guide-18

 

5. The default administrator account is

  • Username:root
  • Password:123456

Changes should be made in Users immediately after logging in, thus securing the account

Deploying OneAPI without a server? | OneAPI Deployment User Guide-19

 

 

Usage

 

Considering that most of the people who can read my post are newbies, I'll briefly demonstrate its usage. The free API introduced in the above blog postbe on fire Examples.

For those who are not impressed by this, you can find out for yourself, or watch the This blog post

 

OneAPI Configuration

 

1. After logging in to your OneAPI administrator account, locate theirrigation ditch, clickNew channels

Deploying OneAPI without a server? | OneAPI Deployment User Guide-20

 

2. channel name we can name, channel API address is the forwarding address, just fill in its request address, and then select the model of support; add your API KEY, and finally submit.

Deploying OneAPI without a server? | OneAPI Deployment User Guide-21

 

Deploying OneAPI without a server? | OneAPI Deployment User Guide-22

 

3. Finally we click untested , measure the connectivity of the API.

Deploying OneAPI without a server? | OneAPI Deployment User Guide-23

 

Deploying OneAPI without a server? | OneAPI Deployment User Guide-24

 

4. After completing the test, we will be able totokenIf you want, you can also share your site after adding many APIs for everyone to use. If you want to you can also share your site after adding many APIs and let people use them.
We just need to maintain each API channel in the background, as for our OneAPI request address, it is our domain name by default, you can also change it in the settings.

Deploying OneAPI without a server? | OneAPI Deployment User Guide-25

 

Deploying OneAPI without a server? | OneAPI Deployment User Guide-26

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 " Deploying OneAPI without servers? | OneAPI Deployment User Guide

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