Guides · Codex CLI
Codex CLI on Layer X1.
Codex talks the OpenAI Responses protocol. One provider block in config.toml points it at the gateway; the key travels through an environment variable.
One command
npx layerx1 setup --tool codex --key lx1_your_keyThe CLI writes the provider block below into ~/.codex/config.toml (with a backup) and prints the export line for your key. See CLI.
By hand
Add a provider to ~/.codex/config.toml. Two details matter: the base URL includes /v1, and the wire protocol is responses.
[model_providers.layerx1]
name = "Layer X1"
base_url = "https://api.layerx1.in/v1"
env_key = "LAYERX1_API_KEY"
wire_api = "responses"
model_provider = "layerx1"
model = "lx1-gpt-oss-120b"Then export the key Codex will read:
export LAYERX1_API_KEY=lx1_your_keymodel accepts any catalog id — a coding flagship like lx1-glm-5 is a strong daily driver for heavy sessions.
Troubleshooting
- Empty responses? Reasoning models spend hidden reasoning tokens from
max_output_tokens— a very low budget can be consumed before any text is emitted. Raise it (4,000+ is a safe floor) or pick a non-reasoning model. - 401 unauthorized? Codex reads the key from the variable named in
env_key— make sureLAYERX1_API_KEYis exported in the shell that launches it. - 404s? Unlike Claude Code, the Codex base URL must end in
/v1. - Protocol errors? Keep
wire_api = "responses"— the gateway serves the Responses dialect on/v1/responsesfor exactly this client.
Note
Switching models mid-project is a one-line change to model — the provider block stays put.