Skip to content

feat: Codex OpenAI API key and base URL overrides from Settings#1174

Open
sohamnandi77 wants to merge 1 commit intopingdotgg:mainfrom
sohamnandi77:snandi1/add-base-url-support
Open

feat: Codex OpenAI API key and base URL overrides from Settings#1174
sohamnandi77 wants to merge 1 commit intopingdotgg:mainfrom
sohamnandi77:snandi1/add-base-url-support

Conversation

@sohamnandi77
Copy link

@sohamnandi77 sohamnandi77 commented Mar 17, 2026

What Changed

  • Server: Added a CodexOpenAiEnvOverrides service that holds optional OPENAI_API_KEY and OPENAI_BASE_URL overrides. These are passed into the Codex app-server process environment when starting a session, so users can point Codex at a different API endpoint or use a different key without changing system env.
  • WebSocket: New method codexSetOpenAiEnv so the web app can push overrides to the server; the server does not persist the API key.
  • Web app: Settings → Codex App Server now has optional fields for OPENAI_BASE_URL (e.g. https://api.openai.com/v1) and OPENAI_API_KEY. Values are stored on the device only and synced to the server on change (debounced). Copy updated to say these settings let you “customize how Codex connects.”
  • Contracts: New CodexSetOpenAiEnvInput / CodexSetOpenAiEnvResult schemas and NativeApi.server.setCodexOpenAiEnv for desktop/web.

Why

Users need to use custom OpenAI-compatible endpoints or keys (e.g. proxy, different region, or alternate provider). Today that requires setting env vars before starting T3 Code. This keeps behavior predictable (overrides apply only to new sessions, API key not stored server-side) while making it configurable from the UI.

UI Changes

Before

image

After

image

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes
  • I included a video for animation/interaction changes

Note

Add Codex OpenAI API key and base URL overrides via Settings UI and WebSocket API

  • Adds a new CodexOpenAiEnvOverrides service (CodexOpenAiEnvOverrides.ts) that stores API key and base URL overrides in an in-memory Ref on the server.
  • Adds a new codex.setOpenAiEnv WebSocket method (ws.ts) so clients can update overrides at runtime; the server handler is wired in wsServer.ts.
  • Extends the Settings UI (_chat.settings.tsx) with inputs for OPENAI_BASE_URL and OPENAI_API_KEY; values are persisted in app settings and synced to the server via a new CodexOpenAiEnvSync component in __root.tsx.
  • When starting a Codex session, CodexAdapter.ts reads the stored overrides and forwards them as OPENAI_API_KEY / OPENAI_BASE_URL env vars to the spawned codex app-server child process.
  • Behavioral Change: OPENAI_API_KEY and OPENAI_BASE_URL set via the Settings UI will override any ambient env vars inherited by the child process for each new session.

Macroscope summarized 9317ef8.

- Introduced CodexOpenAiEnvOverrides service to manage OpenAI API key and base URL.
- Updated CodexAdapter to utilize OpenAI environment overrides during session initialization.
- Enhanced server and client layers to integrate CodexOpenAiEnvOverrides.
- Added UI components for configuring OpenAI API key and base URL in app settings.
- Implemented WebSocket methods for setting OpenAI environment variables.
@coderabbitai
Copy link

coderabbitai bot commented Mar 17, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 89fbfec5-fd0d-456c-a920-edf3e3e48e56

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
📝 Coding Plan
  • Generate coding plan for human review comments

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 and usage tips.

Tip

CodeRabbit can generate a title for your PR based on the changes.

Add @coderabbitai placeholder anywhere in the title of your PR and CodeRabbit will replace it with a title based on the changes in the PR. You can change the placeholder by changing the reviews.auto_title_placeholder setting.

@github-actions github-actions bot added size:L 100-499 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list. labels Mar 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant