Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,24 @@ cross-protocol conversion), #4433.

**Does this work with [opencodex](https://github.com/lidge-jun/opencodex) (`ocx`) — the local Codex/Claude Code gateway with a ChatGPT account pool?** Same pattern: point the client at bili, and point bili at ocx through the `/bili/` prefix — OpenAI-style clients (chat completions and Responses, e.g. Codex) → `OPENAI_BASE_URL=http://localhost:8787/bili/http://127.0.0.1:10100/v1`; Anthropic-style clients → `ANTHROPIC_BASE_URL=http://localhost:8787/bili/http://127.0.0.1:10100`. A dummy key value satisfies clients that require one; it rides through untouched. Keep bili *in front of* ocx rather than behind it: ocx owns the provider credentials and the account pool at its final hop, so only this order keeps compression and pooling working together. Loopback needs no key between the two (ocx's default loopback bind reads no token); a non-loopback bind takes `OPENCODEX_API_AUTH_TOKEN` plus the `x-opencodex-api-key` header per its docs. Request models by ocx's `provider/model` id so routing is deterministic; as with any gateway, routed ids are opaque to bili's window lookup (declare them via `models.<name>.context`) and a mid-session account rebind invalidates the prefix cache (watch `KEY SWITCHES` in `/acp-cache`). Verified end-to-end over all three wires (OpenAI Chat / Responses / Anthropic Messages), bili 0.1.212 × ocx 2.97.0.

**Can I combine bili with the [qoder-trae-workbuddy-switch](https://github.com/NextAgentX/qoder-trae-workbuddy-switch) quota gateway?**
Yes — same `/bili/` prefix pattern: `http://localhost:8787/bili/http://127.0.0.1:5789x/v1`
(OpenAI wire) or without `/v1` (Anthropic wire) + the gateway's sk-* key; ports
57891 WorkBuddy / 57892 unified / 57894 Trae / 57895 Qoder. Caveats: ① the
gateway's account stickiness reads ONLY the non-standard body field
`metadata.conversation_id` (no header fallback) — clients that don't write it
(Claude Code, Codex) get a per-request account draw from the pool, and each
vendor account keeps its own prefix cache, so cross-turn prefix-cache hits ≈ 0;
use a client that writes the field (Cursor/Cline) or set the gateway's pick
mode to Sequential / keep one account in the allowlist; ② the unified gateway
requires namespaced model names `<ns>:<model>` (bare names → 400) — declare
their context windows under the providers key via `models.<name>.context`
(#2317); ③ the Qoder lane reports zero token usage upstream → bili's usage
stats degrade there (compression is unaffected — it runs on local tokenization);
④ mid-conversation account switches invalidate the provider's prefix cache and
stay invisible to bili's KEY SWITCHES attribution (the outbound key is always
the stable sk-* gateway key). Full analysis: #5193.

**Where are logs and session data stored?** Log:
`~/.local/state/billion-context/bili.log` (also mirrored to stderr); session
state: `~/.local/share/billion-context/` (XDG-overridable; Windows AV exclusion
Expand Down
2 changes: 2 additions & 0 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,8 @@ bili --version

**能配合 [opencodex](https://github.com/lidge-jun/opencodex)(`ocx`)用吗?——它是带 ChatGPT 账号池的本地 Codex/Claude Code 网关。** 同样的模式:客户端指向 bili、bili 经 `/bili/` 前缀指向 ocx —— OpenAI 系客户端(chat completions 与 Responses,如 Codex)→ `OPENAI_BASE_URL=http://localhost:8787/bili/http://127.0.0.1:10100/v1`;Anthropic 系客户端 → `ANTHROPIC_BASE_URL=http://localhost:8787/bili/http://127.0.0.1:10100`。要求 key 的客户端填个假值即可,原样穿过。bili 要放在 ocx *前面*而不是后面:provider 凭据与账号池都在 ocx 这一最终跳上,只有这个顺序才能让压缩与账号池同时生效。回环下两者之间不需要 key(ocx 默认回环绑定不读 token);非回环绑定按其文档设 `OPENCODEX_API_AUTH_TOKEN` + `x-opencodex-api-key` 头。请求模型时用 ocx 的 `provider/model` id 保证路由确定;和任何网关一样,路由后的 id 对 bili 的窗口查询不透明(用 `models.<name>.context` 声明),会话中途换账号会使前缀缓存失效(见 `/acp-cache` 的 KEY SWITCHES)。三条线(OpenAI Chat / Responses / Anthropic Messages)已端到端实测:bili 0.1.212 × ocx 2.97.0。

**能配合 [qoder-trae-workbuddy-switch](https://github.com/NextAgentX/qoder-trae-workbuddy-switch) 的配额网关用吗?** 能 —— 同样的 `/bili/` 前缀接法:`http://localhost:8787/bili/http://127.0.0.1:5789x/v1`(OpenAI 线)或去掉 `/v1`(Anthropic 线)+ 网关的 sk-* key;端口 57891 WorkBuddy / 57892 统一 / 57894 Trae / 57895 Qoder。注意:① 该网关的账号粘性**只**读非标准 body 字段 `metadata.conversation_id`(不读任何请求头)——不写这个字段的客户端(Claude Code、Codex)每请求都在账号池里抽签换号,而各厂商账号各有自己的前缀缓存,跨轮 prefix cache 命中≈0;用会写字段的客户端(Cursor/Cline),或把网关选号模式设为 Sequential / allowlist 只留一个账号;② 统一网关要求命名空间模型名 `<ns>:<model>`(裸名直接 400)——需在 providers 键下用 `models.<name>.context` 声明其上下文窗口(#2317);③ Qoder 车道上游恒报 0 token → bili 用量统计在该车道退化(压缩不受影响——走本地 tokenize);④ 会话中途换号会使 provider 前缀缓存失效,且对 bili 的 KEY SWITCHES 归因不可见(出站 key 永远是稳定的 sk-* 网关 key)。完整分析:#5193。

**日志和会话数据存在哪?** 日志:`~/.local/state/billion-context/bili.log`(同时镜像到 stderr);会话状态:`~/.local/share/billion-context/`(XDG 可覆盖;Windows 杀软排除 #362、可选清理 #1082)—— 完整路径见 [docs/configuration.zh-CN.md](docs/configuration.zh-CN.md)。

## 运行代理
Expand Down
Loading