Skip to content

feat: Add API key support#93

Open
Loongphy wants to merge 6 commits intomainfrom
codex/api-key-accounts
Open

feat: Add API key support#93
Loongphy wants to merge 6 commits intomainfrom
codex/api-key-accounts

Conversation

@Loongphy
Copy link
Copy Markdown
Owner

@Loongphy Loongphy commented May 8, 2026

Summary

Support OPENAI_API_KEY auth as a first-class managed account.

This change:

  • imports and syncs API-key auth.json files instead of rejecting them with MissingEmail
  • resolves API-key identity via GET /v1/me
  • stores the account email for list display and grouping
  • uses API_KEY in the PLAN column for API-key accounts
  • keeps single API-key rows email-only, and shows masked per-key child labels when the same email has multiple API keys
  • skips ChatGPT usage refresh for registry records marked as API-key auth, so stale or malformed API-key snapshots render placeholder usage instead of MissingAuth

API key identity

For API-key auth, the local account_key now uses:

apikey::<me.id>::<sha256(OPENAI_API_KEY)>

list example

Single API key account:

     ACCOUNT           PLAN      5H USAGE  WEEKLY USAGE  LAST ACTIVITY
---------------------------------------------------------------------
user@example.com      API_KEY        -           -            -

Multiple API keys for the same email:

     ACCOUNT           PLAN      5H USAGE  WEEKLY USAGE  LAST ACTIVITY
---------------------------------------------------------------------
user@example.com
  sk-7f3c1***42ce     API_KEY        -           -            -

Validation

  • HOME=/tmp/codex-auth-pr93-check zig build --build-file /coding/codex-auth/build.zig --cache-dir /tmp/codex-auth-pr93-check/zig-cache --global-cache-dir /tmp/codex-auth-pr93-check/zig-global-cache test
  • HOME=/tmp/codex-auth-pr93-run CODEX_HOME=/tmp/codex-auth-pr93-run/.codex zig build --build-file /coding/codex-auth/build.zig --cache-dir /tmp/codex-auth-pr93-run/zig-cache --global-cache-dir /tmp/codex-auth-pr93-run/zig-global-cache run -- list
  • Manual reproduction: API-key registry record with stale {} snapshot now renders API_KEY with - usage, not MissingAuth

Refs #92
Issue: #92

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 8, 2026

Open in StackBlitz

@loongphy/codex-auth-darwin-arm64

npx https://pkg.pr.new/@loongphy/codex-auth-darwin-arm64@93

@loongphy/codex-auth-darwin-x64

npx https://pkg.pr.new/@loongphy/codex-auth-darwin-x64@93

@loongphy/codex-auth-linux-arm64

npx https://pkg.pr.new/@loongphy/codex-auth-linux-arm64@93

@loongphy/codex-auth-linux-x64

npx https://pkg.pr.new/@loongphy/codex-auth-linux-x64@93

@loongphy/codex-auth-win32-arm64

npx https://pkg.pr.new/@loongphy/codex-auth-win32-arm64@93

@loongphy/codex-auth-win32-x64

npx https://pkg.pr.new/@loongphy/codex-auth-win32-x64@93

@loongphy/codex-auth

npx https://pkg.pr.new/@loongphy/codex-auth@93

commit: 0e18634

@Loongphy Loongphy changed the title Add API key account support feat: Add API key support May 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant