# Native Codex custom endpoints The native desktop operator may save a custom Responses endpoint and key, then choose **Codex ยท Custom endpoint** for an individual chat. Saving does not require a model or a successful compatibility check. Ordinary **Codex** retains its native configuration and sign-in. Both choices use native Codex app-server; a gateway that implements Chat Completions alone is insufficient. Session create/update requests use `backend: "codex"` with `codex_provider: "default" | "custom"`; missing selection means `default`. Provider selection is returned in session detail and summary, preserved by forks, and can change between ordinary and custom Codex in the same native conversation. Saving the custom endpoint updates all custom chats, including chats retaining older credential revisions. Existing turns, active goals, children, side answers and background terminals keep their original owner until idle; the saved selection then takes effect automatically or at the next admission. Reload Codex also adopts settings saved before this behavior was introduced. The session retains its native thread, history and goal. On native versions where unsubscribe only removes the subscription, the handoff archives the idle parent once to release its process-owned writer. Native archive also moves descendants, so AgentsDock first records every previously unarchived descendant and restores each through native unarchive; per-thread durable markers preserve recovery after interruption. Already archived descendants remain archived. Legacy child markers are cleared only after native relationship, terminal-state, and existing unarchived-rollout proof. This does not archive the AgentsDock chat. Ordinary account credentials are untouched. Resetting the endpoint lets active work finish, then requires custom chats to configure an endpoint again; it never silently switches billing to the ordinary account. Pending selections are persisted separately from effective session settings. The public `codex_provider_control` reports active/requested providers and endpoint URLs. The existing `provider_runtime_changed` event with `runtime: "codex_provider"` carries the updated public session, including the exact credential-scoped catalog. No model request or compatibility probe runs merely because settings were saved. A native provider switch retains opaque encrypted reasoning and compaction history. A genuinely different upstream may reject that history; AgentsDock does not strip or rewrite it, replay a failed turn, or claim universal cross-provider portability. The runtime catalog publishes separate `backends.codex.custom_provider` metadata. Model discovery excludes affirmative non-chat capabilities such as embeddings and image generation. Unfamiliar models remain selectable and can also be entered manually. Per-model `model_capabilities` report `compatibility` as `unverified`, `verified`, or `unsupported`, plus model-specific reasoning settings. Explicit endpoint effort lists and support flags take precedence, including empty lists and denials. When the endpoint declares an OpenAI-owned Responses model without reasoning metadata, its final model ID may use the exact matching installed Codex model's effort levels from a credential-free offline catalog. This supplies selectable levels without claiming gateway compatibility; unfamiliar models and successful basic checks do not imply effort support. Empty per-model efforts mean no effort should be sent, not that clients should fall back to ordinary Codex defaults. Saved endpoint discovery persists model IDs and effort metadata privately by credential revision, so reopening after a server restart retains the choices. New revisions do not load an earlier revision's saved catalog; compatibility-check status and summary evidence retain their separate rules below. Custom turns explicitly replace native collaboration settings to clear an inherited or earlier reasoning effort. Summary requests are independent: `reasoning_summary_supported: true` enables `summary: "auto"`; unknown or unsupported models use `none`. Support comes from explicit endpoint model metadata or an actual summary observed by the optional model check, never from a model name or effort support. Each custom process launch also prepares a private catalog from the installed executable's offline model metadata. It preserves native tools and instructions while removing built-in reasoning defaults, permitting explicit summary requests, and selecting standard Responses instead of the internal Lite serializer. This does not remove the complete `reasoning` object from every native request: an endpoint must still accept the actual Responses request generated by its installed Codex version. Ordinary account turns retain their existing settings and catalog. Administrative routes require native admin authentication, reject browser-origin requests, and disable response caching: | Method | Route | Purpose | | --- | --- | --- | | GET | `/api/admin/codex/provider` | Saved endpoint identity and whether a key exists; never returns the key. | | POST | `/api/admin/codex/provider/test` | Explicit, optional basic model compatibility check using native Codex. | | GET | `/api/admin/codex/provider/models` | Refresh the saved endpoint's catalog; optional `session_id` selects a chat's currently active endpoint. | | POST | `/api/admin/codex/provider/models` | Discover models using entered endpoint credentials. | | PUT | `/api/admin/codex/provider` | Save `base_url` and a freshly entered `api_key`; `model` is optional. | | DELETE | `/api/admin/codex/provider` | Reset the current custom endpoint selection. | A saved-model check accepts `{model, session_id?, credential_id?}` without resubmitting the key. A supplied credential revision must match the current endpoint or selected chat; stale requests fail with HTTP 409. A chat can check its retained endpoint after settings replacement, but not after Forget/reset. For older clients, `/test` also accepts entered `{base_url, api_key, model?}`; omitting the model performs discovery only. Save remains independent of both operations. HTTPS is required except for literal loopback HTTP. URLs cannot contain credentials, query strings, fragments, or a `/responses` or `/chat/completions` operation suffix. Inputs are bounded and validation errors never echo supplied values. Discovery does not follow redirects or forward provider keys to another host. Credentials live in a private `codex-provider` directory under the administrative state directory. Mode-0600 credential records are bound to a normalized endpoint and retained by revision for existing conversations. They are not encrypted at rest. Native config and process arguments contain the dedicated environment-variable name, never the key. Normal OpenAI/ChatGPT credentials are not copied to the custom endpoint. The legacy `/api/admin/codex/auth/api-key` mutation is disabled; use the custom endpoint routes instead. The basic compatibility check owns a separate native app-server with a fresh temporary `CODEX_HOME`, ephemeral auth/thread state, temporary logs/databases, disabled integrations, and empty turn environments. It asks native `update_plan` to complete one harmless step and handles one in-memory dynamic ping. The model must return the random token supplied only in that tool result, then repeat it in a subsequent turn on the same thread. Other dynamic and approval requests are declined. No workspace commands or model-generated scripts are dispatched by the server. A successful result is **Basic compatibility checked**, with `scope: "isolated_native_tools_and_continuation"` and `checks` for `native_tool_call`, `tool_roundtrip`, and `continuation`. It does not certify every production tool schema, workspace tool, integration, or reasoning effort setting. A text-only response is inconclusive. Explicit protocol, model, or unsupported-parameter rejection during these basic checks reports `unsupported`; authentication, connectivity, and incomplete checks remain `unverified`. After the basic checks succeed, the same operator-requested operation makes one additional, tool-free summary check, limited to 10 seconds within the shared 45-second budget. An actual native summary on a completed turn records `reasoning_summary_supported: true`; a specific summary-parameter rejection records `false`. An absent summary, unrelated error, or timeout supplies no new evidence and preserves basic compatibility success. The separate `summary_check` field is `supported`, `unsupported`, `inconclusive`, or `not_checked`. Saving, discovery, and ordinary chat turns never launch this check. Basic compatibility observations are cached in memory per endpoint, key, and model and clear on server restart. Explicit summary observations for saved endpoints persist in separate private, atomic mode-0600 records scoped to the exact credential revision and model; fresh negative evidence replaces an earlier positive observation. If optional metadata cannot be written, the successful result remains available in memory for the current server process. Entered, unsaved checks do not persist summary evidence. New credential revisions do not inherit previous proof. In-flight work retains its original revision until handoff; Forget/reset revokes that revision for new checks and admissions. The total check budget is 45 seconds, followed by owned-process cleanup. Results use fixed, secret-safe messages and never expose raw provider errors. Checks do not save credentials or change a chat's provider. There are no automatic probe retries. Configured readiness means only that a local key exists; unknown models remain available for deliberate selection. Ordinary custom-endpoint chats retain the installed Codex runtime's bounded HTTP and stream retries. The no-retry overrides apply only to explicit connection checks and offline catalog inspection. Recovery stays inside the native turn; AgentsServer does not replay the entire user task or synthesize a successful completion when the endpoint closes an incomplete stream. Use pure-module or AST-isolated tests and controlled localhost Responses fixtures. Do not import the server monolith or use production credentials to test this feature. Custom chat managers use an owned loopback Responses transport to preserve errors from gateways that send an untyped SSE `error` object and then close the stream. Only those malformed error frames become `response.failed`; valid frames and already typed errors pass through unchanged. HTTP status and retry headers are preserved. Native Codex still owns retries, and no successful completion or whole-turn replay is synthesized. The transport adds no execution deadline. Each transport is bound to one immutable endpoint and credential revision. The native process receives an ephemeral loopback token; the configured provider key is sent only to that transport's fixed upstream. Public endpoint identity remains the configured URL. Disconnect cancels a pending upstream request, including while waiting for response headers; closing the native manager closes its owned listener and requests. A parser buffer bound passes large frames through without limiting the response content. Ordinary Codex traffic does not use this transport.