# AI use cases for Codex LB Enhanced (aafqaq/codex-lb-enhanced)

Repo: [aafqaq/codex-lb-enhanced](https://github.com/aafqaq/codex-lb-enhanced) | Use cases: 4 | Page: https://dedupedai.com/use-cases/aafqaq-codex-lb-enhanced/

Codex LB Enhanced is a self-hosted gateway that pools several upstream accounts behind Codex-compatible and OpenAI-compatible endpoints, with failover, session recovery, quota headers, and diagnostics.

This file holds every use case of this repo. Each one starts with a "## " heading and ends with its URL.

- Run a self-hosted Codex account-pool gateway with Docker: https://dedupedai.com/use-cases/aafqaq-codex-lb-enhanced/self-host-codex-account-pool-gateway/
- Point Codex CLI at the gateway with a provider entry: https://dedupedai.com/use-cases/aafqaq-codex-lb-enhanced/point-codex-cli-at-enhanced-gateway/
- Read API-key quota usage from /v1/usage in scripts: https://dedupedai.com/use-cases/aafqaq-codex-lb-enhanced/read-api-key-quota-usage-for-automation/
- Run the gateway from source for local development: https://dedupedai.com/use-cases/aafqaq-codex-lb-enhanced/run-enhanced-gateway-from-source-for-development/

## How to run a self-hosted Codex account-pool gateway with Docker with Codex LB Enhanced

Repo: [aafqaq/codex-lb-enhanced](https://github.com/aafqaq/codex-lb-enhanced) | Difficulty: Intermediate | Time: 30 minutes | Basis: From the README

Start the gateway in a container, add accounts, and create an API key in the dashboard.

**Who it is for:** A developer or small team that wants one local endpoint for Codex and OpenAI-compatible clients, backed by several upstream accounts they control.

**The problem:** Single upstream accounts hit quota limits or drop long Codex sessions, and each client needs its own setup.

**The outcome:** A running gateway at localhost:2455 with accounts added, an API key created, and a persistent SQLite data volume.

### Steps

1. Create the Docker network if it does not exist: `docker network inspect codex-lb-net >/dev/null 2>&1 || docker network create codex-lb-net`
2. Create the data volume: `docker volume create codex-lb-enhanced-data`
3. Start the container: `docker run -d --name codex-lb-enhanced --restart unless-stopped -e CODEX_LB_HTTP_RESPONSES_SESSION_BRIDGE_AMBIGUOUS_CONTINUATION_RECOVERY_MODE=server_indefinite_recovery --network codex-lb-net -p 2455:2455 -p 1455:1455 -v codex-lb-enhanced-data:/var/lib/codex-lb ghcr.io/aafqaq/codex-lb-enhanced:1.25.3` (inferred, check the README)
4. Open http://localhost:2455, complete initialization, and add your accounts.
5. Create an API key in the dashboard and save it for your clients.

### Prompt to paste into your agent

```text
In the aafqaq/codex-lb-enhanced repo, run the Docker quick start to start the gateway as the container named codex-lb-enhanced, using the target directory <workdir>. Report the container status from `docker ps` and confirm that http://localhost:2455 responds. Verify that the data volume codex-lb-enhanced-data exists before you finish.
```

### Caveat

The README says account-pool switching can still occasionally fail to recover, so check important sessions instead of trusting failover blindly.

Risk, account pooling: Pooling several upstream accounts behind one endpoint may conflict with the terms of the upstream services, so confirm you are allowed to do this before you add accounts.

Risk, credentials: The dashboard stores upstream account data and API keys in the data volume, so protect that volume and the admin port.

Disclaimer: Third-party repos we don't own or vouch for. AI-generated use cases can be wrong: review everything and run at your own risk. Full text: https://dedupedai.com/disclaimer/

URL: https://dedupedai.com/use-cases/aafqaq-codex-lb-enhanced/self-host-codex-account-pool-gateway/

## How to point Codex CLI at the gateway with a provider entry with Codex LB Enhanced

Repo: [aafqaq/codex-lb-enhanced](https://github.com/aafqaq/codex-lb-enhanced) | Difficulty: Intermediate | Time: 30 minutes | Basis: From the README

Add a Codex LB Enhanced provider to config.toml so Codex routes through the pool.

**Who it is for:** A developer who uses the Codex CLI or IDE integration and wants long sessions to survive account quota limits and interruptions.

**The problem:** Codex sessions break when one upstream account is exhausted or a WebSocket drops without a close frame.

**The outcome:** Codex sends its Responses traffic through the gateway, with WebSocket support enabled and the provider selected by default.

### Steps

1. Start the gateway and create an API key in the dashboard at http://localhost:2455.
2. Open ~/.codex/config.toml and add the model, model_reasoning_effort, and model_provider lines from the README example.
3. Add a [model_providers.codex-lb-enhanced] block with base_url set to http://127.0.0.1:2455/backend-api/codex, wire_api = "responses", supports_websockets = true, and requires_openai_auth = true.
4. Replace base_url with your reverse-proxy address if you do not run the gateway on localhost.
5. Start Codex and send one short prompt to confirm it reaches the gateway.

### Prompt to paste into your agent

```text
Using the aafqaq/codex-lb-enhanced README, add the codex-lb-enhanced provider block to <path to config.toml> with the base_url for <gateway URL>. Report the final provider block and whether a test Codex prompt succeeds. Verify that the file still parses as TOML.
```

### Caveat

The README example uses a specific model name, so change model and model_reasoning_effort to values your account supports.

Risk, credentials: The config file will hold a reference to an API key, so keep the file private and do not commit it to version control.

Disclaimer: Third-party repos we don't own or vouch for. AI-generated use cases can be wrong: review everything and run at your own risk. Full text: https://dedupedai.com/disclaimer/

URL: https://dedupedai.com/use-cases/aafqaq-codex-lb-enhanced/point-codex-cli-at-enhanced-gateway/

## How to read API-key quota usage from /v1/usage in scripts with Codex LB Enhanced

Repo: [aafqaq/codex-lb-enhanced](https://github.com/aafqaq/codex-lb-enhanced) | Difficulty: Advanced | Time: 45 minutes | Basis: From the README

Query the usage endpoint to track remaining limits for each API key.

**Who it is for:** A developer or operations engineer who runs scripts or agents that need to check how much quota an API key has left before starting work.

**The problem:** Clients cannot see how close an API key is to its window limits, so jobs fail mid-run when a limit is hit.

**The outcome:** A script that reads /v1/usage and reports the same quota source the Codex headers use.

### Steps

1. Configure 5h, daily, 7d, weekly, or monthly windows for an API key in the dashboard, using credits, tokens, or cost limits.
2. Enable Codex quota emulation and choose API-key limits or pooled-account estimates as the display source.
3. Send an authenticated GET request to the /v1/usage endpoint with your API key.
4. Parse the JSON response and compare the remaining amounts with the window limits you set. (inferred, check the README)
5. Make your script stop or wait when remaining usage falls below your threshold.

### Prompt to paste into your agent

```text
In the aafqaq/codex-lb-enhanced repo, write a small script that calls /v1/usage on <gateway URL> with the API key in <env var name>. Output the remaining usage per window as JSON. Verify that the output matches the usage limits shown in the dashboard for that key.
```

### Caveat

The README says model-specific limits do not become the default Codex window, so check model-level limits in the dashboard separately.

Risk, credentials: The script will need an API key, so load it from an environment variable and never hard-code it.

Disclaimer: Third-party repos we don't own or vouch for. AI-generated use cases can be wrong: review everything and run at your own risk. Full text: https://dedupedai.com/disclaimer/

URL: https://dedupedai.com/use-cases/aafqaq-codex-lb-enhanced/read-api-key-quota-usage-for-automation/

## How to run the gateway from source for local development with Codex LB Enhanced

Repo: [aafqaq/codex-lb-enhanced](https://github.com/aafqaq/codex-lb-enhanced) | Difficulty: Advanced | Time: 1 hour | Basis: From the README

Sync dependencies with uv and launch codex-lb from a source checkout.

**Who it is for:** A contributor who wants to change the gateway, test recovery behavior, or submit a PR to the project.

**The problem:** Testing failover fixes requires running the same launcher used by the package and Docker image, not only the container.

**The outcome:** A local source build of the gateway running with the same launcher as the release image.

### Steps

1. Clone the repository from https://github.com/aafqaq/codex-lb-enhanced and change into its directory.
2. Install dependencies: `uv sync --dev --frozen`
3. Start the application launcher: `uv run codex-lb`
4. Open http://localhost:2455 and complete initialization.
5. Reproduce a failover case, then open a PR if you have a fix, as the README invites.

### Prompt to paste into your agent

```text
In a clone of aafqaq/codex-lb-enhanced at <path>, run `uv sync --dev --frozen` and then `uv run codex-lb`. Report whether the launcher starts and whether http://localhost:2455 responds. Verify that no dependency install step failed before you start the launcher.
```

### Caveat

The README notes that account-pool switching is still being improved and can occasionally fail to recover, so expect edge cases while you develop.

Disclaimer: Third-party repos we don't own or vouch for. AI-generated use cases can be wrong: review everything and run at your own risk. Full text: https://dedupedai.com/disclaimer/

URL: https://dedupedai.com/use-cases/aafqaq-codex-lb-enhanced/run-enhanced-gateway-from-source-for-development/
