Codex CLI
Run OpenAI Codex CLI on OhMyGPT with your OhMyGPT key, on GPT or any other model in the catalog.
Codex CLI runs on OhMyGPT with one provider entry in its config file. Your OhMyGPT key then gives Codex the GPT models and the rest of the catalog, switchable per run with codex -m. You can test the whole setup for free with ohmygpt/mock.
Configure
Add the provider to ~/.codex/config.toml:
model = "openai/gpt-5.5"
model_provider = "ohmygpt"
[model_providers.ohmygpt]
name = "OhMyGPT"
base_url = "https://api.ohmygpt.com/v1"
env_key = "OHMYGPT_API_KEY"
wire_api = "responses"Codex reads your key from the variable named in env_key. Export it in the shell that runs Codex:
export OHMYGPT_API_KEY="sk-..."
codexbase_urlends in/v1. Codex appends/responses.wire_api = "responses"selects the Responses API, which Codex uses for every provider.modelis any model ID from Choose a model. To use another model for one run, start Codex withcodex -m <model id>.
Check the connection
Send a Responses request, the kind Codex sends, to the free test model ohmygpt/mock:
curl https://api.ohmygpt.com/v1/responses \
-H "Authorization: Bearer $OHMYGPT_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "ohmygpt/mock", "input": "ping"}'{
"id": "resp_MRazQMjAopUMBIjoOfs2bSUL",
"object": "response",
"status": "completed",
"model": "mock",
"output": [
{
"type": "message",
"id": "msg_0",
"role": "assistant",
"status": "completed",
"content": [
{
"type": "output_text",
"text": "This is a mock reply from OhMyGPT. Your integration works; switch to a real model when ready."
}
]
}
],
"usage": { "input_tokens": 15, "output_tokens": 17, "total_tokens": 32 }
}To run Codex itself at no cost, start it with codex -m ohmygpt/mock. The mock calls the first tool Codex declares, gets the result back and replies with text, so you see one full turn of the agent loop. The mock is available once your account has been topped up.
Choose a model
List the models you can use with Codex:
curl -s https://api.ohmygpt.com/v1/models \
| jq -r '.data[] | select(.available and any(.protocols[]?; .id == "openai-responses")) | .id'Prices for each are on the Models page.
Codex is tuned for OpenAI's GPT models, and openai/gpt-* IDs give you the full experience. Other models in the list, such as zhipu/glm-5.3, run Codex too, including its tool calls and reasoning settings.
Troubleshooting
| Symptom | Cause | Fix |
|---|---|---|
Missing environment variable: `OHMYGPT_API_KEY`. | The variable is not exported in the shell that runs Codex | export OHMYGPT_API_KEY=..., then start Codex again |
`wire_api = "chat"` is no longer supported. | The provider entry uses an older Codex setting | Set wire_api = "responses" |
Every request returns 404 | base_url is missing /v1, so requests go to /responses | Set base_url = "https://api.ohmygpt.com/v1" |
401 with Invalid API key | The key is mistyped or was deleted | Copy a key from API keys |
404 saying the model does not exist | The ID is misspelled | Copy the ID from GET /v1/models |
402 | The balance or the key's spending limit is used up | Top up at Billing |
Every response carries an X-Request-ID header, and Usage shows what each request cost.