Configuration

ChatGPT subscription

Latch can connect to a ChatGPT account through the OpenAI Codex device authorization service. This is separate from OpenAI API-key billing. Your account must be eligible for Codex and remains subject to its subscription usage limits and organization policy. A ChatGPT subscription does not provide general OpenAI API credits. Latch never switches to API billing when a subscription request fails.

Sign in

In the TUI or Web composer, run:

/login

You can also select ChatGPT subscription in /setup, or sign in before starting an interactive session:

latch login
# For a non-default installation:
latch --config /path/to/config.toml login
  1. Open https://auth.openai.com/codex/device in your browser.
  2. Enter the one-time code displayed by Latch and complete OpenAI sign-in.
  3. Return to Latch. It waits for authorization, saves credentials, and makes the subscription provider available as openai-codex.

Only enter a code for a login you initiated yourself. Never paste access or refresh tokens into a chat, configuration file, issue, or API-key field. You may need to enable device code authorization in ChatGPT's security settings. If your organization disables it, this implementation does not bypass that policy. There is no browser-cookie or external credential-file import.

The Web interface shows a sign-in dialog with a link, code and Cancel button. In the TUI, Ctrl+C cancels while the code is displayed; /login cancel also cancels. The standalone CLI uses Ctrl+C. Authorization expires after 15 minutes. The device flow works over SSH without a local callback listener or port forward.

Interactive login selects the provider for the current session. Existing configured providers and their new-session default are kept, including legacy single-provider installations. OpenCode Go, DeepSeek and ChatGPT subscription remain selectable side by side in /model after setup, login and restart. On a new installation, ChatGPT becomes the new-session default. Use /setup to change that default, and /model to select a model or reasoning effort. Standalone latch login saves the provider but does not change an existing session.

Login now reads the authenticated Codex model catalog rather than exposing only the original 5.4/5.3 entries. The offline fallback includes GPT-6.1 Sol/Terra, GPT-6 Astra/Sol/Luna, GPT-5.6 Sol/Terra/Luna and GPT-5.5. The default for a new subscription configuration is gpt-6.1-sol; existing active profiles/defaults are not silently changed. These are subscription entries, not copied API models.

Run /model refresh to fetch current service metadata, then /model to choose. Refresh automatically follows the official latest stable Codex catalog version; GitHub lookup failures fall back to the last successful version, then an embedded version. This requires no local Codex installation and does not add startup network requests. Version lookup uses no account credentials. A stale query version can hide new models even when their advertised minimum version is older. If an older setup restricted models, /model all clears the local filters. Old 5.4/5.3 descriptors are retained for resume, not presented as the complete current catalog. Service visibility is not a promise of plan entitlement or available quota. Context/effort/image facts come from the service; user overrides win. No API dollar prices are inferred for subscription usage.

Sign out

/logout

Or:

latch logout

This removes local saved ChatGPT tokens. It keeps provider configuration, session history and other providers' API keys. Existing provider objects reload credentials before their next request, including child sessions. Already in-flight requests are not revoked. To revoke remote authorization, use OpenAI's account controls. Select another provider with /model or sign in again.

Storage and security

  • Configuration contains only credential = "oauth:openai-codex" with provider kind openai-codex. OAuth cannot be attached to arbitrary compatible endpoints.
  • Tokens are stored in chatgpt-auth.toml under the configured Latch state directory, normally ~/.latch/. Storage uses the existing private-root and atomic credential writer (0600 on Unix); aliases/hardlinks are refused.
  • chatgpt-auth.lock serializes token rotation across Latch processes. The file may remain after logout; OS lock ownership ends when its file handle closes.
  • Tokens refresh near expiry at request time, not during latch doctor. Setup and doctor can establish local credential presence, not remote validity.
  • Tokens never enter durable events, model context, transcripts or browser metadata. The one-time device challenge is human-only, transient UI state.
  • Subscription requests use the fixed Codex endpoint. Authentication and token HTTP clients do not follow redirects. Provider serialization remains in provider.rs; tool execution and approval rules are unchanged.
  • One locally signed-in ChatGPT account is shared by subscription provider instances within a state directory. Separate state directories isolate accounts.
  • The existing legacy-XDG migration does not transfer this new OAuth file; sign in again after migrating rather than copying rotating refresh tokens.

Troubleshooting and qualification

Message Action
Device sign-in unavailable Enable device code authorization in ChatGPT security settings and check organization policy.
Sign-in expired/cancelled Start /login again and use the newly displayed code.
Token refresh failed / access revoked Run /login again. Do not substitute an API key into the subscription provider.
Subscription access denied Check Codex entitlement and account/organization permissions.
Usage limit reached Wait for your subscription allowance to reset. There is no automatic paid fallback.
Credential files are aliased or too permissive Use ordinary private files in the protected state directory; re-login if necessary.

This is an independent implementation of the Codex device/Responses wire protocol, not a general-purpose OpenAI OAuth developer platform integration. The service uses the public Codex native-client identifier (not a client secret) and Latch identifies requests with originator: latch. OpenAI controls protocol availability, policy and entitlement; this is not an OpenAI endorsement or a promise that the endpoint will remain unchanged.

Deterministic loopback tests cover authorization polling, PKCE token exchange, refresh rotation/concurrency, failure redaction, storage restrictions, cancellation/logout, streaming/tool/reasoning replay and truncated streams:

cargo test -p latch-kernel --lib oauth --locked
cargo test -p latch-cli --bin latch login --locked

They make no external requests and require no account. Live account sign-in and plan/model entitlement require human verification; passing mock tests alone does not establish live-service or native Windows/macOS qualification.

Edit this page on GitHub ↗Source: docs/CHATGPT_LOGIN.md

Type to search. Results stay in your browser.