Skip to content

Latest commit

 

History

History
84 lines (53 loc) · 2.3 KB

File metadata and controls

84 lines (53 loc) · 2.3 KB

Using a Codex Subscription with OpenClaw

This guide covers configuring OpenClaw to use your Codex subscription via the AI Gateway Cloudflare worker.

Your actual Codex subscription details is never given to OpenClaw. Instead, it's securely stored & managed by the AI Gateway. This allows you to use the same subscription with multiple OpenClaws.

Prerequisites

  • A working OpenClaw deployment on your VPS
  • An active Codex subscription
  • Access to the AI Gateway Proxy Worker /config UI

Steps

1. Login to Codex

On any machine (local or a code agent sandbox), login to Codex using your subscription:

codex login

2. Copy your auth credentials

After logging in, copy the contents of your Codex auth file:

cat ~/.codex/auth.json

3. Add credentials to AI Gateway

Open your AI Gateway Worker's /config UI and paste the auth.json contents.

Your AI Gateway URL is typically in .env as AI_GATEWAY_URL

(source .env && open $AI_GATEWAY_URL/config)

Your gateway auth token is also in .env as AI_GATEWAY_TOKEN. You will need the auth token to access the /config UI.

After authenticating:

  1. Paste your ~/.codex/auth.json file contents into the Codex OAuth form field
  2. Click the Save Changes button
  3. Copy the generated JWT

The AI Gateway generates a custom JWT to use with openclaw. This JWT does not contain any of your actual Codex info or secrets. It's only used for openclaw to authenticate with the AI Gateway.

You can inspect the contents of the JWT at https://jwt.io

The AI Gateway securely stores your real auth.json info and automatically manages refresh tokens for you.

You can now use your Codex subscription with any of your openclaws in your stack.

4. Configure OpenClaw to Use Codex

# SSH into your VPS
./scripts/ssh-vps.sh

Add the AI Gateway JWT to OpenClaw:

openclaw models auth paste-token --provider openai-codex
# Paste in the JWT generated by the AI Gateway

Set codex as the default model:

openclaw models set openai-codex/gpt-5.3-codex

This updates openclaw.json with Codex as the primary model. The change should take effect immediately via hot-reload. If it doesn't, restart the gateway:

# From your local machine (not the VPS):
scripts/restart-gateway.sh