Skip to content

Proxy Codex model discovery through CodeRouter - #9641

Merged
lawrencecchen merged 2 commits into
mainfrom
fix/coderouter-models
Aug 5, 2026
Merged

lawrencecchen merged 2 commits into
mainfrom
fix/coderouter-models

Conversation

@lawrencecchen

@lawrencecchen lawrencecchen commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • add authenticated /v1/models support for Codex model discovery
  • forward through the selected Stack-vault account
  • preserve account cooldown/failover behavior
  • prevent Codex startup from logging a Next.js HTML 404

Test plan

  • focused CodeRouter suite: 12 passed
  • bun run typecheck

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.


Summary by cubic

Expose an authenticated /v1/models endpoint in CodeRouter that proxies Codex model discovery through the selected vault-backed Codex account. Preserves cooldown/failover behavior and stops the Codex startup 404 log.

  • New Features

    • Proxies to https://chatgpt.com/backend-api/codex/models, forwarding query params and using the account’s accessToken.
    • Retries on 429s and marks account cooldown before failing over to the next account.
    • Adds a focused test for the models proxy.
  • Bug Fixes

    • Serve the models route dynamically to prevent a Next.js HTML 404 during Codex startup.

Written for commit cfe00a5. Summary will update on new commits.

Review in cubic

@coderabbitai

coderabbitai Bot commented Aug 5, 2026 •

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 1433034f-ea4b-4b3d-9260-ae3673739749

📥 Commits

Reviewing files that changed from the base of the PR and between 81ae632 and cfe00a5.

📒 Files selected for processing (3)
  • web/app/v1/models/route.ts
  • web/services/coderouter/codexProxy.ts
  • web/tests/coderouter-models-proxy.test.ts

📝 Walkthrough

Walkthrough

The change adds a dynamic /v1/models route that forwards requests to a Codex proxy. The proxy authenticates requests, selects and refreshes accounts, forwards queries and headers, retries rate-limited accounts, and returns model data or an error.

Changes

Codex models proxy

Layer / File(s) Summary
Codex proxy request handling
web/services/coderouter/codexProxy.ts
Adds the Codex models endpoint and proxy handler. The handler authenticates requests, selects usable accounts, refreshes credentials, forwards requests, retries rate-limited accounts, and returns errors when no account is usable.
Models route integration and validation
web/app/v1/models/route.ts, web/tests/coderouter-models-proxy.test.ts
Adds the dynamic GET route and tests authenticated request forwarding, query propagation, upstream status, and model payloads.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant ModelsRoute
  participant proxyCodexModels
  participant CodexModelsEndpoint
  Client->>ModelsRoute: Send authenticated GET request
  ModelsRoute->>proxyCodexModels: Delegate request
  proxyCodexModels->>proxyCodexModels: Authenticate and select account
  proxyCodexModels->>CodexModelsEndpoint: Forward query and headers
  CodexModelsEndpoint-->>proxyCodexModels: Return models or rate limit
  proxyCodexModels-->>ModelsRoute: Return response
  ModelsRoute-->>Client: Return response
Loading
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/coderouter-models

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@lawrencecchen
lawrencecchen merged commit 2d9ba4b into main Aug 5, 2026
3 of 4 checks passed
@lawrencecchen
lawrencecchen deleted the fix/coderouter-models branch August 5, 2026 09:22
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