Using another model for one Codex session: codex -m

Coding with AICodex CLI·· 16 views· 2 min read

Codex starts with the model in the model line of ~/.codex/config.toml. To use another one just this time, without touching the file, use the -m option (or --model).

The command

codex -m zai-org/glm-5.2

The value is the catalogue id, exactly as it is, with the slash. The provider is still the one in the file: only the model changes. It also works in non-interactive mode, with codex exec -m deepseek-ai/deepseek-v4-flash "...".

When to use each model

Model Context What for
moonshotai/kimi-k2.7-code 262,144 tokens Made for coding: the best starting point for everyday work.
deepseek-ai/deepseek-v4-pro 1,048,576 tokens Strong reasoning, for large changes and hard bugs.
zai-org/glm-5.2 1,048,576 tokens Built for agents: uses tools well in long tasks.
deepseek-ai/deepseek-v4-flash 1,048,576 tokens Fast and cheap, for background tasks and short questions.

For a model you use often: a profile

A profile is a file next to config.toml, named <profile>.config.toml. The keys go at the top of the file. For example, ~/.codex/fast.config.toml:

model = "deepseek-ai/deepseek-v4-flash"

codex --profile fast

The profile is layered on top of your config.toml, so the provider stays the same.

Checking the model

Inside Codex, /status shows the active model and the context still left.

A wrong id gives 404 model_not_found in Codex. Copy the id from the Models tab or from GET /v1/models.
-m saves nothing. To change the starting model for good, change the model line in ~/.codex/config.toml. With the Coding Plan, the models in the plan spend points and the others spend credits: the list is in the Plan tab.

Want to code with AI in Codex? Visit the Coding with AI page.

See Coding with AI

SEE ALSO

Codex CLI with All in One AI: creating config.toml, the key and the model

Which models to use in Codex CLI: Kimi K2.7 Code, DeepSeek V4 Pro, GLM 5.2 and others

Codex in a project: why .codex/config.toml cannot change the provider

Coding Plan: which plan to choose, what it costs and how to subscribe

Coding with AI in All in One AI

RECOMMENDED PRODUCT

Web hosting with cPanel

Domain and SSL included, daily backups and the panel you already know. from 321,75 MT/mo (3-year plan, with coupon)

See plans
Was this answer helpful? Your answer helps us improve this article.