Codex API Key vs ChatGPT Login: Setup and Billing

Choose between ChatGPT sign-in, an official OpenAI API key, and a separately billed Responses provider. Configure BetterToken in user-level config.toml, understand country and card restrictions, and verify authentication, model routing, and the matching usage record before starting real work.

Contents
Codex API Key vs ChatGPT Login: Setup and Billing

If Codex cannot sign in or its usage appears on an unexpected bill, identify the authentication route before changing plans. For developers using Codex locally, ChatGPT login uses plan entitlements; an OpenAI API key uses separate OpenAI Platform billing. With a custom Responses provider, check the selected provider and its usage records as well as codex login status.

Choose the account that should pay

As of 2026-11-22, OpenAI’s authentication documentation distinguishes subscription sign-in from API-key access. A third-party provider adds a separate model-billing route, not a ChatGPT subscription.

RouteRequirementsWhere usage is billedChoose it when
ChatGPT loginA ChatGPT account in a supported location; an eligible plan and supported payment method for paid featuresYour plan’s allowance and any applicable ChatGPT credits or usage billingYou want included local usage or eligible Codex cloud features
Official OpenAI API keyAn OpenAI Platform key, API billing or usable API credits, a supported location, and an eligible payment method when payingOpenAI Platform, at API rates rather than your ChatGPT allowanceYou need local CLI work or trusted automation billed to an API organization
BetterToken custom providerYour own BetterToken account, API key, and funded balance; payment options depend on the consoleBetterToken balance at the selected model’s token ratesYou need separately billed local Codex access, including a ruble-payment option

Configure BetterToken for a local CLI session

Use the BetterToken Codex access route with the installed official Codex CLI. Check current token and cache rates, then open the console.

Confirm that your account has sufficient usable balance for the test. If needed, add credit through an available console payment option and confirm that the balance has updated. Then create your own API key, following BetterToken’s account setup instructions.

The example uses gpt-6.2-sol, listed with Responses support as of 2026-11-22. It uses the environment-variable authentication option documented in BetterToken’s Codex guide.

Quit Codex and back up your configuration privately. Merge this into user-level ~/.codex/config.toml, keeping root keys before all tables. Replace existing matching settings rather than adding duplicate keys or tables. If CODEX_HOME is set, edit config.toml in that directory instead.

model = "gpt-6.2-sol"
model_provider = "bettertoken"

[model_providers.bettertoken]
name = "BetterToken"
base_url = "https://www.bettertoken.ai/v1"
wire_api = "responses"
env_key = "BETTERTOKEN_API_KEY"
requires_openai_auth = false
supports_websockets = false

In Bash, paste your key when read waits, then press Enter. The input is hidden. Start the test from a directory without sensitive project material.

read -rs BETTERTOKEN_API_KEY && export BETTERTOKEN_API_KEY
codex --sandbox read-only "Reply with exactly CODEX_ROUTE_OK. Do not use tools."

Codex reads the key from the exported variable and sends Responses requests to https://www.bettertoken.ai/v1/responses. This configuration does not require replacing auth.json or passing the BetterToken key to OpenAI’s login flow. Start Codex from this same terminal so it receives the variable.

Look for the requested reply, then match the model, request time, status, and charge in the BetterToken console. A reply confirms the connection; the matching record confirms which platform handled the request. Check the bill before opening a large repository.

Create a BetterToken account

What do the two official sign-ins include?

For OpenAI’s own route, use its official sign-in instructions. Choose ChatGPT login for plan access or an OpenAI-issued API key for Platform billing; the third-party configuration above is a different route.

Both official sign-in methods support local work in Codex CLI, the IDE extension, and the ChatGPT desktop app. Codex cloud requires ChatGPT sign-in. The feature-availability page excludes cloud-based GitHub code review and Slack integration from API-key access.

Choose API-key authentication for local work or trusted CI jobs, not as a replacement for cloud entitlements. API model availability follows the models available to your key. A higher ChatGPT plan does not turn an API-key session into included subscription usage.

To switch back to OpenAI, set root model_provider = "openai" in your user configuration. Also restore your previous OpenAI model setting, or select a model available to your official sign-in. Do not carry over model = "gpt-6.2-sol" from the gateway example without checking your official account’s model access.

Remove any openai_base_url override intended for a gateway. When replacing saved credentials, run codex logout first. Run codex login for ChatGPT sign-in.

For official API-key sign-in, use an OpenAI-issued key. These Bash commands supply it through standard input without putting its value in the command:

read -rs OPENAI_API_KEY && export OPENAI_API_KEY
codex login --with-api-key <<<"$OPENAI_API_KEY"
codex login status

After signing in, start a new session and rerun the read-only test above with your selected OpenAI model. Confirm the reply, then check the corresponding ChatGPT or OpenAI Platform usage dashboard in the billing section below.

Keep the key private. OpenAI’s billing guidance separates API billing from ChatGPT billing, including promotional API credits. When evaluating a subscription benefit, check its API-credit eligibility and exclusions rather than assuming it covers Codex.

What if your country or card is unsupported?

An official API key does not remove OpenAI’s location requirements. As of 2026-11-22, Russia is absent from both the API supported-country list and the combined ChatGPT/API list.

The error "OpenAI's services are not available in your country." can appear during registration or API-key creation. OpenAI’s unsupported-country policy warns that access from unsupported countries may result in account suspension. It also says unsupported-country payment methods cause service blocking.

Payment has separate checks. For card payments, your location and the issuing bank must each be in a supported region. Prepaid cards cannot buy API credits, according to its card-decline guidance.

For users in Russia, BetterToken supports ruble payments without the foreign card commonly needed for official vendor subscriptions. Its API endpoint is reachable without a VPN. That endpoint claim does not cover third-party downloads, logins, marketplaces, or updates; payment channels, eligible cards, fees, and settlement conditions depend on the console.

A browser reset is relevant only when you are currently in a supported country. OpenAI recommends clearing cookies and cache or trying another browser after travel-related detection errors. If that fails, contact OpenAI Support.

Why does Codex ignore my custom provider?

Put provider settings in user-level configuration, not a repository’s .codex/config.toml. The configuration reference says project-local model_provider and model_providers entries are ignored. Trusting the project does not change that restriction.

model_provider selects a provider ID; [model_providers.bettertoken] defines that ID. base_url identifies the API root, while env_key names the environment variable holding the credential. Use your own provider ID. Built-in IDs, including openai, ollama, and lmstudio, are reserved.

The only supported wire_api value is responses. A gateway that supports only Chat Completions is insufficient for this configuration. Use https://www.bettertoken.ai/v1 as the Base URL, not the complete /responses request URL.

Keep authentication modes separate. OpenAI documents that requires_openai_auth = true makes Codex ignore env_key. The example explicitly sets it to false; do not combine it with a copied file-auth configuration that sets it to true.

supports_websockets = false keeps this example on HTTP/SSE transport. Leave optional tuning out of the first test. Support for fields such as service_tier needs gateway-side confirmation; a Codex configuration field alone does not establish support.

If the configuration still appears ineffective, inspect CODEX_HOME and any command-line or selected-profile overrides. In the CLI, /debug-config shows configuration layers and policy sources. Restart with a new session after changes. The custom-provider setup guide covers the broader connection checks.

How do you confirm the billing source?

Check authentication, routing, and usage records together. codex login status reports the authentication mode; it is not a billing receipt. With an env_key provider, do not infer the model’s billing destination solely from an existing ChatGPT login.

Run this in the same environment used to launch Codex:

codex login status

Then inspect the selected model_provider and base_url. Inside the session, /status shows the active model and token usage. Match these details to the small test request before starting a long task.

For ChatGPT sign-in, inspect the Codex usage dashboard for allowance consumption. Check the account or workspace’s ChatGPT billing settings for purchases. Included usage need not create a separate per-request monetary charge.

For an official API key, use OpenAI Platform usage reporting and the API organization’s billing settings. Check the correct project, model, API key, and reporting period. Dashboard times are UTC, and recent activity may take time to appear.

For BetterToken, check the console request record and balance. Its dashboard shows request time, model, status, token usage, and charges. Do not expect that charge to appear on your personal OpenAI Platform account or consume your ChatGPT allowance.

If the test fails, fix the matching cause

For a missing-variable error, enter the key again and launch Codex from the same Bash terminal. For a BetterToken 401, check that the key belongs to BetterToken and remains valid. A 402 indicates insufficient balance.

For a request-format rejection, compare the selected protocol and Base URL with the minimal configuration above. Remove optional provider-specific fields before retesting. BetterToken’s Responses reference documents 400 for invalid request formats or parameters.

If the reply succeeds but the expected usage record is missing, stop before sending a larger workload. Recheck the provider, credential source, dashboard account, and reporting period. A model name or successful login alone is insufficient evidence of the billing route.

Ready to optimize your LLM workflow?

Join thousands of developers building faster, smarter, and more cost-effective AI applications with BetterToken.

Get Started for Free