Introducing The Sweep: OX’s New Live Security Research Series
Register Now
Breaking: The 2026 Vulnpocalypse Hits PHP: Four Critical RCEs, but How Dangerous Are They?
Read the Report
Are you exposed? Connect your apps in minutes.
Scan your apps free

codex-as-api

Latest version: v1.0.2

Overview

Last scanned
24 Nov 2026
Published
24 Nov 2026
PyPI package Publisher: choam, jho6394
38 Stars
12 Forks
14 Versions
1.6K Downloads
Rust Repo language

Scan summary

codex-as-api was last scanned on 24 Nov 2026 at version 1.0.2. Risk score 0 of 100. No malicious behavior was detected.

  • Releases: 14 versions; the latest 2 were published within 7 days (18–24 Nov 2026).
  • Findings: No rules fired in version 1.0.2.
  • Downloads: 1,644 downloads.

Versions

14 versions published
Versions and the rules that fired in each
VersionPublishedStatus
1.0.2 LATEST 24 Nov 2026 No rules fired
1.0.1 18 Nov 2026 No rules fired
0.10.2 13 Nov 2026 1 rule fired
0.10.1 10 Nov 2026 Not shown
0.10.0 29 Oct 2026 Not shown

No rules fired in 1.0.2

Findings

Findings for v1.0.2. The score is a capped sum of the weights of the rules that fired — not CVSS, not exploitability, and not a probability. It is not comparable across packages with different scan coverage.

The score describes 1.0.2; other versions have their own rules, not their own score.

README

The publisher’s own README, as collected from the registry.

codex-as-api

GitHub Release PyPI npm License

Use ChatGPT / Codex OAuth as a local OpenAI-compatible API server.

Features

  • OpenAI & Anthropic compatible — Responses (/v1/responses, /v1/responses/compact), Chat Completions, Messages, and GET /v1/models
  • Claude Code ready — use Codex models directly from Claude Code CLI
  • Streaming — full SSE streaming for both OpenAI and Anthropic protocols
  • Tool calling — function calls, tool results, and parallel tool calls
  • Image support — generation, inspection, multimodal Chat input, and capability-gated original image detail in classic Responses
  • Reasoning — capability-checked effort/context, persisted reasoning, and explicit Codex reasoning extensions without fabricated Anthropic signatures
  • Codex features — live authenticated model discovery, session-aware prompt_cache_key, account-scoped Chat continuation, subagent headers, and remote compaction
  • Codex config aware — reads CODEX_HOME / ~/.codex/config.toml for model, reasoning-effort, and context-window settings
  • Token estimate & compaction helpers — Anthropic-compatible /v1/messages/count_tokens and /v1/messages/compact
  • Standalone ChatGPT login — ordinary browser OAuth by default, optional device-code login for remote servers, a private application-owned credential store, and managed refresh; no installed Codex CLI or existing Codex login required
  • 3 implementations — Python, TypeScript (npm), and Rust — identical behavior

What it does

Runs a lightweight HTTP server on localhost that translates standard OpenAI API calls into authenticated requests against the ChatGPT / Codex backend. Sign in explicitly through this server's browser OAuth API; it stores and refreshes its own OAuth credentials without reading or changing your Codex login.

Python, Rust, and TypeScript (npm) implementations are provided — identical functionality, same endpoints, same behavior.

Prerequisites

A ChatGPT account eligible for the Codex backend and a runtime for your chosen implementation are required. The official Codex CLI is not required.

After starting the server, use Standalone login to open OpenAI's ordinary sign-in page in your browser and authorize this server. Credentials are saved privately to ~/.codex-as-api/auth.json by default, and the server handles refresh itself. It does not discover, import or fall back to ~/.codex/auth.json, CODEX_HOME credentials or a Codex keychain entry. Upgrading from older versions therefore requires a fresh login for codex-as-api; your existing Codex login is left alone.

Use one server process per credential store. To run independent instances, assign each its own CODEX_AS_API_HOME or CODEX_AS_API_AUTH_PATH. Model settings may still be read from ~/.codex/config.toml; that separate configuration behavior is unchanged and does not require installing Codex.

Install & Run

Python

Install from PyPI:

pip install codex-as-api
codex-as-api

Or with uv:

uv pip install codex-as-api
codex-as-api

Or from source:

git clone https://github.com/CHOAM-CO/codex-as-api.git
cd codex-as-api
pip install -e .
codex-as-api
Rust
cd rust
cargo build --release
./target/release/codex-as-api
TypeScript (npm)

Install from npm and run:

npm install -g codex-as-api
codex-as-api

Or use npx without installing:

npx codex-as-api

Or from source:

cd ts
npm install
npm run build
node dist/cli.js

Can also be used as a library:

import { ChatGPTOAuthProvider, createApp } from "codex-as-api";

// Use the provider directly
const provider = new ChatGPTOAuthProvider({ model: "gpt-5.6-sol" });
const response = await provider.chat(
  [
    { role: "system", content: "You are helpful." },
    { role: "user", content: "Hello!" },
  ],
);
console.log(response.content);

// Or create an Express app
const app = createApp();
app.listen(18080);

All versions bind to 127.0.0.1:18080 (localhost only) by default.

Standalone login

Login is an API operation; the codex-as-api command starts the server, not the Codex CLI. Before starting, set CODEX_AS_API_ADMIN_KEY to a private random administrator key. Supply that same key as a bearer credential on /auth/*. This key is independent of both the OpenAI OAuth credentials and any inference client authentication; never use your access or refresh token as the admin key.

  1. Start the server with the key configured, then initiate login from a trusted local terminal or authenticated management client:

    curl -sS -X POST http://127.0.0.1:18080/auth/login \
      -H "Authorization: Bearer $CODEX_AS_API_ADMIN_KEY" \
      -H 'Content-Type: application/json' -d '{}'
  2. The 202 response contains id, method: "browser", status: "pending", auth_url and expires_at. Your app opens auth_url in the system browser; sign in normally on OpenAI's page. No one-time device code or Codex CLI is needed. On approval, the browser returns to a separate loopback callback listener on the same machine as the server, and credentials are saved privately. The server tries registered callback port 1455, then 1457; if both are occupied it reports 409 callback_port_unavailable instead of interfering with another app. The API itself never launches a browser on a remote server. The authorization URL contains temporary sensitive state; do not log or share it. Only start login on a server you control.

  3. Poll the login ID returned by step 1 (the placeholder below is not a real ID):

    curl -sS http://127.0.0.1:18080/auth/login/LOGIN_ID \
      -H "Authorization: Bearer $CODEX_AS_API_ADMIN_KEY"

    Status becomes succeeded only after valid credentials are durably saved. Other terminal states are failed, cancelled and expired. Routine status responses include the method but never repeat the authorization URL or user code, or return OAuth tokens, authorization codes, verifiers, device IDs or storage paths.

  4. To stop an outstanding attempt, send DELETE /auth/login/LOGIN_ID with the same administrator bearer. Repeating cancellation is safe. A login already saved remains succeeded; cancellation is not logout or provider-side revocation.

GET /auth/status with the administrator bearer returns only {"status":"authenticated"}, unauthenticated or reauthentication_required. This checks the local application-owned credential state, not provider-side revocation or remote account validity; refresh is handled privately when needed. Validation, cancellation and failures before credential replacement preserve a prior valid login. If replacement succeeds but the final directory sync fails, login_persistence_uncertain reports that durability could not be confirmed; a new local credential may already exist. Cancellation is not a rollback.

Explicit device login for remote/headless use

When the browser and API server are on different machines, a loopback browser callback would reach the wrong machine. Explicitly send {"method":"device"} to POST /auth/login instead. It returns method: "device", verification_url, user_code, interval and the common session fields. Open https://auth.openai.com/codex/device in your own browser and enter the code. Only approve a code from a login you initiated on a trusted server; never post it in public channels or logs. Device-code login may need enabling in your OpenAI account. No method silently falls back to another.

All management responses use Cache-Control: no-store. An unset admin key returns 503 management_disabled; a missing/wrong bearer returns 401 invalid_admin_key. An empty request body, {} or {"method":"browser"} selects browser login; {"method":"device"} selects device login. No other body fields are accepted. The API does not accept credentials to import, token export switches, authentication endpoints or credential paths from a request. One active attempt per store is allowed; another start returns 409 login_in_progress. Unknown/retired IDs return 404.

Keep the default loopback binding unless you deliberately deploy authenticated HTTPS administration behind a trusted reverse proxy. A browser Origin must match the request's own scheme and Host; the API does not blindly trust forwarded headers. Configure proxy origins consistently. Origin checking supplements the admin bearer and is not a replacement for authentication or network controls. Each credential store must be owned by one server process, not shared between independent workers. Choose separate store paths for separate instances.

Note on OpenAI "Sign in with ChatGPT" (SIWC) preview

OpenAI's public Sign in with ChatGPT (chatgpt.tokens.use.direct) preview route (https://api.openai.com/v1/responses with dynamic client registration) is intentionally kept on hold and not used as the default transport:

  • Function tools on the SIWC preview route must be wrapped inside a namespace tool object rather than sent as top-level function definitions.
  • Remote compaction (/responses/compact), Responses Lite, hosted image_generation, device-code login, and ChatGPT Live / Realtime WebRTC voice calls are not supported on the SIWC preview route.
  • Reliable prompt cache hits on SIWC currently require reusing a persistent WebSocket (wss://api.openai.com/v1/responses) rather than stateless HTTP POST /v1/responses requests.

Configuration

Environment variables (Python, Rust, and TypeScript):

Variable Default Description
CODEX_AS_API_HOST 127.0.0.1 Bind address
CODEX_AS_API_PORT 18080 Listen port
CODEX_AS_API_MODEL ~/.codex/config.toml model, else live default Model identifier passed to Codex backend
CODEX_AS_API_AUTH_PATH CODEX_AS_API_HOME/auth.json, else ~/.codex-as-api/auth.json Explicit application-owned OAuth store path; not an import command
CODEX_AS_API_HOME ~/.codex-as-api Application-owned credential directory
CODEX_AS_API_ADMIN_KEY unset (management disabled) Independent bearer key for /auth/*; never use an OAuth token as this key
CODEX_AS_API_RESPONSES_LITE auto Responses Lite mode: auto, on, or off
CODEX_AS_API_CODEX_METADATA off Add Codex-style per-turn client_metadata and related backend headers
CODEX_HOME ~/.codex Optional Codex model/config discovery only; never used to find credentials

The server also reads root-level Codex CLI settings from ~/.codex/config.toml:

model = "gpt-5.6-sol"
model_reasoning_effort = "high"

# Optional explicit context values. A published live maximum still clamps them.
model_context_window = 272000
model_auto_compact_token_limit = 244800

CODEX_AS_API_MODEL overrides the Codex config model. Reasoning-effort precedence is request, Codex config, then the authenticated model catalog default when present. When no request or configured model exists, the proxy selects the catalog's first visibility: "list" model by ascending priority, matching Codex. The effective model, reasoning setting, catalog status, and context settings are exposed from /health; optional reasoning and context values are null when neither config nor the live catalog supplies them. Context settings are also returned by Anthropic token-count responses when available.

Supported Models

Ordinary models and capabilities come from the authenticated Codex /models response. The proxy keeps each account/base-URL/client-version snapshot in memory for 300 seconds and invalidates it when a Responses X-Models-Etag changes. An unavailable or malformed refresh returns 503 catalog_unavailable before streaming headers are sent; an upstream HTTP rejection after the one allowed OAuth refresh preserves its status as upstream_error. Model snapshots are never shared across accounts or served as an offline fallback.

Use GET /v1/models for the effective catalog. It includes exact slugs, visibility, supported_in_api, reasoning-summary controls, and opaque comp_hash compatibility identifiers when supplied. Unknown IDs return 404 model_not_found. Automatic default selection uses only the upstream catalog's originally visible models, not the experimental additions below.

Experimental hidden models

These three upstream-hidden models returned real responses on October 24, 2026, and are explicitly included in codex-as-api's effective catalog:

Model ID Observed upstream purpose
gpt-6-chat-thinking Server-described paid CCA experiment; hidden and marked unsupported in the upstream API catalog
gpt-reserve Official Codex CLI's Luna Reserve routing for reserve usage
codex-auto-review Official Codex CLI's Guardian automatic approval-review model

A small authenticated smoke test also verified function-tool calling plus tool-result continuation for all three models, and executed a simple generated JavaScript function against four inputs per model. This is a basic functionality check, not a coding-quality benchmark.

These are hidden models. Upstream support can stop at any time, and availability may differ by account. If a model stops responding, open an issue with its model ID and a sanitized error; we will remove the discontinued model from this catalog. Do not include access tokens or other credentials in the issue.

The proxy exposes these verified exceptions as selectable models and prefers their current live capability metadata. Bundled capability records keep only these three IDs available when a successful live catalog omits them; they do not bypass OAuth, upstream rejection, or a failed/malformed catalog fetch. A successful empty upstream catalog can therefore list these experimental entries, while health/default selection still fails until an ordinary upstream default is available. The proxy never selects a hidden experimental model as its automatic default.

To use a different port:

CODEX_AS_API_PORT=9000 codex-as-api

To expose on all interfaces (e.g. for remote access):

CODEX_AS_API_HOST=0.0.0.0 codex-as-api

API Endpoints

GET /v1/models

Returns the current account's authenticated Codex model catalog using an OpenAI-compatible list envelope. The response includes safe routing and capability metadata but omits backend instructions and model messages.

curl http://localhost:18080/v1/models

OX Radar and Response Center

Find threats in your stack.

OX Radar can check high-priority threats, like critical package CVEs, against your context.

Each incident is marked Detected or Not Detected with a remediation plan and proof all tracked in the Response Center.

Where it’s listed

The probe returned only these fields for this server — auth requirement, protocol and tool list weren’t observed, so they’re not shown (never guessed).

  • pypi-releases codex-as-api

References

The publisher’s own links, as the registry reports them. These are not sources for the assessment on this page.

Scan your whole stack

Group 1261154050 1
Group 1261154050
 

From OX Research Newsroom

Ethersphere Hijacked With Crypto Stealing Malware (1)
npm

Ethersphere Hijacked With Crypto Stealing Malware Via Github & npm

PHP2Shell, Day 5 93.6% of Measurable Instances Still Unpatched (1)
Vulnerability Insights

PHP2Shell, Day 5: The Panic Hasn’t Turned Into Patching

Copy of Template Design OX Blog (3)
Research

Ruby2Shell: Ruby Memory Corruption Flaws Expose Applications to Remote Code Execution, But is it an Actual Risk?

Frame 2085668439 (1)
Group 1261154229