基于docker搭建CLIProxyAPI图文教程

2026-04-11 14:021阅读0评论SEO教程
  • 内容介绍
  • 相关推荐
问题描述:

本文作者:猫猫摸大鱼

1. 前言

本文隶属于 OpenClaw龙虾系列教程文章,建议按顺序阅读,可以访问OpenClaw龙虾系列教程文章目录 https://iloli.love/archives/1766849996690 查看其它文章,本文也可单独作为 CLIProxyAPI 搭建教程文章阅读

本文基于CLIProxyAPI v6.8.24版本,Github地址为 https://github.com/router-for-me/CLIProxyAPI

CLIProxyAPI 能够将 GeminiCLI , ClaudeCode 等转换为不仅限于原客户端使用的API,从而供给OpenClaw或其它客户端使用

该项目有更多玩法,本文只赘述其中一部分,其他请自行探索

本系列教程全程使用腾讯云轻量应用服务器,可以参加腾讯云OpenClaw专属活动进行购买,新客68/年起,老客99/年起

活动链接 https://cloud.tencent.com/act/pro/lighthouse-moltbot (无AFF)

就算不买也强烈推荐使用有 快照 功能的厂商的服务器进行搭建,并且一定要经常打快照,不要问为什么,血的教训,血的教训,血的教训

1905×908 246 KB

1905×924 83.1 KB

2. 搭建

首先选择一个目录,本文中使用的是/data/CLIProxyAPI

运行 mkdir -p /data/CLIProxyAPI && touch /data/CLIProxyAPI/config.yaml ,创建项目配置文件

1129×270 13.9 KB

复制以下项目配置,将 secret-key 修改为你的密码

# Server host/interface to bind to. Default is empty ("") to bind all interfaces (IPv4 + IPv6). # Use "127.0.0.1" or "localhost" to restrict access to local machine only. host: "" # Server port port: 8317 # TLS settings for HTTPS. When enabled, the server listens with the provided certificate and key. tls: enable: false cert: "" key: "" # Management API settings remote-management: # Whether to allow remote (non-localhost) management access. # When false, only localhost can access management endpoints (a key is still required). allow-remote: true # Management key. If a plaintext value is provided here, it will be hashed on startup. # All management requests (even from localhost) require this key. # Leave empty to disable the Management API entirely (404 for all /v0/management routes). secret-key: "loginpassword" # Disable the bundled management control panel asset download and HTTP route when true. disable-control-panel: false # GitHub repository for the management control panel. Accepts a repository URL or releases API URL. panel-github-repository: "https://github.com/router-for-me/Cli-Proxy-API-Management-Center" # Authentication directory (supports ~ for home directory) auth-dir: "~/.cli-proxy-api"

粘贴到刚刚新建的 config.yaml 里

923×501 35 KB

然后运行 mkdir -p /data/CLIProxyAPI && touch /data/CLIProxyAPI/compose.yaml ,创建docker compose文件

1161×296 16.8 KB

复制以下docker compose 配置

services: cli-proxy-api: image: eceasy/cli-proxy-api:latest container_name: cli-proxy-api ports: - "8317:8317" volumes: - ./config.yaml:/CLIProxyAPI/config.yaml - ./auths:/root/.cli-proxy-api restart: unless-stopped

粘贴到刚刚新建的 compose.yaml 里

550×312 10.7 KB

运行如下命令 cd /data/CLIProxyAPI && docker compose up -d ,创建容器,如图即为成功

1597×415 21.4 KB

3. 配置

接下来访问 服务器IP:8317/management.html ,进入后台管理页(如果你修改了端口则替换为你的端口),输入你在前面配置的密码,登录

1920×927 74.8 KB

进入后台主页

1920×929 55.3 KB

本文以对接Qwen作为教程,其它大同小异,请自行研究

点击 OAuth 登录

1920×929 71.7 KB

下拉到 Qwen OAuth ,点击登录,等待链接出现后,复制链接到浏览器打开,或者点击 打开链接 按钮

1920×929 77.8 KB

登录千问账号

1920×927 38.6 KB

千问显示认证成功

1920×927 24 KB

回到项目后台,也可以看到认证成功

1920×929 73.3 KB

接下来添加 API 密钥,点击配置面板,下拉到认证配置处,点击添加 API 密钥

1920×929 74.8 KB

可自定义或随机生成一个 API 密钥,点击添加

1920×927 89.1 KB

可以看到我们刚刚添加的 API 密钥,点击下方的对号,保存更改

1920×929 76.8 KB

点击确认保存

1920×927 89.7 KB

4. 使用

到此已经完成,可以使用该密钥了,BaseURL 即为你的服务器IP:项目端口,本项目能提供标准的OpenAI API和Claude API,这里就不过多赘述了

网友解答:
--【壹】--:

目前除了qwen其他的 OAuth 登录 都失败,佬有遇到一样的问题嘛


--【贰】--:

哦哦 是回错人了


--【叁】--:

这也太详细了,买了腾讯云,这个CLIProxyAPI代理是不是直接放到腾讯云,然后我本地可以访问哇,佬友


--【肆】--:

转载
还是就是转自己啊


--【伍】--:

你是不是回错人了,我不是楼主
肯定可以啊,嗯?你本地机器都不联网的?


--【陆】--:

转载的,原作者头像和我一样,昵称和我一样,网站和我一样


--【柒】--:

太强了大佬!


--【捌】--:

你说外网啊,我还以为你是没有公网的,境内机器也能用,富强或者用socks代理就行了


--【玖】--:

外网没鸡 用梯子行不行 就自己用


--【拾】--:

佬 我在自己家里的机器上部署行不行?还是说要能连上外网的机器


--【拾壹】--:

你是不是用的大陆的服务器


--【拾贰】--:

肯定要连外网啊,不然你本地自建大模型吗?


--【拾叁】--:

想问问佬友 是不是最好买海外地域的套餐呢?


--【拾肆】--:

反手一个关注


--【拾伍】--: miaowmint:

下拉到 Qwen OAuth ,点击登录,等待链接出现后,复制链接到浏览器打开,或者点击打开链接按钮

佬我到这一步就进行不下去了,我这里复制的用的gpt授权认证,提示“网络无法访问”,但是我这边可以正常登录的(本地挂了梯子)。是不是复制的链接是国内的服务器的问题。我看日志报错是地区限制了。


--【拾陆】--:

感谢猫猫教程


--【拾柒】--:

太强辣!!!


--【拾捌】--:


转载要正确使用tag的,之前还发生过被追到站里的情况,自己的就随意了


--【拾玖】--:

刚部署完,没赶上佬有教程

问题描述:

本文作者:猫猫摸大鱼

1. 前言

本文隶属于 OpenClaw龙虾系列教程文章,建议按顺序阅读,可以访问OpenClaw龙虾系列教程文章目录 https://iloli.love/archives/1766849996690 查看其它文章,本文也可单独作为 CLIProxyAPI 搭建教程文章阅读

本文基于CLIProxyAPI v6.8.24版本,Github地址为 https://github.com/router-for-me/CLIProxyAPI

CLIProxyAPI 能够将 GeminiCLI , ClaudeCode 等转换为不仅限于原客户端使用的API,从而供给OpenClaw或其它客户端使用

该项目有更多玩法,本文只赘述其中一部分,其他请自行探索

本系列教程全程使用腾讯云轻量应用服务器,可以参加腾讯云OpenClaw专属活动进行购买,新客68/年起,老客99/年起

活动链接 https://cloud.tencent.com/act/pro/lighthouse-moltbot (无AFF)

就算不买也强烈推荐使用有 快照 功能的厂商的服务器进行搭建,并且一定要经常打快照,不要问为什么,血的教训,血的教训,血的教训

1905×908 246 KB

1905×924 83.1 KB

2. 搭建

首先选择一个目录,本文中使用的是/data/CLIProxyAPI

运行 mkdir -p /data/CLIProxyAPI && touch /data/CLIProxyAPI/config.yaml ,创建项目配置文件

1129×270 13.9 KB

复制以下项目配置,将 secret-key 修改为你的密码

# Server host/interface to bind to. Default is empty ("") to bind all interfaces (IPv4 + IPv6). # Use "127.0.0.1" or "localhost" to restrict access to local machine only. host: "" # Server port port: 8317 # TLS settings for HTTPS. When enabled, the server listens with the provided certificate and key. tls: enable: false cert: "" key: "" # Management API settings remote-management: # Whether to allow remote (non-localhost) management access. # When false, only localhost can access management endpoints (a key is still required). allow-remote: true # Management key. If a plaintext value is provided here, it will be hashed on startup. # All management requests (even from localhost) require this key. # Leave empty to disable the Management API entirely (404 for all /v0/management routes). secret-key: "loginpassword" # Disable the bundled management control panel asset download and HTTP route when true. disable-control-panel: false # GitHub repository for the management control panel. Accepts a repository URL or releases API URL. panel-github-repository: "https://github.com/router-for-me/Cli-Proxy-API-Management-Center" # Authentication directory (supports ~ for home directory) auth-dir: "~/.cli-proxy-api"

粘贴到刚刚新建的 config.yaml 里

923×501 35 KB

然后运行 mkdir -p /data/CLIProxyAPI && touch /data/CLIProxyAPI/compose.yaml ,创建docker compose文件

1161×296 16.8 KB

复制以下docker compose 配置

services: cli-proxy-api: image: eceasy/cli-proxy-api:latest container_name: cli-proxy-api ports: - "8317:8317" volumes: - ./config.yaml:/CLIProxyAPI/config.yaml - ./auths:/root/.cli-proxy-api restart: unless-stopped

粘贴到刚刚新建的 compose.yaml 里

550×312 10.7 KB

运行如下命令 cd /data/CLIProxyAPI && docker compose up -d ,创建容器,如图即为成功

1597×415 21.4 KB

3. 配置

接下来访问 服务器IP:8317/management.html ,进入后台管理页(如果你修改了端口则替换为你的端口),输入你在前面配置的密码,登录

1920×927 74.8 KB

进入后台主页

1920×929 55.3 KB

本文以对接Qwen作为教程,其它大同小异,请自行研究

点击 OAuth 登录

1920×929 71.7 KB

下拉到 Qwen OAuth ,点击登录,等待链接出现后,复制链接到浏览器打开,或者点击 打开链接 按钮

1920×929 77.8 KB

登录千问账号

1920×927 38.6 KB

千问显示认证成功

1920×927 24 KB

回到项目后台,也可以看到认证成功

1920×929 73.3 KB

接下来添加 API 密钥,点击配置面板,下拉到认证配置处,点击添加 API 密钥

1920×929 74.8 KB

可自定义或随机生成一个 API 密钥,点击添加

1920×927 89.1 KB

可以看到我们刚刚添加的 API 密钥,点击下方的对号,保存更改

1920×929 76.8 KB

点击确认保存

1920×927 89.7 KB

4. 使用

到此已经完成,可以使用该密钥了,BaseURL 即为你的服务器IP:项目端口,本项目能提供标准的OpenAI API和Claude API,这里就不过多赘述了

网友解答:
--【壹】--:

目前除了qwen其他的 OAuth 登录 都失败,佬有遇到一样的问题嘛


--【贰】--:

哦哦 是回错人了


--【叁】--:

这也太详细了,买了腾讯云,这个CLIProxyAPI代理是不是直接放到腾讯云,然后我本地可以访问哇,佬友


--【肆】--:

转载
还是就是转自己啊


--【伍】--:

你是不是回错人了,我不是楼主
肯定可以啊,嗯?你本地机器都不联网的?


--【陆】--:

转载的,原作者头像和我一样,昵称和我一样,网站和我一样


--【柒】--:

太强了大佬!


--【捌】--:

你说外网啊,我还以为你是没有公网的,境内机器也能用,富强或者用socks代理就行了


--【玖】--:

外网没鸡 用梯子行不行 就自己用


--【拾】--:

佬 我在自己家里的机器上部署行不行?还是说要能连上外网的机器


--【拾壹】--:

你是不是用的大陆的服务器


--【拾贰】--:

肯定要连外网啊,不然你本地自建大模型吗?


--【拾叁】--:

想问问佬友 是不是最好买海外地域的套餐呢?


--【拾肆】--:

反手一个关注


--【拾伍】--: miaowmint:

下拉到 Qwen OAuth ,点击登录,等待链接出现后,复制链接到浏览器打开,或者点击打开链接按钮

佬我到这一步就进行不下去了,我这里复制的用的gpt授权认证,提示“网络无法访问”,但是我这边可以正常登录的(本地挂了梯子)。是不是复制的链接是国内的服务器的问题。我看日志报错是地区限制了。


--【拾陆】--:

感谢猫猫教程


--【拾柒】--:

太强辣!!!


--【拾捌】--:


转载要正确使用tag的,之前还发生过被追到站里的情况,自己的就随意了


--【拾玖】--:

刚部署完,没赶上佬有教程