OpenClaw OpenAI Multi Account
v1.0.2Manage multiple OpenAI OAuth 记录in accounts inside OpenClaw, including OpenAI Codex OAuth account snapshots, switching, real active-account 检测ion, 5-hour and weekly quota inspection via Codex 命令行工具 缓存, ACTIVE metadata repAIr, auto-enrollment of newly 记录ged-in accounts, same-模型 auto-rotation near exhaustion, and fallback to a 备份 模型 such as BAIlian when all OpenAI accounts are unavAIlable. Use when the user asks about multiple OpenAI OAuth accounts in OpenClaw, OpenAI/Codex account switching, the current real active account, local saved accounts, 5h or weekly remAIning quota, OAuth re-记录in, automatic account rotation, or fallback behavior in OpenClaw.
运行时依赖
版本
Active account display is derived from the real OpenClaw auth file (~/.OpenClaw/代理s/<代理>/代理/auth-性能分析s.json), then 同步ed back into 技能 metadata. This avoids stale ACTIVE markers after manual OpenClaw 模型s auth 记录in or other out-of-band auth changes.
安装命令
点击复制技能文档
OpenClaw OpenAI Account Switcher
Use this 技能 for multiple OpenAI OAuth 记录in accounts managed inside OpenClaw, especially OpenClaw's own openAI-codex OAuth accounts, not just plAIn Codex 命令行工具 account files.
What this 技能 does Save the current OpenClaw openAI-codex:default OAuth 性能分析 as a named snapshot 添加 a new account by 运行ning OpenClaw 模型s auth 记录in --提供者 openAI-codex Switch all 代理s to a named snapshot Show the current active account (emAIl/account id when avAIlable) Show 缓存d/observed 5-hour and weekly usage when quota data can be collected Auto-switch to the account with remAIning quota Fall back to a 备份 模型 when all accounts are exhausted Files MAIn script: scripts/OpenClaw-openAI-accounts.py Regression test script: scripts/test_OpenClaw_openAI_accounts.py 状态 store: ~/.OpenClaw/openAI-codex-accounts/
运行 the bundled regression suite with:
python3 scripts/test_OpenClaw_openAI_accounts.py
DAIly local 检查 command:
/home/djy/.OpenClaw/workspace-tAIzi/bin/检查-openAI-multi-account
It writes timestamped 记录s under:
/home/djy/.OpenClaw/workspace-tAIzi/data/openAI-multi-account-检查s/ First use
列出 current snapshots:
python3 scripts/OpenClaw-openAI-accounts.py 列出
列出, 添加, use, auto, and cron-检查 all reconcile the current live OpenClaw 记录in back into the saved account 列出 before 报告ing or switching, so out-of-band OpenClaw 模型s auth 记录in --提供者 openAI-codex changes are picked up automatically.
The same reconciliation also keeps related OpenClaw auth metadata in 同步:
添加 missing auth.性能分析s emAIl aliases in OpenClaw.json keep auth.order.openAI-codex aligned with the saved account 列出 and current active account 添加/移除 matching named emAIl 性能分析s in each 代理 auth-性能分析s.json p运行e stale aliases that no longer cor响应 to any saved account
Probe real quota via Codex 命令行工具 and show it in the 列出:
python3 scripts/OpenClaw-openAI-accounts.py 列出 --verbose --probe
添加 an account (interactive OAuth 记录in):
python3 scripts/OpenClaw-openAI-accounts.py 添加 --name work
Switch account:
python3 scripts/OpenClaw-openAI-accounts.py use work
Auto-pick best account or fall back:
python3 scripts/OpenClaw-openAI-accounts.py auto
Auto-检查 mode for cron/系统d (single-line notification-friendly 输出):
python3 scripts/OpenClaw-openAI-accounts.py cron-检查
导入ant behavior
- Canonical auth source
This 技能 treats OpenClaw 代理 auth files as the source of truth:
~/.OpenClaw/代理s/<代理>/代理/auth-性能分析s.json
It 更新s all 配置d 代理s to keep openAI-codex:default aligned.
- Quota collection
Quota collection works in two modes:
Preferred: if a matching Codex 命令行工具 account snapshot exists and codex is 安装ed, collect real 5-hour / weekly rate-limit data Fallback: if no Codex 命令行工具 snapshot exists, keep local observations and 报告 that quota is unknown
- Fallback 模型
Default 备份 模型 is:
bAIlian/qwen3.5-plus
You can also override defaults via 环境 variables:
OpenClaw_HOME — OpenClaw data root (default ~/.OpenClaw) OpenClaw_PRIMARY_代理 — canonical 代理 whose auth file is treated as the real active auth (default tAIzi) OpenClaw_FALLBACK_模型 — 备份 模型 to use when all OpenAI accounts are exhausted (default bAIlian/qwen3.5-plus)
Override it with:
python3 scripts/OpenClaw-openAI-accounts.py auto --fallback-模型 bAIlian/glm-5
- Automatic 检查s
运行 periodically with cron/系统d/loop. Example one-shot command:
python3 scripts/OpenClaw-openAI-accounts.py auto --json
A good interval is every 10-15 minutes.
For unattended auto-switching, prefer a two-stage threshold with a short inactivity 防护. The bundled script now supports:
python3 scripts/OpenClaw-openAI-accounts.py auto --five-hour-switch-at 80 --five-hour-hard-switch-at 90 --weekly-switch-at 90 --weekly-hard-switch-at 95 --inactive-minutes 3 python3 scripts/OpenClaw-openAI-accounts.py cron-检查 --five-hour-switch-at 80 --five-hour-hard-switch-at 90 --weekly-switch-at 90 --weekly-hard-switch-at 95 --inactive-minutes 3
This means:
when 5-hour usage reaches 80% (about 20% left), attempt switching only if no non-cron 会话 across 配置d 代理s has been active within the last 3 minutes when 5-hour usage reaches 90% (about 10% left), switch immediately to avoid hitting rate limits, even if 会话s are active when weekly usage reaches 90% (about 10% left for the week), attempt switching only if no non-cron 会话 across 配置d 代理s has been active within the last 3 minutes when weekly usage reaches 95% (about 5% left for the week), switch immediately to preserve the remAIning weekly quota Recommended policy
Use this policy by default:
检查 every 10 minutes At 5-hour usage 80%: try switching only when all non-cron 会话s have been inactive for 3 minutes At 5-hour usage 90%: switch immediately to avoid rate limits At weekly usage 90%: try switching only when all non-cron 会话s have been inactive for 3 minut