Skip to content

Codex CLI

Codex CLI provides powerful code generation and completion capabilities directly in your terminal.

Terminal window
npm install -g @openai/codex

Configuring Codex CLI to work with DeepIntShield

Section titled “Configuring Codex CLI to work with DeepIntShield”

Codex talks to DeepIntShield through the OpenAI-compatible HTTP integration. Like the official OpenAI API, Codex expects the base URL to end with /v1. It then calls paths such as /chat/completions under that base.

Set OPENAI_BASE_URL to your DeepIntShield gateway origin plus /openai/v1 (not only /openai, and not the bare gateway root).

DeploymentExample OPENAI_BASE_URL
Local deepintshield-http (default listen)http://localhost:8080/openai/v1
Custom host or porthttp://127.0.0.1:3000/openai/v1
HTTPS in productionhttps://deepintshield.example.com/openai/v1

Using only http://localhost:8080 (without /openai/v1) will not hit the OpenAI integration layer.

Some HTTP clients instead append /v1/... to a host that ends at /openai. That can still reach DeepIntShield, but Codex expects the base to include /v1 — use …/openai/v1 (same idea as OpenAI’s openai_base_url = "https://api.openai.com/v1" in Codex advanced configuration).

If you launch Codex through the DeepIntShield CLI (launcher TUI), it sets OPENAI_BASE_URL for you from your saved base_url in ~/.deepintshield/config.json by appending /openai/v1. You only need the exports below when running the codex binary directly.

To persist values, add the same export lines to your shell profile (for example ~/.zshrc).

Codex loads ~/.codex/config.toml and project .codex/config.toml with a defined precedence order (CLI flags and config files rank above ad-hoc defaults). If you already set openai_base_url there, it can override what you expect from the shell.

Use openai_base_url in config so routing is explicit:

# ~/.codex/config.toml — use your real host and scheme
openai_base_url = "http://localhost:8080/openai/v1"

For a one-off run without editing the file:

Terminal window
codex -c 'openai_base_url="http://localhost:8080/openai/v1"'

Always run codex from the same terminal session where you exported variables (or restart the terminal after changing your profile). GUI-launched terminals or IDEs may not see shell-profile exports unless the environment is configured there too.

Codex CLI supports multiple authentication methods. Choose the one that matches your account type.

If you have a ChatGPT Plus, Pro, Team, Enterprise, or Edu subscription, Codex CLI authenticates via browser-based OAuth — no API key needed.

  1. Set the DeepIntShield OpenAI base URL (see Setting the base URL manually)

    Terminal window
    export OPENAI_BASE_URL=http://localhost:8080/openai/v1
  2. Run Codex and sign in

    Terminal window
    codex

    Select Sign in with ChatGPT and authenticate via your browser. All traffic automatically routes through DeepIntShield.

For users with OpenAI API keys or DeepIntShield virtual keys:

  1. Configure environment variables (OPENAI_BASE_URL must be …/openai/v1; see Setting the base URL manually)

    Terminal window
    export OPENAI_API_KEY=your-api-key # OpenAI API key or DeepIntShield virtual key
    export OPENAI_BASE_URL=http://localhost:8080/openai/v1
  2. Run Codex

    Terminal window
    codex

Now all Codex CLI traffic flows through DeepIntShield, giving you access to any provider/model configured in your DeepIntShield setup, plus observability and governance.

Use the --model flag to start Codex with a specific model:

Terminal window
codex --model gpt-5-codex
codex --model gpt-5.4-pro

Switch models mid-session with the /model command:

Terminal window
/model gpt-5.4-pro
/model gpt-5-codex

DeepIntShield automatically translates OpenAI API requests to other providers, so you can use Codex CLI with models from Anthropic, Google, Mistral, and more. Use the provider/model-name format to specify any DeepIntShield-configured model.

Terminal window
# Start with an Anthropic model
codex --model anthropic/claude-sonnet-4-5-20250929
# Start with a Google model
codex --model gemini/gemini-2.5-pro
# Switch mid-session
/model anthropic/claude-sonnet-4-5-20250929
/model mistral/mistral-large-latest

DeepIntShield supports the following providers with the provider/model-name format:

openai, azure, gemini, vertex, bedrock, mistral, groq, cerebras, cohere, perplexity, xai, ollama, openrouter, huggingface, nebius, parasail, replicate, vllm, sgl