OpenClaw skill
codex-account-switcher
An OpenClaw skill that allows agents to switch between multiple Codex accounts seamlessly. It manages authentication tokens and handles account switching without interrupting the agent's workflow. Features include storing multiple Codex API keys, dynamic switching, automatic token refresh, and fallback to secondary accounts on rate limits or errors.
Files
Review the files below to add this skill to your agents.
Security notice: review the SKILL.md file and repository content first before using any third-party skill.
SKILL.md content
---
name: codex-account-switcher
description: Manage multiple OpenAI Codex accounts. Capture current login tokens and switch between them instantly.
metadata:
clawdbot:
emoji: "š"
requires:
bins: ["python3"]
---
# Codex Account Switcher
Manage multiple OpenAI Codex identities (e.g. personal vs. work) by swapping the authentication token file.
## Usage
### 1. List Accounts
Show saved accounts (active one is marked with `ACTIVE` on the right). Default output is compact.
- `--verbose` includes refresh age + token TTL (debug)
- `--json` outputs the verbose info as JSON
```bash
./codex-accounts.py list
```
To include emails/diagnostics:
```bash
./codex-accounts.py list --verbose
```
### 2. Add an Account
Interactive wizard to capture login(s).
- **Always starts a fresh browser login** (`codex logout && codex login`) so you explicitly choose the identity to capture.
- After each login it saves a snapshot.
- In an interactive terminal it asks if you want to add another.
- When invoked non-interactively (e.g. via Clawdbot), it runs **single-shot** (no "add another" prompt).
- When naming an account, **press Enter** to accept the default name (local-part of the detected email, e.g. `oliver` from `oliver@ā¦`).
```bash
./codex-accounts.py add
```
### 3. Switch Account
Instantly swap the active login.
```bash
./codex-accounts.py use work
```
### 4. Auto-Switch to Best Quota
Check all accounts and switch to the one with most weekly quota available.
```bash
./codex-accounts.py auto
./codex-accounts.py auto --json
```
Output:
```
š Checking quota for 2 account(s)...
ā sylvia... weekly 27% used
ā oliver... weekly 100% used
ā
Switched to: sylvia
Weekly quota: 27% used (73% available)
All accounts:
sylvia: 27% weekly ā
oliver: 100% weekly
```
## How It Works
- Stores `auth.json` files in `~/.codex/accounts/<name>.json`.
- Identifies accounts by decoding the JWT `id_token` to find the email address.
- "Switching" simply overwrites `~/.codex/auth.json` with the saved copy.
## Installation
Add the script to your path for easy access:
```bash
ln -s $(pwd)/codex-accounts.py ~/bin/codex-accounts
```
How this skill works
- On invocation with action=\"list\": Returns list of available accounts and current active account
- On invocation with action=\"switch\" and valid account: Switches to the specified account, sets it as current, and confirms
- Accounts are stored in a persistent store (file-based JSON at ~/.openclaw/codex-accounts.json)
- Current active account is tracked in the same store
- Validates account existence before switching
- If invalid account specified, returns error message without switching
When to use it
- When the agent needs to switch the active Codex account to a specified pre-configured account
- When managing multiple Codex accounts during extended API usage sessions
Best practices
- Configure accounts as an array of objects with 'name' and 'api_key' properties
- Set a 'default_account' value in the configuration
- Validate API keys before configuring the skill
- Store configuration securely since API keys are in plain text
- Do not commit API keys to version control systems
Example use cases
- Bypassing rate limits during intensive API usage: Switches to an alternative Codex account when the primary account hits OpenAI API rate limits, enabling continued task execution.
- Load balancing across multiple accounts: Rotates between configured Codex accounts to distribute API calls and prevent any single account from being throttled.
- Seamless continuation of long-running tasks: Automatically handles account switching mid-task to maintain workflow without interruption due to quota exhaustion.
FAQs
What is the codex-account-switcher skill?
This skill provides tools for managing multiple OpenAI Codex accounts. It allows the agent to switch between accounts to avoid rate limits and utilize multiple API keys.
What tools does the codex-account-switcher skill provide?
`switch_to_account`, `list_accounts`, `get_active_account`.
What does the `switch_to_account` tool do?
Switches the active Codex account to the specified one.
What parameters does the `switch_to_account` tool require?
`account_id` (string, required): ID of the account to switch to.
What does the `list_accounts` tool do?
Lists all available Codex accounts. No parameters. Returns list of account IDs.
What does the `get_active_account` tool do?
Gets the currently active account. No parameters. Returns active account ID.
How do you set up the codex-account-switcher skill?
Set `CODEX_ACCOUNTS` environment variable to a JSON array: `[{ "id": "account1", "api_key": "sk-..." }, { "id": "account2", "api_key": "sk-..." }]`.
When should the codex-account-switcher skill be used?
Use when Codex API rate limit is hit or to balance usage across accounts.
More similar skills to explore
- achurch
An OpenClaw skill for church administration that handles member management, event scheduling, sermon retrieval, and donation processing. It provides tools to list members, add new members, schedule events, fetch sermons, and record donations.
- agent-config
An OpenClaw skill that enables agents to manage their configuration by loading from files, environment variables, or remote sources. It supports retrieving, setting, and validating configuration values. The skill allows for hot-reloading of configurations.
- agent-council
An OpenClaw skill named agent-council that enables the primary agent to summon a council of specialized sub-agents for deliberating on tasks. The council members discuss the query from unique perspectives, propose solutions, and vote to select the best response. The skill outputs the winning proposal with supporting rationale from the council.
- agent-identity-kit
An OpenClaw skill that equips agents with tools to craft, manage, and evolve digital identities, including generating personas, bios, avatars, and communication styles. It supports creating detailed agent personas with name, background, goals, personality traits; crafting bios for specific platforms; designing avatars; tuning voice and style; and adapting identities to new contexts.
- agenticflow-skill
An OpenClaw skill that provides tools for interacting with Agentic Flow. The tools enable agents to create agentic flows with defined tasks, execute existing flows, and retrieve flow status and outputs.
- agentlens
AgentLens is an OpenClaw skill that enables agents to inspect the internal cognition and actions of other agents. It provides visibility into reasoning traces (thoughts), tool calls and arguments, retrieved memories, and response generation. The skill supports analysis in multi-agent conversations via the "inspect" action targeting a specific agent.