How to Deploy OneAPI for Unified Large‑Model Access (AI Code Review Tutorial 13)

This article explains why enterprises need a single gateway for multiple large‑model services, introduces the open‑source OneAPI tool and its features, and provides step‑by‑step Docker installation, UI setup, channel and token configuration, optional Nginx proxy, and integration into an AI code‑review project.

Ubiquitous Tech
Ubiquitous Tech
Ubiquitous Tech
How to Deploy OneAPI for Unified Large‑Model Access (AI Code Review Tutorial 13)

When building AI code‑review and related AI applications in an enterprise, teams often need to connect to various large‑model providers, private deployments, and fine‑tuned models. Without a unified access point each team must write its own integration code, manage tokens separately, and handle load‑balancing manually, which increases development effort and operational complexity.

OneAPI (GitHub: https://github.com/songquanpeng/one-api) is an open‑source gateway that offers an OpenAI‑compatible interface and supports multiple large models, third‑party proxy services, load‑balancing, streaming mode, multi‑node deployment, token management, channel management, model mapping, quota display, user groups, and more. As of 2025‑06‑11 it has earned 25.6K stars, indicating broad community adoption.

Installation can be performed via Docker. The basic command is:

docker run --name one-api -d --restart always \
  -p 3000:3000 \
  --privileged=true \
  -e TZ=Asia/Shanghai \
  -v /soft/docker/oneapi:/data \
  justsong/one-api

If the Docker image cannot be pulled, a registry‑mirror configuration can be added, for example:

{
  "registry-mirrors": [
    "https://docker.m.daocloud.io",
    "https://docker.jianmuhub.com",
    "https://huecker.io",
    "https://dockerhub.timeweb.cloud",
    "https://dockerhub1.beget.com",
    "https://noohub.ru"
  ]
}

After the container starts, the UI is reachable at http://localhost:3000. The default login credentials are root/123456. From the UI you can add channels (e.g., Zhihu AI, Ollama), configure model name redirection, and create tokens with specific quotas, expiration times, IP whitelists, and model access permissions.

Token management lets you set expiration, quota limits, allowed IP ranges, and associate tokens with particular models, enabling centralized control of large‑scale token usage across the organization.

For external access, you can place an Nginx reverse‑proxy in front of OneAPI. A minimal server block is:

server {
  server_name openai.justsong.cn; # adjust to your domain
  location / {
    client_max_body_size 64m;
    proxy_http_version 1.1;
    proxy_pass http://localhost:3000; # adjust port if needed
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-For $remote_addr;
    proxy_cache_bypass $http_upgrade;
    proxy_set_header Accept-Encoding gzip;
    proxy_read_timeout 300s; # increase for GPT‑4
  }
}

To integrate OneAPI into the AI code‑review project, replace the original model endpoint with the OneAPI address, e.g., change the request URL to http://oneapi_address:3000/v1/chat/completions (or http://oneapi_address:3000/v1 for generic calls). After updating the configuration, the project successfully routes all model requests through OneAPI, benefiting from unified token handling and model name redirection.

In summary, OneAPI provides a single, configurable gateway that unifies access to diverse large‑model services, centralizes token and channel management, supports load‑balancing and streaming, and simplifies integration for enterprise AI applications such as code review.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Dockerlarge language modelsNginxAI code reviewtoken managementOneAPImodel routing
Ubiquitous Tech
Written by

Ubiquitous Tech

A ubiquitous public account for pirate enthusiasts, regularly sharing curated experiences, tech learning, and growth insights. Currently publishing articles on AI RAG customer service, AI MCP technology, and open-source design. Personal free Knowledge Planet: Awakening New World Programmer.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.