chatgpt-codex-onboarding

Connect ChatGPT / Codex subscription via OAuth device-code login (NOT BYOK)

INSTALLATION
npx skills add https://github.com/starchild-ai-agent/official-skills --skill chatgpt-codex-onboarding
Run in your project or agent environment. Adjust flags if your CLI version differs.

SKILL.md

πŸ” ChatGPT / Codex OAuth Onboarding

Use the user's existing ChatGPT or Codex subscription for gpt-5-codex, gpt-5, gpt-5-mini access β€” without an API key.

This is a script-mode skill β€” no tools registered. Read this file, then call the exports from a bash block.

See also

  • byok-custom-model skill β€” for vendor-key BYOK setup (DIFFERENT mechanism, NOT OAuth)
  • config/context/references/model-onboarding.md β€” overall model-selection landscape

When to use this skill

βœ… Use when the user EXPLICITLY says one of:

  • "Sign in with my ChatGPT account"
  • "Use my Codex subscription"
  • "Connect my ChatGPT Plus / Pro / Team / Enterprise"
  • "Login with OpenAI / ChatGPT"

❌ Do NOT use for:

  • BYOK / API-key-based setup ("Add OpenAI API key", "I have an OpenAI key")
  • Other vendors that sound similar (Anthropic, Gemini, Qwen, etc.) β†’ use byok-custom-model
  • "Add the OpenAI model" without subscription context β€” ASK first whether they want OAuth (subscription) or BYOK (API key)

⚠️ Vendor names that sound similar (Codex, OpenAI, GPT) are NOT a signal to start OAuth on their own. Only an explicit user mention of "subscription / sign in / login with ChatGPT" qualifies.

Onboarding flow

  • status β€” check if a credential already exists (resume vs fresh).
  • start β€” get a verification URL + user code from OpenAI; persisted to disk.
  • Tell the user: open the URL in a browser, log in to their ChatGPT / Codex account, and enter the code. Do NOT auto-poll.
  • Wait for the user to confirm they approved the device.
  • poll β€” finalize the OAuth handshake; on success, the new model becomes available.

If poll returns status='pending', the user hasn't finished yet β€” wait for them, then poll again. Don't loop poll automatically.

Script usage

python3 - <<'EOF'

import sys, json

sys.path.insert(0, "/data/workspace/skills/chatgpt-codex-onboarding")

from exports import status, start, poll, logout, refresh, models, usage

# Check current state

print(json.dumps(status(), indent=2))

# Start a flow

result = start()

print(f"Open: {result['verification_url']}\nCode: {result['user_code']}")

EOF

After the user approves:

python3 - <<'EOF'

import sys, json

sys.path.insert(0, "/data/workspace/skills/chatgpt-codex-onboarding")

from exports import poll

print(json.dumps(poll(), indent=2))

EOF

Functions

Function

Required args

Purpose

status()

β€”

Inspect current OAuth state, expiry, model list

start()

β€”

Begin device-code flow β†’ verification_url + user_code

poll(pending_id=None)

β€”

Check authorization (call after user confirms approval)

logout()

β€”

Disconnect + remove credentials

refresh()

β€”

Force-refresh access token (debug; normally automatic)

models(force=False)

β€”

List available models from the OAuth endpoint

usage(force=False)

β€”

Subscription usage stats

force=True on models / usage bypasses the cache TTL.

All functions return a dict with ok: True on success or ok: False, error: "..." on failure.

After connecting

Models appear with the openai-codex/ prefix:

  • openai-codex/gpt-5-codex β€” primary
  • openai-codex/gpt-5 β€” full GPT-5
  • openai-codex/gpt-5-mini β€” smaller / faster

User switches via /model openai-codex/gpt-5-codex or the model picker UI.

Subsequent calls hit OpenAI directly using the OAuth token β€” bypasses the platform proxy. Subscription usage limits apply (not the platform's credit balance).

Reauth

Tokens auto-refresh via refresh_token. If a 401 surfaces:

  • refresh() β€” try the manual refresh path.
  • If still failing, logout() + restart from start().

Critical rules

  • Never paste user_code in the verification_url. They're separate β€” user must enter the code manually after opening the URL.
  • Never start the flow without explicit user request. "I want to use ChatGPT" is enough; "I have an OpenAI key" is NOT (that's BYOK).
  • **Wait for user confirmation between start and poll.** Auto-polling wastes API calls and gives stale "pending" responses.
BrowserAct

Let your agent run on any real-world website

Bypass CAPTCHA & anti-bot for free. Start local, scale to cloud.

Explore BrowserAct Skills β†’

Stop writing automation&scrapers

Install the CLI. Run your first Skill in 30 seconds. Scale when you're ready.

Start free
free Β· no credit card