Skip to content

feat(chatgpt): support Codex images, review, and public Live routes - #40366

Closed
jibanez-staticduo wants to merge 110 commits into
BerriAI:mainfrom
jibanez-staticduo:litellm_chatgpt_codex_routes
Closed

jibanez-staticduo wants to merge 110 commits into
BerriAI:mainfrom
jibanez-staticduo:litellm_chatgpt_codex_routes

Conversation

@jibanez-staticduo

@jibanez-staticduo jibanez-staticduo commented Sep 9, 2026 •

Copy link
Copy Markdown

TLDR

Problem this solves:

  • Codex image edits fail with ChatGPT OAuth deployments
  • Structured review requests lose their strict JSON schema
  • Voice signaling rejects ordinary proxy keys
  • Optional sidebands leave voice usage untracked or duplicated
  • Multipart voice requests need consistent model authorization
  • Public Live session routes are missing

How it solves it:

  • Adds image adapters and preserves strict Responses schemas
  • Preserves Image 2.5 quality, transparency, and JSON parameters
  • Applies cached text and image prices by modality
  • Authenticates signaling and binds sidebands to their owner
  • Accounts for voice independently of client sideband connections
  • Preserves gateway routing, quotas, and bounded cleanup
  • Checks voice permissions against the model actually requested
  • Adds Live sessions, forks, recording, and SIP controls
  • Documents Codex text, images, and voice gateway configuration

Intentional product change: legacy JSON SDP handles are rejected with HTTP 401 before OAuth lookup or routing. Clients must create fresh session handles; ordinary OpenAI ephemeral credentials keep their existing behavior

User Flow

Before: a developer can generate an image, but editing it fails

  1. Configure gpt-image-2 as a chatgpt/gpt-image-2 deployment using existing ChatGPT OAuth credentials
  2. Send POST http://localhost:4000/v1/images/generations with a blue-circle prompt and receive HTTP 200 with a base64 PNG
  3. Send POST http://localhost:4000/v1/images/edits with that image in the JSON images array and a red-circle prompt
  4. Receive HTTP 500: aimage_edit() missing 1 required positional argument: 'image'
  5. Send a voice offer to POST http://localhost:4000/v1/realtime/calls with the ordinary proxy key and receive HTTP 401

After: the same developer receives the edited image

  1. Configure gpt-image-2 as a chatgpt/gpt-image-2 deployment using existing ChatGPT OAuth credentials
  2. Send POST http://localhost:4000/v1/images/generations with a blue-circle prompt and receive HTTP 200 with a base64 PNG
  3. Send POST http://localhost:4000/v1/images/edits with that image in the JSON images array and a red-circle prompt
  4. Receive HTTP 200 with a base64 PNG of the edited image
  5. Send a permitted voice offer to POST http://localhost:4000/v1/realtime/calls with the same key, using JSON or multipart regardless of media-type capitalization, and receive HTTP 201; requests outside personal permissions or model budgets are denied

These flows describe the supported request contract. Fresh real-provider before/after evidence for the current tip is still unavailable

Implementation

Adds ChatGPT OAuth image generation and JSON/file image editing, strict Responses schemas, and voice. Image routes preserve the selected model and quality, nested JSON parameters, and extra_body precedence. Multipart edits retain their encoding. Provider bodies exclude local ChatGPT authentication options. Cached text and image costs use separate modality rates when reported. Provider configuration stays separate from proxy authentication, and lazy WebSocket imports keep ordinary SDK calls independent of proxy dependencies

Configured gateway headers and repeated query parameters survive signaling, call state, attachment, and hangup. Configured routing wins over permitted client protocol parameters; call identity and OAuth credentials remain authoritative. Custom key-header selection is consistent across authentication and ownership checks. JSON and multipart media types are case-insensitive. Multipart session authorization uses the model actually signaled, shares parsed forms with custom authentication, invalidates stale body caches, and closes uploads. Generic OpenAI header overrides and ephemeral credentials retain their behavior

A proxy-owned observer starts before SDP is returned and accounts independently of client attachments. V3 signaling transfers its parallel slot to a renewable call-supervisor lease; reconnects retain policy checks without acquiring another slot or duplicating spend. Lost lease ownership terminates the call. Redis Cluster reservations retain ownership and compensate partial acquisition. Legacy attachment counters decrement atomically; signaling with legacy parallel limits requires the V3 limiter and returns HTTP 400 otherwise

Shutdown closes supervisors before draining spend, counters, and logging. Cancellation waits for bounded cleanup, including repeated cancellation. Provider termination has 60 seconds, usage drain five seconds, and logging dispatch its existing 20-second default. Live reserves half the termination window for an independent hangup attempt. Missing terminal usage or invalid duration invalidates reservation counters instead of settling unknown spend to zero. Callback completion does not guarantee persistence if downstream errors are swallowed

Codex offers have an 8 MiB byte limit before parsing, authentication, or temporary-file creation. GPT-Live terminal duration remains authoritative alongside token events and uses the selected deployment's per-second price. Encrypted handles bind deployment identity and supervision state. Legacy JSON SDP handles are rejected before OAuth lookup or routing; generic OpenAI ephemeral credentials remain accepted. Authentication uses upstream's existing CHATGPT_TOKEN_DIR and CHATGPT_AUTH_FILE

Public GPT-Live routes

This update adds the public Live protocol alongside the existing Codex signaling routes. OpenAI deployments use their configured API key; ChatGPT deployments retain the existing proxy OAuth credentials. Supporting the route contract does not guarantee that every OAuth account or backend supports every operation

Method Path
POST, WebSocket /v1/live/sessions
WebSocket /v1/live/sessions/{session_id}/attach
POST, WebSocket /v1/live/sessions/{session_id}/fork
GET /v1/live/sessions/{session_id}/content
POST /v1/live/sessions/{session_id}/accept
POST /v1/live/sessions/{session_id}/reject
POST /v1/live/sessions/{session_id}/refer
POST /v1/live/sessions/{session_id}/hangup

The same routes have /live and /openai/v1/live aliases. Public WebRTC creation uses JSON; Codex multipart/raw SDP signaling remains available at POST /v1/live. Primary WebSockets start with session.start. Attachment sockets require neither a new start event nor a replayed session.started event

Session handles conceal upstream credentials and bind controls to their owner and selected deployment. Managed delegation checks the backend model as well as the voice model. Restricted keys forking a managed session must supply an explicit authorized backend model, since later session updates can make the initial model stale. Client-delegation forks retain their immutable delegation type and may use empty overrides. Sparse sideband updates can retain the current backend model. Keys requiring per-invocation backend budgets or rate limits must use client delegation. Incoming SIP enrollment requires a proxy administrator and an unambiguous configured model alias

Configure Codex through LiteLLM

The ChatGPT provider guide includes LiteLLM deployment examples and Codex configuration for text models, image generation/editing, and voice

# Root settings must precede the provider table
model_provider = "litellm"
model = "qwen3.8-flash-next-codex"
experimental_realtime_ws_base_url = "https://proxy.example.com/v1"

[model_providers.litellm]
name = "LiteLLM"
base_url = "https://proxy.example.com/v1"
wire_api = "responses"
requires_openai_auth = true
experimental_bearer_token = "<LITELLM_VIRTUAL_KEY>"

Keep the Codex ChatGPT login for client capability checks, use a LiteLLM virtual key to authenticate to the gateway, and configure ChatGPT OAuth separately on the proxy. Qwen text requests use the selected LiteLLM alias; images and voice require their own authorized aliases and capable deployments. Restricted keys and team members must allow every requested alias. Selecting a text model does not make it an image or voice model

Set the root experimental_realtime_ws_base_url so voice sideband connections return to the same gateway as signaling. Otherwise, Codex can send the offer through LiteLLM and attempt to attach directly to OpenAI using a proxy-owned call ID. experimental_realtime_webrtc_call_base_url separately overrides HTTP signaling when needed. Image requests use the active provider's base_url

Relevant issues

Related to #40888; this adds its public route contract but does not claim complete real-provider validation of recording, forks, or SIP

Protocol reference: OpenAI Codex and OpenAI Live

Affected release

Linear ticket

Pre-Submission checklist

  • I have added meaningful tests
  • The focused test files covering my change pass locally
  • My PR passes all required CI/CD checks
  • My PR's scope includes only its feature and necessary CI repairs
  • Current-tip Greptile confidence is at least 4/5

At 966b047dd5ff7e67b6afe4156172c1e3d53ba0fa, the branch includes upstream 0980f756bd031993329eb0b8b2caa193047e6465 and is mergeable. make check passes against that upstream snapshot, including Python lint and type budgets, test quality, E2E types, dashboard lint, and API-type synchronization. Coverage thresholds, lint budgets, and signature verification remain unchanged

Final local validation passes 570 focused tests and seven SDP regression tests. The SDP regression tests cover rejection before OAuth lookup or routing and preserve generic OpenAI ephemeral credentials. The former High-severity legacy-handle finding is fixed in this tip

Current-tip codecov/patch and Veria pass. The remote proxy-behavior job fails only while uploading Lens coverage: Codecov CLI 11.3.1 cannot import its GPG key and reports No public key, matching codecov-action#1876. An attempted workflow rerun was rejected because it requires repository-admin rights. The rust-test check is cancelled rather than passed, so required CI remains incomplete

Greptile's visible 5/5 belongs to 8c9367ba8d, not this tip. Current-tip Greptile confirmation is unavailable, and Bugbot has no visible result. Maintainer review has not been requested

Screenshots / Proof of Fix

Fresh before/after captures against the merge base and this exact public tip are unavailable. Local regression checks and live deployment smoke checks do not replace headful Codex, image-edit, and voice-session evidence

Type

New Feature, Bug Fix, Documentation, Test

Caveats (if any)

Severe

  • Legacy JSON SDP handles return 401; create fresh session handles

Medium

  • OAuth backends may not support every public Live operation
  • Provider failures can prevent complete termination and terminal accounting
  • Worker crashes can lose terminal-only usage
  • Recording downloads are buffered in memory
  • SIP enrollment requires proxy administrator credentials
  • Live per-second billing requires a configured deployment price
  • Signaling offers have an 8 MiB limit
  • Image masks remain unsupported; use reference images
  • Requested image properties and model identity depend on the backend
  • ChatGPT Live uses global OAuth, without deployment credential overrides

Low

  • Headful Codex and fresh real-provider validation remain pending
  • Workers must share the configured encryption salt
  • Accounting deadlines can interrupt slow custom logging integrations
  • Live JSON conversion limits nesting to 256 levels

Final Attestation

  • All real-world workflows and edge cases are verified

@jibanez-staticduo
jibanez-staticduo requested a review from a team September 9, 2026 05:25
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 9, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-14T22:00:16.722999Z be9a191 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@codspeed

codspeed Bot commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 31 untouched benchmarks


Comparing jibanez-staticduo:litellm_chatgpt_codex_routes (966b047) with main (0980f75)

Open in CodSpeed

@greptile-apps

greptile-apps Bot commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[High risk] Adds realtime call routing, live endpoints, and proxy authentication changes.

The PR appears safe to merge based on the reviewed changes; no outstanding blocking finding was established.

Summary

The PR adds ChatGPT image and Codex voice support, public Live routes, model authorization, usage accounting, and supervised call cleanup. The upstream merge also updates shared authorization and pricing code; this review found no actionable new regression from those interactions.

Reviews (38) · Last reviewed commit: "chore: merge upstream main into Codex ro..."

Comment thread docs/chatgpt-codex-routes.md Resolved
Comment thread litellm/llms/chatgpt/codex.py Resolved
Comment thread litellm/proxy/proxy_server.py Resolved
@veria-ai

veria-ai Bot commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

PR overview

All previously flagged issues have been addressed. No open security concerns remain on this pull request.

Security review

No open security issues remain on this pull request.

Fixed/addressed: 16 · PR risk: 0/10

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bce8aa1dcc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread litellm/llms/chatgpt/images.py Resolved
@codecov

codecov Bot commented Sep 9, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.36399% with 13 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
litellm/proxy/auth/auth_checks.py 72.22% 5 Missing ⚠️
litellm/proxy/realtime_endpoints/live.py 99.47% 4 Missing ⚠️
litellm/proxy/hooks/parallel_request_limiter_v3.py 98.36% 2 Missing ⚠️
litellm/proxy/proxy_server.py 89.47% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@jibanez-staticduo

Copy link
Copy Markdown
Author

@greptileai @codex review Updated security validation, image file handling, provider placement, and gateway routes; local checks and both deployment probes pass.

Comment thread litellm/llms/chatgpt/codex.py Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 58a5657784

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread litellm/llms/chatgpt/codex.py Resolved
Comment thread litellm/llms/chatgpt/codex.py Resolved
@jibanez-staticduo

Copy link
Copy Markdown
Author

@greptileai Please review 93285ed: provider transformations and FastAPI handlers are separated. Both deployed instances passed real image, review, and voice probes

Comment thread litellm/llms/chatgpt/realtime.py Resolved
@jibanez-staticduo

Copy link
Copy Markdown
Author

@greptileai Please review 8e5901e. Live transport now uses model metadata; both deployments and the isolated proxy passed fresh image, review, and voice probes

@jibanez-staticduo

Copy link
Copy Markdown
Author

@codex review d5f3528: sideband pre-call policies and all three credential transports now pass regression tests and real probes on both deployments

@jibanez-staticduo

Copy link
Copy Markdown
Author

@greptileai Please review d5f3528. Sideband policy enforcement and supported WebSocket credentials passed real provider probes on both deployments before this update

Comment thread litellm/llms/chatgpt/images.py Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d5f352823b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@jibanez-staticduo

Copy link
Copy Markdown
Author

@greptileai Please re-review 06b2d76: the ChatGPT provider tests moved into the sharded tests/unit/llms tree that upstream now selects, the duplicated resolution-tier fields are gone from the Rust ModelInfo (upstream added the same block, so the struct no longer declares them twice), the access-group budget query is sliced by IN_LIST_CHUNK_SIZE, and three authentication paths now stay on the model they dispatch: the synthetic request drops the inherited parsed_body, model-bound authentications carry litellm_pinned_realtime_model, and the authenticated image model wins over extra_body. Each has a regression test, and the threads above record the evidence.

@jibanez-staticduo

Copy link
Copy Markdown
Author

@greptileai Please review 94a4929: fixed the shared catalog and Interactions contract tests. Both focused suites and test-quality gates pass locally

Merge upstream cbe6972 while preserving image, structured review, Realtime, and public Live behavior

Deduplicate the eight shared ultrafast catalog schema properties without loosening constraints, and regenerate dashboard types for the optional trace_ref parameter

Validated 1588 focused regressions, 163 merge-overlap tests, the catalog regression, and the Redis TTL test against temporary Redis. Full make check passes after resolving catalog duplicates and generated type drift
@jibanez-staticduo

Copy link
Copy Markdown
Author

@greptileai Please review this updated tip after merging upstream main, focusing on authorization, Live accounting, signaling, and supervisor cleanup

@jibanez-staticduo
jibanez-staticduo force-pushed the litellm_chatgpt_codex_routes branch from 5f70abe to c33110c Compare October 1, 2026 01:36
@jibanez-staticduo
jibanez-staticduo force-pushed the litellm_chatgpt_codex_routes branch from 1c3f1bb to c33110c Compare October 1, 2026 02:26
@krrish-berri-2

Copy link
Copy Markdown
Contributor

@jibanez-staticduo — the Proof of Fix section notes that end-to-end evidence is still pending. Could you add a screenshot or short video showing that this change works as expected (e.g. Codex image input / review and a public Live route working through the proxy)? It really helps reviewers verify the fix quickly. Thanks!

@jibanez-staticduo
jibanez-staticduo force-pushed the litellm_chatgpt_codex_routes branch from 32eba7a to 82d2d6d Compare October 1, 2026 07:47
Comment thread litellm/llms/chatgpt/realtime.py Resolved
@akapur99

Copy link
Copy Markdown
Contributor

@jibanez-staticduo bumping the proof of fix!

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.

7 participants