惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Know Your Adversary
Know Your Adversary
阮一峰的网络日志
阮一峰的网络日志
V
Visual Studio Blog
H
Help Net Security
博客园 - Franky
博客园_首页
博客园 - 【当耐特】
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
腾讯CDC
人人都是产品经理
人人都是产品经理
T
Tailwind CSS Blog
博客园 - 三生石上(FineUI控件)
爱范儿
爱范儿
博客园 - 聂微东
小众软件
小众软件
宝玉的分享
宝玉的分享
美团技术团队
WordPress大学
WordPress大学
L
LINUX DO - 热门话题
S
Secure Thoughts
IT之家
IT之家
博客园 - 叶小钗
Apple Machine Learning Research
Apple Machine Learning Research
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
有赞技术团队
有赞技术团队
V
V2EX
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
The Cloudflare Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
量子位
G
GRAHAM CLULEY
Attack and Defense Labs
Attack and Defense Labs
Jina AI
Jina AI
罗磊的独立博客
Security Archives - TechRepublic
Security Archives - TechRepublic
W
WeLiveSecurity
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
T
Tenable Blog
L
Lohrmann on Cybersecurity
S
SegmentFault 最新的问题
J
Java Code Geeks
Last Week in AI
Last Week in AI
Cyberwarzone
Cyberwarzone
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
大猫的无限游戏
大猫的无限游戏
T
Tor Project blog
酷 壳 – CoolShell
酷 壳 – CoolShell
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
H
Heimdal Security Blog

好好学习的郝

ClawdBot(OpenClaw)试用记录 编程辅助工具 Codex 入门篇 编程辅助工具 Claude Code 入门篇 Claude API 中转服务 Claude Relay Service LLM 接口管理和分发系统 New API 好好学Git:Git Submodule详解 编程辅助工具Cursor入门篇 好好学Golang:Golang问题记录 FastAPI入门篇 好好学Docker:使用Docker安装配置AList 好好学Docker:容器指标查看工具ctop 好好学Docker:自建RustDesk Server 好好学Linux:Ubuntu18 升级到 Ubuntu22 好好学Docker:使用Docker安装配置FileBrowser 邮箱配置中的SPF、DKIM、DMARC记录 One API 开发环境配置 LLM 接口管理和分发系统 One API 好好学K8S:K8S中的Leader Election机制 好好学Golang:Viper库
One API配置自定义渠道
本文作者: 好好学习的郝 · 2025-02-09 · via 好好学习的郝

1. 前言

《LLM 接口管理和分发系统 One API》一文中,我们学习了One API的安装和基础配置。

随着One API项目不断更新,支持的渠道也越来越多。但是,有些新的渠道暂未支持或者不会支持,这时我们可以使用自定义渠道。
本文中,我们来学习一下One API自定义渠道的配置方法。

相关文档:

2. 配置并测试LLM API

以配置并测试 UCloud DeepSeek 为例,整个流程如下。

1、申请UCloud DeepSeek的使用权限

2、获取模型名称和Key

3、调用测试
参考文档:模型服务平台 UModelVerse API说明

1
2
3
4
5
6
7
8
9
10
11
12
13
14
curl --location 'https://deepseek.modelverse.cn/v1/chat/completions' \
--header 'Authorization: Bearer <你的API Key>' \
--header 'Content-Type: application/json' \
--data '{
"reasoning_effort": "low",
"stream": true,
"model": "models/DeepSeek-V3",
"messages": [
{
"role": "user",
"content": "say hello to ucloud"
}
]
}'

3. 配置自定义渠道

配置自定义渠道,与配置其他渠道最主要的差别,在于 代理(老版本中是 Base URL)需要填写自己渠道的 URL。

以配置 UCloud DeepSeek 渠道为例,整个配置如下:

  • 类型:自定义渠道
  • 名称:ucloud-deepseek
  • 分组:default
  • 代理:https://deepseek.modelverse.cn
  • 模型:deepseek-chat
  • 模型重定向:{"deepseek-chat": "models/DeepSeek-V3"}
  • 密钥:自己的密钥

配置完成后,点击测试,验证渠道是否可以正常调用。

4. 调用自定义渠道

使用curl命令测试调用自定义的 deepseek-chat 模型:

1
2
3
4
5
6
7
8
9
10
11
12
curl "https://oneapi.voidking.com/v1/chat/completions" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <ONE_API_KEY>" \
-d '{
"model": "deepseek-chat",
"messages": [
{
"role": "user",
"content": "hello!"
}
]
}'

如果想要使用 python 测试调用自定义的 deepseek-chat 模型,那么可以参考文档《LLM 接口管理和分发系统 One API》

5. 自定义渠道 + Nginx代理

在配置 UCloud DeepSeek时,比较简单,代理直接填写 UCloud 官方给的域名就可以了。
这是因为UCloud官方的 LLM API 路径刚好和 OneAPI 的规范匹配,是 /v1/chat/completions
如果某个渠道的 LLM API 路径不是 /v1/chat/completions,那么就需要配合 Nginx代理 来进行配置了。

已知潞晨云的LLM API URL为:

1
https://cloud.luchentech.com/api/maas/chat/completions

那么在OneAPI中自定义渠道配置代理时,是不能直接填入 https://cloud.luchentech.com 这个地址的,需要借助Nginx。

原理:通过Nginx代理,将 /api/maas/chat/completions 转换成 /v1/chat/completions

Nginx配置示例:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
server {
listen 80;
listen 443 ssl;
server_name luchen.voidking.com;
charset utf-8;

ssl_certificate /etc/letsencrypt/live/voidking.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/voidking.com/privkey.pem;
ssl_session_timeout 5m;
ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!ADH:!EXPORT56:RC4+RSA:+MEDIUM;
ssl_prefer_server_ciphers on;

if ($ssl_protocol = "") {
return 301 https://$host$request_uri;
}

location /v1/chat/completions {
proxy_pass https://cloud.luchentech.com/api/maas/chat/completions;
proxy_set_header Host cloud.luchentech.com;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;

proxy_connect_timeout 60s;
proxy_send_timeout 60s;
proxy_read_timeout 60s;

# WebSocket support
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}

配置完成后,在OneAPI中自定义渠道配置代理时,填入 https://luchen.voidking.com