Skip to content

Codex CLI

OpenAI’s Codex CLI talks to providers through the Responses API, which OpenPike serves at /v1/responses. Add OpenPike as a custom model provider in Codex’s config, and every Codex request goes through your virtual key, budgets and Logs.

OpenPike endpoint POST /v1/responses
Base URL https://api.openpike.dev/v1
Key A virtual key, from the environment variable named in env_key
Models openai/<model>, for example openai/gpt-5.4; also xai/, groq/ and openrouter/ models
Tags http_headers in the provider config

1. Add a provider key and create a key for Codex

Section titled “1. Add a provider key and create a key for Codex”

Add your OpenAI API key (or an xAI, Groq or OpenRouter key) on the Providers page. Then, on the Keys page, create a virtual key for Codex and set it as an environment variable:

Terminal window
export OPENPIKE_API_KEY="opk_live_..."

Add a model provider to ~/.codex/config.toml and make it the default:

~/.codex/config.toml
model = "openai/gpt-5.4"
model_provider = "openpike"
[model_providers.openpike]
name = "OpenPike"
base_url = "https://api.openpike.dev/v1"
env_key = "OPENPIKE_API_KEY"
wire_api = "responses"
http_headers = { "x-openpike-tags" = "agent=codex" }
  • model is OpenPike’s provider/model name. An alias made for the Responses endpoint works too, for example openpike/codex.
  • env_key names the variable Codex reads the virtual key from. Codex sends it as Authorization: Bearer.
  • wire_api = "responses" is Codex’s only supported value, and the format OpenPike serves at /v1/responses.
  • http_headers adds x-openpike-tags to every request, so Codex’s requests show as the agent codex in Logs, Activity and Agents.

A run budget caps one task’s spend, requests and time. http_headers values are fixed, but env_http_headers maps a header to an environment variable, so each task can carry its own run ID:

~/.codex/config.toml
[model_providers.openpike]
# ...as above, plus:
env_http_headers = { "x-openpike-run" = "OPENPIKE_RUN", "x-openpike-run-label" = "OPENPIKE_RUN_LABEL" }
Terminal window
OPENPIKE_RUN="triage-$(date +%s)" OPENPIKE_RUN_LABEL="Nightly triage" codex exec "triage the open issues"

Once the run reaches a cap, Codex’s requests get 429 run_limit_exceeded and the task stops. Set a new OPENPIKE_RUN for each task.

To keep your normal Codex setup and use OpenPike only sometimes, leave out the first two lines and pick the provider per run: codex -c model_provider=openpike -m openai/gpt-5.4.

Codex also works with Groq models through OpenPike’s Responses endpoint: add your Groq key on the Providers page and change the model line. The provider block stays the same.

~/.codex/config.toml
model = "groq/openai/gpt-oss-120b"

Everything after groq/ is Groq’s own model ID, here OpenAI’s open-weight gpt-oss-120b as Groq serves it. Groq’s Responses API is in beta, and its built-in tools (browser search, code execution) work only on openai/gpt-oss-20b and openai/gpt-oss-120b, according to Groq’s docs. Groq’s GPT OSS and Qwen models are priced from Groq’s own models page, so their requests show a cost; Groq’s Llama models are sold through its sales team, have no public price, and show tokens only.

Run a small task, then open Logs: each Codex turn is a request on the Responses endpoint, tagged agent=codex, with its tokens and cost.

Terminal window
codex exec "List the files in this directory and say which one is largest."
  • Requests Codex makes: only POST /v1/responses, streamed, with store: false, so each request carries the whole conversation and OpenAI keeps no state. When Codex compacts a long thread it sends that through /v1/responses as well. Every request counts toward your plan’s monthly requests and your budgets.
  • Budgets and loop limits apply as for any agent. A hard budget or a loop pause stops Codex with a 429; see Stop a runaway agent.
  • Hosted tools such as web search are billed by OpenAI on top of tokens, and are not in OpenPike’s cost. See Usage and cost.
  • Background responses (background: true) are not supported by OpenPike. Codex does not use them.
  • Skill: the OpenPike skills repo has an openpike-setup skill that Codex can load to set this up for you. It never asks for or writes a provider key.