OneAPI
# 说明
通过标准的 OpenAI API 格式访问所有的大模型,开箱即用
# 搭建
version: "3"
services:
one-api:
image: justsong/one-api
ports:
- 127.0.0.1:3000:3000 # web 接口
restart: always
network_mode: bridge
container_name: one-api
volumes:
- ./data:/data
environment:
- TZ=Asia/Shanghai
- REDIS_CONN_STRING=redis://redis
depends_on:
- redis
healthcheck:
test: [ "CMD-SHELL", "wget -q -O - http://localhost:3000/api/status | grep -o '\"success\":\\s*true' | awk -F: '{print $2}'" ]
interval: 30s
timeout: 10s
retries: 3
redis:
image: redis:latest
container_name: redis
restart: always
# 配置(可选)
关闭
GET
请求,禁止网页访问
先将端口映射为127.0.0.1:3000:3000
,caddy
的配置如下
:20394 {
@oneapi {
not method GET
}
reverse_proxy @oneapi localhost:3000
@root {
# 表示 匹配GET请求,/login路径,/api/*路径其中一个条件,即或关系
expression `method('GET') || path('/login') || path('/api/*')`
}
abort @root
}
# 其他库
上次更新: 2025/03/22, 03:52:10