DocsCodex CLI setup

Set up Codex CLI with MYUSAPI: a custom provider in config.toml

Recent Codex CLI versions no longer read OPENAI_BASE_URL. Declare a custom provider in ~/.codex/config.toml and Codex runs on GPT models through MYUSAPI. Models are never swapped or downgraded, and you are billed by the usage the upstream reports.

Tested 2026-11-12: macOS, Codex CLI 0.162.1, not signed in to ChatGPT; gpt-6.1-sol completed a shell-command tool call. The Windows commands and the other GPT models were not rerun.

1Sign up and get an API key

Sign up with email or Google. Once you add credit, your workspace creates your key (it starts with sk-).

Sign up and get an API key

2Write config.toml

Save this as ~/.codex/config.toml ($HOME\.codex\config.toml on Windows). If the file already exists, do not replace it: put the first two lines at the very top, before any [section] (change the values if those keys exist), and add the whole [model_providers.myusapi] block at the end.

config.toml
model = "gpt-6.1-sol"
model_provider = "myusapi"

[model_providers.myusapi]
name = "MYUSAPI"
base_url = "https://myusapi.com/v1"
env_key = "MYUSAPI_API_KEY"
wire_api = "responses"
model_providerSelects the provider declared below; it must match the name in [model_providers.…].
base_urlhttps://myusapi.com/v1. This one does end in /v1.
env_keyThe environment variable that holds your key (MYUSAPI_API_KEY). The key itself stays out of the file.
wire_apiMust be "responses". Codex removed the "chat" value found in older guides, and it now fails as a config error.

3Set your key and start

macOS / Linux

Terminal
export MYUSAPI_API_KEY="sk-your-key"
codex

Windows PowerShell

PowerShell
$env:MYUSAPI_API_KEY = "sk-your-key"
codex

A key set this way lasts only for the current terminal window. To keep it, add the export line to ~/.zshrc or ~/.bashrc; on Windows, add MYUSAPI_API_KEY in the system’s environment variable settings.

4Check that it works

On start, Codex shows provider: myusapi and the chosen model. Give it a simple task; if it completes, you are connected. Switch models inside Codex with /model. Usage in your workspace shows the model, tokens and charge for each call.

GPT models and prices

ModelInput / 1MOutput / 1MCache read / 1M
GPT-6.2 Astragpt-6.2-astraOfficial$8.00, our price$2.00Official$40.00, our price$10.00$0.10
GPT-6 Astragpt-6-astraOfficial$10.00, our price$2.50Official$50.00, our price$12.50$0.25
GPT-6.1 Solgpt-6.1-solOfficial$2.00, our price$0.40Official$10.00, our price$2.00$0.02
GPT-6 Lunagpt-6-lunaOfficial$0.10, our price$0.01Official$0.50, our price$0.05$0.001
GPT-6 Solgpt-6-solOfficial$2.00, our price$0.50Official$10.00, our price$2.50$0.05
GPT-5.6 Solgpt-5.6-solOfficial$4.00, our price$1.20Official$20.00, our price$6.00$0.12
GPT-5.6 Terragpt-5.6-terraOfficial$2.00, our price$0.60Official$12.00, our price$3.60$0.06
GPT-5.6 Lunagpt-5.6-lunaOfficial$0.20, our price$0.02Official$1.20, our price$0.12$0.002

USD per 1M tokens. The struck figure is the official standard list price; bold is ours. All models and prices

Common questions

Can Codex CLI use Claude models?

Yes: set model to a Claude model ID. In a test on 2026-11-12 with Codex CLI 0.162.1, claude-opus-5-5 and claude-sonnet-5-5 each completed a shell-command tool call. Codex's own web search and multi-agent tools are not served here: sent beside other tools they are left out and the request goes on.

Do I need to sign in with a ChatGPT account?

No. Codex reads your API key from MYUSAPI_API_KEY, and usage is charged to your prepaid MYUSAPI credit.

Next