84382761fc feat(auth): add focused API key usage page (#102)
* feat(auth): add API key workspace

Add persistent API key sessions and enforce admin/key authorization boundaries. Expose key-scoped quotas, trends, health, and paginated usage records through server-projected data.

Share the application shell, system overview, and usage views between admin and key sessions, reorganize frontend domains around view ownership, and omit account, provider, and authentication details from the key workspace.

BREAKING CHANGE: Browser authentication now uses /api/auth/* and cpr_session; existing browser sessions must sign in again.

Validated frontend lint, type checking, production build, backend workspace tests, and live authenticated key views.

Co-authored-by: Codex <noreply@openai.com>

* feat(console): refine key workspace experience

Unify role-aware console routes and use mode/role in authentication contracts.
Reuse request state, stable pagination and performance projections across workspaces.
Refine quota cards, usage panels, empty states and key-aware theme previews.
Skip session restoration on login and retain form inputs until unmount.
Keep the full health timeline grid visible without samples.

Co-authored-by: Codex <noreply@openai.com>

* feat(key-usage): replace shared workspace with focused usage page

Preserve unified admin/key authentication, restore admin pages, and remove the previous client workspace implementation. Add a scoped usage page with metrics, trends, budgets, request logs, and section loading placeholders.

Co-authored-by: Codex <noreply@openai.com>

---------

Co-authored-by: Zyy <zyycn@users.noreply.github.com>
Co-authored-by: Codex <noreply@openai.com>
2026-09-16 01:49:37 +08:00
2026-09-15 15:55:09 +08:00

Codex Proxy RS

Codex Proxy RS

面向 Codex 的自托管多账号 AI 网关

CI Release GHCR License: Apache 2.0

快速开始 · 客户端接入 · 文档 · 社区 · 许可证

Note

本项目提供 Responses API,不支持 /v1/chat/completions。接入前请确认客户端支持 Responses 协议。

快速开始

使用 Docker Compose 部署版本固定的发布镜像,同时启动 PostgreSQL 和 Redis。 以下命令适用于 Linux amd64/arm64,需要 Docker Engine、Docker Compose Plugin、curl 和 OpenSSL。已有部署请先看 升级说明,不要覆盖原配置。

1. 下载部署文件并配置

mkdir -p codex-proxy-rs/deploy && cd codex-proxy-rs

# 只解析一次最新正式版本,确保两个文件来自同一 Release。
CPR_RELEASE_URL="$(curl -fsSL -o /dev/null -w '%{url_effective}' https://github.com/zyycn/codex-proxy-rs/releases/latest)"
CPR_RELEASE_TAG="${CPR_RELEASE_URL##*/}"
curl -fsSL "https://github.com/zyycn/codex-proxy-rs/releases/download/${CPR_RELEASE_TAG}/compose.yaml" \
  -o deploy/compose.yaml
curl -fsSL "https://github.com/zyycn/codex-proxy-rs/releases/download/${CPR_RELEASE_TAG}/config.example.yaml" \
  -o deploy/config.example.yaml

install -d -m 0750 .runtime/postgres .runtime/redis
sudo install -d -m 0770 -o "$(id -u)" -g 10001 .runtime/data .runtime/logs
sudo install -m 0640 -o "$(id -u)" -g 10001 deploy/config.example.yaml deploy/config.yaml

也可将 CPR_RELEASE_TAG 设置为指定的发布标签。Release 附带的 compose.yaml 默认使用该版本镜像, 配置模板和部署文件均包含在 checksums.txt 中;不要混用 main 分支模板与已发布镜像。

分别生成数据库和 Redis 密码:

openssl rand -hex 24
openssl rand -hex 24

编辑 deploy/config.yaml,填好以下三项:

配置项 填写内容
store.database.password 第一个生成的 48 位十六进制密码
store.redis.password 第二个生成的 48 位十六进制密码
admin.default_password 管理员初始密码,至少 12 位,不能包含 $

2. 启动服务

docker compose -f deploy/compose.yaml config --quiet
docker compose -f deploy/compose.yaml pull
docker compose -f deploy/compose.yaml up -d --no-build --wait
curl -i http://127.0.0.1:8080/healthz

健康检查返回 204 No Content 后,打开 http://127.0.0.1:8080, 使用 admin@cpr.local 和刚设置的管理员密码登录。 API Key 持有者可在同一登录页切换登录身份,进入 /key-usage 查看自己的用量、趋势、请求日志、额度与健康时间线;不能访问管理员页面。

默认地址只能在服务器本机访问。从其他设备使用时,需要配置 HTTPS 反向代理。

3. 添加账号与客户端密钥

  1. 在「账号」中添加账号,完成授权或导入。
  2. 按需建立账号分组,再创建客户端密钥并选择可用分组。不选分组表示可使用全部账号。
  3. 打开密钥的「使用密钥」,复制客户端配置。

客户端接入

Codex CLI / 桌面端:在「使用密钥」中按操作系统复制配置,或通过 CCSwitch 导入。 合并到客户端配置后重启 Codex。完整步骤、生图配置与排障见客户端配置。

其他 Responses API 客户端:填写以下信息。

配置 值
Base URL http://127.0.0.1:8080/v1;远程接入使用服务器的 HTTPS 地址
API Key 管理端创建的客户端密钥

可用模型以该密钥查询到的模型列表为准:

curl http://127.0.0.1:8080/v1/models \
  -H 'Authorization: Bearer <client-api-key>'

文档

社区

感谢 LINUX DO 社区提供开放、友善的技术交流平台。

许可证

本项目基于 Apache License 2.0 开源。

S
Description
基于 Rust 的低风控、高性能、自托管多账号透明代理网关
Readme Apache-2.0
44 MiB
Languages
Rust 90%
Vue 5.7%
TypeScript 3.7%
PLpgSQL 0.4%
Ruby 0.1%