Skip to content
| Marketplace
Sign in
Visual Studio Code>AI>Portwise: Codex Account & Provider SwitcherNew to Visual Studio Code? Get it now.
Portwise: Codex Account & Provider Switcher

Portwise: Codex Account & Provider Switcher

Santu

|
3 installs
| (0) | Free
Switch Codex accounts and manage OpenAI-compatible providers, with a local gateway that stays on the right port.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Portwise — three routes, one active connection

Portwise

Your Codex accounts and providers. One local place to keep them straight.

Install · Quick Start · Security · Troubleshooting

Published Marketplace version Marketplace installs CI workflow status License: MIT TypeScript 5.9

Get Portwise on the VS Code Marketplace · GitHub releases & VSIX downloads

[!NOTE] Portwise is an independent community extension. It is not affiliated with, endorsed by, or sponsored by OpenAI or Microsoft. It is not a fork of any other project. “Codex” describes compatibility only.

Why Portwise

A few providers. A couple of logins. That one config file you would rather leave alone.

Portwise brings provider profiles, saved logins and gateway troubleshooting into one VS Code panel. Open it when you need to change something, or when Codex is talking to the wrong endpoint. Starting the gateway does not edit your Codex files; configuring Codex is a separate, confirmed operation.

What you get
🔀 Provider profiles Add, edit, test, enable and remove endpoints; enter tokens through VS Code's password input.
Saved accounts Save file-store login snapshots and switch explicitly, without changing history or sessions.
Local gateway A configurable port, stable local token and detached daemon that survives extension-host restarts.
Measured diagnostics Separate extension, gateway and upstream hints, plus an explicit redacted-copy action.

Install

Requirements: VS Code 1.106.0 or newer. Install the official Codex tooling separately; account login and the usage terminal require codex on your PATH. Windows, macOS and Linux are targets; CI verifies Windows and Ubuntu.

Install Portwise from the VS Code Marketplace, or use the terminal:

code --install-extension santu-dev.portwise

Prefer a .vsix? Download one from GitHub releases, then choose Extensions → … → Install from VSIX… and select that file. No publishing account is needed for installation. Building your own package? The development steps are below.

Quick Start

For a first run, give Portwise a disposable copy of your Codex home. A small test drive makes the path dialogs much easier to trust.

  1. Choose the target and add a provider. Set portwise.codexHome to an existing real directory—use a disposable copy for a first test. Open Portwise: Open Panel, select Add provider, and enter its URL and token. Non-loopback providers require HTTPS.
  2. Start and configure. Run Portwise: Start Gateway, then Portwise: Configure Codex for Gateway. Read the exact canonical path in the confirmation. Configuration adds Portwise's managed settings and local-token delivery; it does not select model_provider for you.
  3. Switch deliberately and check. Run Portwise: Switch Codex to Portwise Gateway if you want Codex to use it, confirm the path, then run Portwise: Run Diagnostics. Use Copy redacted report in the resulting notification when needed.

[!WARNING] Restart Codex/VS Code after changing the delivered gateway token or switching accounts. Matching .env bytes cannot prove what an already-running Codex process loaded.

[!IMPORTANT] Account save/switch supports only an explicitly configured file credential store. Keyring, auto, ephemeral and unknown modes are refused. Add accounts through Portwise: Add Account via Codex Login; each saved snapshot requires a fresh official login launch. A launch is not proof that login completed.

Chai-break checkpoint: read the path dialog, check Diagnostics, and remember the restart. The gateway can wait for your tea.

How it works

flowchart LR
  C["Codex"] --> G["Portwise loopback gateway: 127.0.0.1:47831"]
  G --> P["Your configured provider"]

47831 is the default, configurable port. The gateway checks the local token and replaces it with the configured provider token upstream. Provider requests use HTTPS, except explicitly configured loopback HTTP endpoints. The extension host manages profiles and controls the separate daemon; Codex talks directly to that daemon.

Security and limits

Implemented handling Boundary to keep in mind
Gateway binds to 127.0.0.1; checks Host/Origin and local authentication. It is for local use, not remote hosting or sharing.
Fresh exact-path confirmation before every config/.env write operation. One Configure approval covers that invocation's config + .env operation; account/login consent is separate.
Timestamped pre-write config/.env backups; retains 10 per file and Codex home in extension storage. Restore makes a safety backup. Backups may contain existing private file contents; private permissions are applied before writing them.
Account snapshots and provider tokens are stored in VS Code SecretStorage. The active account still lives in Codex's auth.json; the local gateway token is delivered through .env.
.env replacements receive verified private Windows ACLs (0600 mode on POSIX); failure blocks that file's commit. Earlier steps in a Configure operation may already have completed. Diagnostics checks permissions without repairing them.
No quota reads from auth.json, no undocumented quota calls and no Portwise telemetry. File-store account operations/current matching do read credentials in host memory. The panel receives names/ids/current flags, never snapshots.
Diagnostics reads current files and probes the local gateway plus the configured provider's models endpoint. It sends no prompts/code. Windows directory write access is not proven by these read-only checks; restart remains necessary.

These are implementation choices, not an absolute security guarantee. See the threat model, architecture and decisions.

Known limits

  • A configured provider can return any response content, including content that reflects information it received. Portwise does not rewrite upstream response bodies.
  • File updates are verified and guarded rollback preserves external edits. A persistent OS or I/O failure, external edit, or power loss can still require manual recovery from the retained private backup.
  • Health and status replies are bounded, but the separate connection phase has no independently tested deadline; the existing total request deadline bounds it.
  • A legacy or unverified daemon is never adopted or stopped automatically. Stop it from its verified owning profile, or choose another port.

Commands

Open the Command Palette and type Portwise. Here is what each command actually does.

Command Palette name / action ID Purpose
Portwise: Open Panel portwise.openPanel Open the provider, account and gateway panel.
Portwise: Refresh portwise.refresh Refresh panel state.
Portwise: Show Logs portwise.showLogs Open the Portwise output channel.
Portwise: Start Gateway portwise.startGateway Start or adopt an authenticated matching daemon.
Portwise: Stop Gateway portwise.stopGateway Stop the owned daemon.
Portwise: Restart Gateway portwise.restartGateway Stop, then start the gateway.
Portwise: Configure Codex for Gateway portwise.configureCodex Confirm and write managed config/local-token delivery.
Portwise: Run Diagnostics portwise.runDiagnostics Run read-only checks with hop-specific hints.
Copy redacted report Notification action; no command ID Offered after Run Diagnostics; copies only when selected.
Portwise: Restore Config Backup portwise.restoreConfig Pick a timestamped config backup and confirm restoration.
Portwise: Switch Codex to Portwise Gateway portwise.switchToGateway Confirm switching model_provider to Portwise.
Portwise: Add Account via Codex Login portwise.startCodexLogin Launch exactly codex login with the confirmed CODEX_HOME.
Portwise: Save Current Codex Account portwise.saveCodexAccount Consume the single-use login-launch permit and save a snapshot.
Portwise: Switch Codex Account portwise.switchCodexAccount Choose and confirm a saved account switch.
Portwise: Remove Saved Codex Account portwise.removeCodexAccount Confirm removal of a snapshot; leave auth.json alone.
Portwise: Open Codex Usage portwise.openCodexUsage Open plain codex; run /status yourself to view Codex rate limits.

Settings

All four settings are machine-scoped. A setting change alone does not write Codex files.

Setting Default Meaning
portwise.codexHome "" Existing absolute Codex-home directory. Empty resolves CODEX_HOME, then ~/.codex; confirmation shows the resolved canonical path. Linked home roots/targets are refused.
portwise.logLevel "info" error, warn, info or debug; output passes through redaction.
portwise.gatewayPort 47831 Stable loopback port, from 1 to 65535. Reconfigure Codex explicitly after changing it.
portwise.autoStartGateway true Start the daemon after activation. Does not configure Codex automatically.

Screenshots

Portwise panel with the gateway Running on port 8787 and the enabled Fake Upstream provider card

Gateway Running on port 8787, with an enabled fake loopback provider. Captured from 0.1.1 in an isolated profile.

Portwise Diagnostics showing 6 PASS, 3 WARN and 0 FAIL

6 PASS, 3 WARN, 0 FAIL. The warnings cover the Codex home write-access check, provider selection and restarting Codex/VS Code.

Real captures supplied by the maintainer, using an isolated profile and fake provider. Click either image for the full-size PNG. The warnings are part of the captured result, not an all-green mockup.

FAQ

How do saved accounts and Current labels work?

Snapshots live in SecretStorage. The host compares file-store auth.json with saved snapshots in memory. Exactly one byte match gets Current; multiple matches produce an ambiguity note. Token refresh or formatting changes can remove the label. It does not establish remote identity or usage limits.

Does Portwise show my quota or rotate accounts automatically?

No. Portwise does not fetch OpenAI quota from credentials or undocumented endpoints, and has no automatic account-rotation feature. Open Codex Usage opens plain codex; /status is run by you inside Codex. Portwise is for your own accounts within their terms of use.

Troubleshooting

Something feels off? Start with Portwise: Run Diagnostics and its hop/fix hints. Its report is read-only; Copy redacted report is an explicit notification action. The sections below cover the usual culprits.

A leftover daemon occupies port 47831

Portwise reuses a daemon only when saved instance identity and authenticated status match. Another development host or a missing state file can prevent adoption. Stop it from the Portwise window that owns it, or identify and stop that process yourself. Alternatively change portwise.gatewayPort, start the gateway and explicitly Configure Codex again. Portwise does not kill a foreign process or silently pick a random port.

Another operation is in progress / a stale lock remains

Close other Portwise operations/windows first. A live owner's lock is refused. An unverifiable legacy blank lock/guard requires Recover lock confirmation showing the exact path; Cancel leaves it unchanged. Recovery checks ownership and file identity, never age alone. Do not delete an unfamiliar lock just because it is old.

Account switching refuses keyring or auto mode

This store is unsupported. Portwise does not read or switch OS-keyring credentials. Use the official Codex login flow instead. Do not change your real store just to pass a test. For fake-credential testing, disable the Codex panel on the same CODEX_HOME: it can remove a fake auth.json without any Portwise write.

Diagnostics says token/config mismatch, permissions FAIL or Windows writability WARN

For stale config/token delivery, start the gateway, run Configure Codex for Gateway, confirm the intended path, and restart Codex/VS Code. For permissions FAIL, inspect the target ACL/mode; a manual rewrite can replace a private ACL. Diagnostics does not repair it. Windows writability WARN is expected: diagnostics cannot prove a successful write without a write probe, and deliberately makes none.

Development & contributing

Want to have a look around? Use Node.js 22 from .nvmrc; the development packaging tool requires Node 22. The extension's declared runtime minimum remains Node 20.19.

npm ci --ignore-scripts
npm run check
npm run verify
npm run watch

npm run verify produces the local portwise-0.1.2.vsix candidate. You can install that build with code --install-extension ./portwise-0.1.2.vsix or VS Code's Install from VSIX… action.

Press F5 for the Extension Development Host. Tests use fake credentials, temporary homes and port-0 fake upstreams. Never use your real Codex home for tests. npm run test:integration is separate because it may download VS Code and needs a display; CI runs it on Ubuntu with Xvfb and on Windows.

Small PRs are welcome. Read AGENTS.md and the engineering rules, keep changes focused, add regressions for bugs and run verify. A clear reproduction is a lovely contribution too. Report vulnerabilities through GitHub private advisories, not public credential dumps. Development dependency findings remain documented; green CI is not a claim of zero dev advisories.

The Marketplace badges use Shields dynamic images with public data from VSMarketplaceBadges because Shields retired its direct Marketplace routes. Values are cached and can lag the listing; they are not hard-coded counts. This is README badge traffic, not a request made by the extension.

Roadmap / not planned

  • Portwise is available on the Marketplace. The 0.1.2 patch adds real screenshots to the docs; runtime behavior is unchanged from 0.1.1.
  • The panel and Diagnostics captures above come from an isolated 0.1.1 profile. The older Markdown screenshot links remain as landing pages for existing release READMEs.
  • Quota display will be reconsidered only if OpenAI publishes a supported source; no quota reading from auth.json is planned.
  • Account sharing, automatic rotation to evade limits and remote gateway hosting are not planned.

License & release notes

MIT © Dharanidhar Mahata. See the changelog, release notes and build plan.

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
  • Your Privacy Choices
  • Consumer Health Privacy
© 2026 Microsoft