Codex
Connecting Codex CLI to Morphogen through config.toml.
Codex CLI uses the Responses API. Morphogen accepts this format for any text model, but does not store response history: see the "Responses limitations" section.
Setup
Add a provider to ~/.codex/config.toml:
model = "gpt-6-sol"
model_provider = "morphogen"
[model_providers.morphogen]
name = "Morphogen"
base_url = "https://api.morphogen.ru/v1"
env_key = "MORPHOGEN_API_KEY"
wire_api = "responses"Codex reads the key from the MORPHOGEN_API_KEY environment variable and does not write it to a file. In model, any text model from GET /v1/models works.
Check
export MORPHOGEN_API_KEY=mg-...
codex exec "ответь одним словом: работает?"Responses limitations
Morphogen does not store response history. In POST /v1/responses you cannot pass "store": true and previous_response_id: the request returns 400 stateful_not_supported. The client sends the full history in every request, as in Chat Completions.
Current Codex CLI versions (checked on 0.162.1) accept only wire_api = "responses": the client rejects "chat" with wire_api = "chat" is no longer supported. There is no fallback through Chat Completions, so configure Codex through Responses as in the example above.
Money reserve and key limits
Codex does not send max_output_tokens, so Morphogen reserves money for the maximum response of the model. The reserve equals the model's response ceiling times its output price from the catalog (prices are in the console, «Models» section). For gpt-6-sol the ceiling is 128,000 tokens, and as of October 10, 2026 the reserve is about 154 ₽ plus the cost of the input. If the daily limit of the key or the balance is below this amount, the request gets 402 key_limit_exceeded or insufficient_funds, although the response itself would cost a few kopecks.
What to do:
- Give the Codex key a daily limit above the reserve (from 200 ₽ for
gpt-6-solas of October 10, 2026) and keep at least that amount on the balance. - Choose a model with a lower output price: the response ceiling of the catalog text models is the same (128,000 tokens), so the price sets the reserve. For example, as of October 10, 2026 the reserve for
gpt-6-lunais about 8 ₽, and Codex works with it under a small limit:codex exec -m gpt-6-luna "…"ormodel = "gpt-6-luna"inconfig.toml. Model prices are in the console, «Models» section.
Common errors
| Symptom | Cause | What to do |
|---|---|---|
400 stateful_not_supported | the request has store: true or previous_response_id | Morphogen does not store response history: check the Codex version and the settings that turn storage on |
| 401 | MORPHOGEN_API_KEY is not set or the key is revoked | check the variable in the same terminal |
403 model_not_allowed | the model is not in the key's list | choose a model from GET /v1/models |
402 key_limit_exceeded | the daily or monthly limit of the key is below the reserve for the maximum response | raise the key limit or choose a model with a lower output price |
402 insufficient_funds | the balance is below the reserve for the maximum response | top up the balance or choose a model with a lower output price |
Next
- Documentation as MCP for Codex: Documentation as MCP.
- What is supported overall: Compatibility.