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

推荐订阅源

Hacker News: Ask HN
Hacker News: Ask HN
Last Week in AI
Last Week in AI
J
Java Code Geeks
V
Visual Studio Blog
The Cloudflare Blog
Hugging Face - Blog
Hugging Face - Blog
博客园_首页
宝玉的分享
宝玉的分享
博客园 - Franky
博客园 - 【当耐特】
Jina AI
Jina AI
月光博客
月光博客
T
Tailwind CSS Blog
Recent Announcements
Recent Announcements
Apple Machine Learning Research
Apple Machine Learning Research
SecWiki News
SecWiki News
H
Heimdal Security Blog
Y
Y Combinator Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Google DeepMind News
Google DeepMind News
Microsoft Security Blog
Microsoft Security Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Hacker News - Newest:
Hacker News - Newest: "LLM"
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
S
Secure Thoughts
MongoDB | Blog
MongoDB | Blog
Forbes - Security
Forbes - Security
S
SegmentFault 最新的问题
The GitHub Blog
The GitHub Blog
L
LINUX DO - 最新话题
M
MIT News - Artificial intelligence
Schneier on Security
Schneier on Security
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
O
OpenAI News
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Vercel News
Vercel News
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
S
Schneier on Security
罗磊的独立博客
Microsoft Azure Blog
Microsoft Azure Blog
爱范儿
爱范儿
C
Check Point Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
AI
AI
大猫的无限游戏
大猫的无限游戏
MyScale Blog
MyScale Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
T
Troy Hunt's Blog
T
The Blog of Author Tim Ferriss

好好学习的郝

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