Codex API Gateway

Connect Codex CLI to gw-link: config.toml and auth.json

Codex CLI uses the OpenAI Responses API. gw-link serves a compatible /v1/responses endpoint: declare a model provider pointing at https://gw-link.com/v1 in ~/.codex/config.toml, put your key in ~/.codex/auth.json, and both the CLI and the IDE extension are ready.

Get started · View pricing

Native Responses API

With wire_api = "responses", Codex tool calls, reasoning and streaming go straight to /v1/responses — no extra proxy.

Shared account with Claude Code

One gw-link account can issue separate keys for Codex and Claude Code, with balance and usage in one place.

Works in scripts and CI

Non-interactive commands such as codex exec read the same config.toml, so automation reuses one setup.

How to connect Codex

  1. Create a key in the gw-link console (OpenAI / GPT group) and open Use Key → Codex.
  2. Save the config.toml content to ~/.codex/config.toml (%USERPROFILE%\.codex\config.toml on Windows).
  3. Save your key to auth.json in the same directory.
  4. Run codex and try a small task to confirm it responds.

Configuration examples

~/.codex/config.toml

base_url must end with /v1; pick a model your console lists.

model_provider = "OpenAI"
model = "gpt-5.5"
review_model = "gpt-5.5"
disable_response_storage = true

[model_providers.OpenAI]
name = "OpenAI"
base_url = "https://gw-link.com/v1"
wire_api = "responses"
requires_openai_auth = true

~/.codex/auth.json

{
  "OPENAI_API_KEY": "sk-your-gw-link-key"
}

FAQ

Does Codex's base_url need /v1?

Yes. Codex appends /responses directly, so use https://gw-link.com/v1 — the opposite of Claude Code.

What should wire_api be?

"responses". Current Codex releases only speak the Responses API, which gw-link's /v1/responses supports.

Codex asks me to sign in to ChatGPT — what now?

Check that model_provider in config.toml points at the provider you defined and that ~/.codex/auth.json contains OPENAI_API_KEY. With both in place Codex uses the key directly.

Can Codex and Claude Code share gw-link?

Yes. Each uses its own config file; you can give them separate keys under one account to track usage independently.

中文版

Last updated: