Codex CLI
Run the OpenAI Codex CLI on sference: one-command launch, or a sference profile next to your OpenAI setup.
Codex CLI
The Codex CLI talks to the OpenAI Responses API, and sference serves that API for open models. Run it through the launcher, or add a sference profile and start Codex with --profile sference. Either way, your OpenAI setup keeps working as before.
Fastest path: sference launch codex
The sference CLI can configure and start Codex for one session:
sference launch codex
sference launch codex --model zai-org/GLM-5.3
sference launch codex -- exec "fix the failing test" # forward flags after --It defines a sference provider through codex -c overrides, so ~/.codex/config.toml is never modified. Run codex as usual to go back to OpenAI. Add --dry-run to print the provider config and command without starting Codex.
Configure
Codex reads named profiles from separate files next to ~/.codex/config.toml. Create ~/.codex/sference.config.toml:
model = "zai-org/GLM-5.3"
model_provider = "sference"
model_reasoning_effort = "medium"
model_context_window = 1048576
web_search = "disabled"
[model_providers.sference]
name = "Sference"
base_url = "https://api.sference.com/v1"
env_key = "SFERENCE_API_KEY"
wire_api = "responses"Then export the key and start Codex with the profile:
export SFERENCE_API_KEY="sk_..."
codex --profile sferenceenv_key names the environment variable Codex reads for the bearer token, so the key never lives in the config file. The other settings matter:
wire_api = "responses"is the only value current Codex accepts."chat"was removed upstream in early 2026, and Codex refuses to start with it.web_search = "disabled"is required. Codex otherwise adds OpenAI's hosted web-search tool, and sference accepts only function tools, so every request fails withtools[8] must be a function tool definition.model_reasoning_effortkeeps Codex from sending an effort level that only OpenAI models accept.model_context_windowsets the real window (1M tokens for every current chat model; seecontext_tokensinGET /v1/models), so auto-compaction triggers at the right point.
Codex prints Model metadata for … not found on start. That is expected with a hand-written profile and harmless; sference launch codex avoids it by generating a model catalog for Codex.
Sference Switch uses the same file
Sference Switch manages ~/.codex/sference.config.toml itself (sference-switch codex on). If you use Switch, let it own the file and skip this section.
Choosing a model
model = "zai-org/GLM-5.3" # general coding turns
# model = "zai-org/GLM-5.3-Flash" # fast edits, 0.20 / 0.60 per 1M
# model = "moonshotai/Kimi-K3" # hard planning, 3.00 / 15.00 per 1MLive ids and rates: GET https://api.sference.com/v1/models.
Switching providers
Your ~/.codex/config.toml is never changed, so moving between providers is a matter of how you start Codex:
codex # OpenAI, as usual
codex --profile sference # sferenceCost control
- Prefix caching. Codex resends the system prompt and tool definitions every turn. Keep them stable and first so they bill at the cached rate. See Prompt caching.
max_output_tokenson reasoning models covers hidden reasoning, so cap it to avoid burning budget before the agent acts.- Per-engineer attribution. One key per engineer shows up separately in
GET /control/v1/usage/by-key. See Usage & analytics.
It is a compatibility layer
Open models plan differently and call tools less reliably than frontier closed models on long repo work. Validate on your own repository before committing a workflow. See SferenceCode for what to expect.