Console
API/Integrations/Codex CLI

Codex CLI

One provider block in ~/.codex/config.toml. Codex speaks the Responses API; AdaptiqAI serves it, with your context read from Native Context Memory for free.

1. The provider

Add the block to your user-level ~/.codex/config.toml (Codex ignores model_provider in a project-local file), and export the key in the shell you run Codex from.

~/.codex/config.toml
# ~/.codex/config.toml
model_provider = "adaptiq"
model = "adaptiq-deepseek-v4.1-flash"
# What Codex may assume about the model; it does not read it from the endpoint.
model_context_window = 1048576
model_auto_compact_token_limit = 1000000

[model_providers.adaptiq]
name = "AdaptiqAI"
# The /v1 is part of the base URL here: Codex appends /responses.
base_url = "https://api.adaptiqai.com/v1"
# The key is read from this environment variable, never written into the file.
env_key = "ADAPTIQ_API_KEY"
# Only "responses" is supported by Codex since February 2026.
wire_api = "responses"
bash
export ADAPTIQ_API_KEY="ak-..."
codex
wire_api must be responses
Codex removed Chat Completions on 2026-02-03; wire_api = "chat" fails at startup. AdaptiqAI serves POST /v1/responses as Codex sends it: streamed, store: false, reasoning items, function tools. previous_response_id is not needed; the session's memory is held on our side.

2. What the usage fields mean

The final response.completed event carries the Responses usage object, and beside it an adaptiq block with the four classes of the price card and the cost. input_tokens is the whole logical context (what the model could attend); input_tokens_details.cached_tokens is the part served from Native Context Memory, which is free. The difference is what you pay input for.

json
"usage": {
  "input_tokens": 312000,
  "input_tokens_details": {"cached_tokens": 310500},
  "output_tokens": 1840,
  "output_tokens_details": {"reasoning_tokens": 1200},
  "total_tokens": 313840
},
"adaptiq": {
  "input_tokens": 1500,
  "memory_write_tokens": 1500,
  "memory_read_tokens": 310500,
  "output_tokens": 1840,
  "cost_usd": "0.004580",
  "price_card": "2026-11-17"
}

cached_tokens = memory_read_tokens, always. input_tokens − cached_tokens = the adaptiq.input_tokens you are charged for. Codex shows the cached share in /status. The price card has the prices; the three shapes show the same request as Chat Completions and Anthropic Messages.

Turn the harness's own compaction off
Native Context Memory keeps the history outside the prompt. model_auto_compact_token_limit above keeps Codex from summarising the conversation on its own before the memory has it.
Was this page helpful?