Skip to content
Every guide

Guide · Codex

Use ScaledThought with Codex

Codex can use ScaledThought's open-weight models as its own model provider: add a scaledthought provider with wire_api = "responses" to ~/.codex/config.toml, load ST_API_KEY into the shell and start codex.

Deep links into apps you have installed. Claude and Claude Code are trademarks of Anthropic; Codex is a trademark of OpenAI. ScaledThought is not affiliated with or endorsed by either.

Or run it yourself:

Before you start

POST $ST_BASE_URL/responses speaks the OpenAI Responses API, so clients that use only that protocol, such as Codex, can use ScaledThought as their model provider. It takes input (a string, or messages, function_call and function_call_output items), instructions, function and custom (freeform) tools, tool_choice, max_output_tokens, text.format for JSON output and stream: true (Responses events, ending with response.completed or response.incomplete with its usage, or response.failed with an error).

It is stateless. We store no responses, so send the whole conversation in input every turn (Codex does) and leave out previous_response_id, which returns 400 invalid_request; store is always false. Hosted tools such as file search return 400; a web search tool is ignored. Requests without max_output_tokens get a cap of what the model's context leaves after your prompt, at most 32,768 tokens.

01

Create the account

Paste the prompt above into your coding agent, or run the command yourself in your project's directory. It creates the account, writes ST_API_KEY and ST_BASE_URL to ./.env (mode 0600) and adds .env to .gitignore. Only the US region is open; Canada is coming soon.

shell
npx -y scaledthought@0.3 init --region us --source org-codex

02

Buy credits

Usage is prepaid, so a new account answers 402 insufficient_credits until its first top-up. This prints a payment link and opens it in your browser; nothing is charged until you pay on it. How prepaid credits work

shell
npx -y scaledthought@0.3 billing topup --amount-usd 20
npx -y scaledthought@0.3 billing wait

03

Add the provider

Add this to ~/.codex/config.toml. npx -y scaledthought@0.3 models --live lists every model live in your region; the examples use deepseek-v4-1-flash.

~/.codex/config.toml
# ~/.codex/config.toml
model = "deepseek-v4-1-flash"  # or a model id from `npx -y scaledthought@0.3 models --live`
model_provider = "scaledthought"

[model_providers.scaledthought]
name = "ScaledThought"
base_url = "https://api.us.scaledthought.com/v1"  # your ST_BASE_URL
env_key = "ST_API_KEY"
wire_api = "responses"
model_catalog_url = "https://api.us.scaledthought.com/v1/codex/models"  # same host (and region) as base_url

04

Start Codex with the key

Codex reads the key from the environment, not from .env, so load it first.

shell
set -a; . ./.env; set +a  # puts ST_API_KEY in the environment
codex

Notes

  • Codex reads ST_API_KEY from the environment, so load ./.env into the shell first. wire_api = "responses" is required: ScaledThought serves Codex over the Responses API.
  • model_catalog_url tells Codex the context windows of the models live in your region, so it compacts long sessions in time, and gives it its apply_patch editing tool. It is built from the live models on every request; Codex sends your key with it, so keep it on the same host as base_url (your region's).

Sources

Questions

Why does Codex need wire_api = "responses"?
Codex speaks the OpenAI Responses API, and ScaledThought serves it at POST /v1/responses. It is stateless: Codex sends the whole conversation every turn, and previous_response_id returns 400.

Read next

ScaledThought is not affiliated with or endorsed by the makers of Codex. Codex is a trademark of its owner. Not affiliated with or endorsed by Anthropic, OpenAI, Cursor or any model publisher. Claude, Claude Code, Codex, Cursor, OpenAI and model names are trademarks of their owners.

Agent view · paste this into your agent

Opens your agent with the prompt typed. You press Enter.

Deep links into apps you have installed. Claude and Claude Code are trademarks of Anthropic; Codex is a trademark of OpenAI. ScaledThought is not affiliated with or endorsed by either.

Agents can read the whole site as markdown at scaledthought.com/llms.txt.