Skip to content
✨ agentgateway has joined the Agentic AI Foundation (AAIF) — Learn more

For the complete documentation index, see llms.txt. Markdown versions of all docs pages are available by appending .md to any docs URL.

Page as Markdown

Codex

Configure Codex AI coding tool to use agentgateway

Configure Codex, the AI coding tool by OpenAI, to route requests through your agentgateway proxy.

Before you begin

  1. Install the agentgateway binary.
  2. Install Codex (npm install -g @openai/codex).

Configure agentgateway

Start agentgateway with an OpenAI backend configuration. The wildcard * model name accepts any model. Codex sends the model in each request, so you do not need to pin a specific model.

  1. Create a configuration file.

    cat > config.yaml << 'EOF'
    # yaml-language-server: $schema=https://agentgateway.dev/schema/config
    llm:
      models:
      - name: "*"
        provider: openAI
        params:
          apiKey: "$OPENAI_API_KEY"
    EOF
  2. Start agentgateway.

    agentgateway -f config.yaml
For wildcard model matching, rate limiting, and other options, see the OpenAI provider page.

Connect Codex to agentgateway

Point Codex at agentgateway through one of the following methods.

Codex uses the OPENAI_BASE_URL environment variable to override the default OpenAI endpoint. Use a base URL that includes /v1 so requests go to /v1/responses and OpenAI does not return 404.

export OPENAI_BASE_URL="http://localhost:4000/v1"
codex

Verify the connection

  1. Send a test prompt through agentgateway.

    codex "Hello"
  2. Verify that the request appears in the agentgateway logs.

    Example output:

    info  request gateway=default/default listener=llm route=internal/model:* endpoint=api.openai.com:443 http.method=POST http.path=/v1/responses http.status=200 protocol=llm gen_ai.operation.name=chat gen_ai.provider.name=openai duration=1687ms

Next steps

Was this page helpful?
Agentgateway assistant

Ask me anything about agentgateway configuration, features, or usage.

Note: AI-generated content might contain errors; please verify and test all returned information.

Tip: one topic per conversation gives the best results. Use the + button in the chat header to start a new conversation.

Switching topics? Starting a new conversation improves accuracy.
↑↓ navigate select esc dismiss

What could be improved?

Your feedback helps us improve assistant answers and identify docs gaps we should fix.

Need more help? Join us on Discord: https://discord.gg/y9efgEmppm

Want to use your own agent? Add the Solo MCP server to query our docs directly. Get started here: https://search.solo.io/.