Skip to content

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

@benjaminbauer

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

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