---
title: "Codex CLI setup: custom provider and base URL in config.toml | MYUSAPI"
description: "Declare a custom provider in ~/.codex/config.toml with base_url https://myusapi.com/v1 and wire_api \"responses\" to run Codex CLI on GPT models. Merge steps included."
url: https://myusapi.com/en/docs/codex-cli
---

# 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.

## 1 Sign 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](https://myusapi.com/en/signup)

## 2 Write 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.

```
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_provider: Selects the provider declared below; it must match the name in [model_providers.…].
- base_url: https://myusapi.com/v1. This one does end in /v1.
- env_key: The environment variable that holds your key (MYUSAPI_API_KEY). The key itself stays out of the file.
- wire_api: Must be "responses". Codex removed the "chat" value found in older guides, and it now fails as a config error.

## 3 Set your key and start

### macOS / Linux

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

### Windows 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.

## 4 Check 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

| Model | Input / 1M | Output / 1M | Cache read / 1M |
| --- | --- | --- | --- |
| [GPT-6.2 Astra](https://myusapi.com/en/models/gpt-6.2-astra) gpt-6.2-astra | Official $8.00, our price $2.00 | Official $40.00, our price $10.00 | $0.10 |
| [GPT-6 Astra](https://myusapi.com/en/models/gpt-6-astra) gpt-6-astra | Official $10.00, our price $2.50 | Official $50.00, our price $12.50 | $0.25 |
| [GPT-6.1 Sol](https://myusapi.com/en/models/gpt-6.1-sol) gpt-6.1-sol | Official $2.00, our price $0.40 | Official $10.00, our price $2.00 | $0.02 |
| [GPT-6 Luna](https://myusapi.com/en/models/gpt-6-luna) gpt-6-luna | Official $0.10, our price $0.01 | Official $0.50, our price $0.05 | $0.001 |
| [GPT-6 Sol](https://myusapi.com/en/models/gpt-6-sol) gpt-6-sol | Official $2.00, our price $0.50 | Official $10.00, our price $2.50 | $0.05 |
| [GPT-5.6 Sol](https://myusapi.com/en/models/gpt-5.6-sol) gpt-5.6-sol | Official $4.00, our price $1.20 | Official $20.00, our price $6.00 | $0.12 |
| [GPT-5.6 Terra](https://myusapi.com/en/models/gpt-5.6-terra) gpt-5.6-terra | Official $2.00, our price $0.60 | Official $12.00, our price $3.60 | $0.06 |
| [GPT-5.6 Luna](https://myusapi.com/en/models/gpt-5.6-luna) gpt-5.6-luna | Official $0.20, our price $0.02 | Official $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](https://myusapi.com/en/models)

## 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

- [Set up Claude Code with MYUSAPI: base URL and API key](https://myusapi.com/en/docs/claude-code)
- [Other tools and clients](https://myusapi.com/en/docs/tools)
- [Error codes and retries](https://myusapi.com/en/docs/errors)
