Skip to content

Support custom Codex CLI model providers and auth (e.g. Portkey, Azure OpenAI) #644

Closed

Description

@benjaminbauer

Environment

  • OS: Linux (Arch)
  • t3code version: 0.0.8
  • Codex CLI version: 0.112.0
  • Custom provider: Portkey (model_provider = "portkey" in ~/.codex/config.toml)

Codex CLI config (working standalone)

  model_provider = "portkey"

  [model_providers.portkey]
  base_url = "https://api.portkey.ai/v1"
  env_key = "PORTKEY_API_KEY"
  wire_api = "responses"

Running codex directly from the terminal works without issues.

Problem

t3code does not work when the Codex CLI is configured with a custom model_provider in ~/.codex/config.toml (e.g. Portkey, Azure OpenAI
proxy). Two issues prevent this:

Auth check rejects custom provider authentication

t3code runs codex login status and parses the output for strings like "not logged in":

  // apps/server/dist/index.mjs ~L15531
  const authProbe = yield* runCodexCommand(["login", "status"])
  // apps/server/dist/index.mjs ~L15424
  function parseAuthStatusFromOutput(result) {
      const lowerOutput = `${result.stdout}\n${result.stderr}`.toLowerCase();
      // ...
      if (lowerOutput.includes("not logged in") || lowerOutput.includes("login required")
          || lowerOutput.includes("authentication required")
          || lowerOutput.includes("run `codex login`")
          || lowerOutput.includes("run codex login")) return {
          status: "error",
          authStatus: "unauthenticated",
          message: "Codex CLI is not authenticated. Run `codex login` and try again."
      };

When using a custom model provider, authentication is handled via environment variables (e.g. PORTKEY_API_KEY), not via codex login.
The CLI works perfectly fine — but codex login status still reports "not logged in" because there's no ~/.codex/auth.json. t3code
treats this as a hard error.

Provider is hardcoded to "codex"

The session object unconditionally sets the provider:

  // apps/server/dist/index.mjs ~L9580
  const session = {
      provider: "codex",
      // ...
  };

There is no path to configure or detect alternative providers.

Portkey needs specific headers, which the model_provider of the codex cli handles. In this case: {"status":"failure","message":"Either x-portkey-config or x-portkey-provider header is required"}

Expected behavior

t3code should respect the Codex CLI's configured model provider and not require codex login when a custom provider with env-based auth
is configured.

Suggested fix

  • Skip or downgrade the codex login status check when the CLI has a custom model_provider configured (e.g. by checking codex config
    output or parsing ~/.codex/config.toml)
  • Read the provider from the Codex CLI config instead of hardcoding "codex"

Related

Activity

  1. added a commit that references this issue on Mar 9, 2026
    9dc1b81
  2. ofcljaved commented on Mar 9, 2026

    @ofcljaved

    Yes I faced this issue as well with Missing AZURE_API_KEY, for this I just did normal codex login so it stopped showing the login issue but this API_KEY issue is consistent and it won't even pick the correct model from the config

  3. benjaminbauer commented on Mar 9, 2026

    @benjaminbauer
    Author

    extra challenge for portkey: even if I were to "fake" the codex login, it would still not send the required headers for portkey

  4. SHJordan commented on Sep 12, 2026

    @SHJordan

    What about using the codex -p "profile name" ?it sure works for me...

    Just not on T3 Code.

    You see, one would think using the launch arguments like -p ZAIwould fix it... nope....

    Still getting "· Codex app-server provider probe failed: Codex App Server process exited with code 2."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions