Diagnose invalid_api_key with the request URL, a catalog check and three provider settings. Keep the key out of terminal output and support tickets.
You add credit, paste a key, type “hello” and see 401 Incorrect API key. Start with the URL in the error. If it says api.openai.com/v1/responses, Codex sent the CheapAI key to OpenAI. Adding CheapAI credit cannot change that route.
Check the key outside Codex
Run the command below from the terminal used to launch the client. It reads CHEAPAI_API_KEY from the environment and prints only the HTTP status for the model list. A 200 confirms catalog access. For a 401, check that the variable is set in this session and that the key is active in your dashboard. Keep the key out of support tickets.
curl -sS -o /dev/null -w '%{http_code}\n' \
-H "Authorization: Bearer ${CHEAPAI_API_KEY:?}" \
https://cheapai.io/v1/models
Inspect the selected profile
Match three values in the active provider configuration: base_url should be https://cheapai.io/v1, env_key should name CHEAPAI_API_KEY and wire_api should be responses. Restart with that profile. An app opened from a desktop launcher may inherit a different environment from your shell. Check the instance showing the error.
Interpret the next result
After the catalog returns 200, send one short Codex request and inspect its destination. A model_not_found response on the CheapAI host calls for a model ID check. If 401 persists on the correct host, share the UTC time, sanitized URL and request ID with support.
Codex CLI · HTTP 401 / 404
- Codex Auto Review pricing: what does one pull request cost?
Estimate small, medium and large reviews at current CheapAI rates. Include the follow-up pass and compare the bill with findings your team can reproduce.
- Claude Fable API pricing for a 100k-token document
Price an initial Fable response and five follow-up questions. Separate uncached input, cache reads and output and check the exact model version.
- Opus vs Sonnet for coding: when does the higher price pay off?
Compare cost per accepted patch, include failed runs and calculate a break-even point before choosing a Claude model for your repository.
- Do Russian prompts cost more than English? Measure your own API tokens
Run a paired Claude token-count test, keep the code and tools fixed, then convert the difference to dollars before changing your team’s working language.
- An AI stream ended after HTTP 200. Did the response finish?
Inspect the final stream event, distinguish an output limit from a disconnect, and decide whether retrying a tool call could duplicate work.
- What can a pelican SVG tell you about a coding model?
Evaluate rendering, instruction following and animation separately. Then compare the result with a reproducible patch in your own repository.
- How much does a Codex coding task cost through the API?
Estimate the cost of one bug fix and a batch of twenty using live API rates. Compare models by the cost of a passing patch, including retries.
- Claude wrote the prompt cache. Why did the next request read zero?
Read Claude usage fields, price a cache miss and run a controlled two-request check before changing your prompts or your API provider.
- How to check Gemini input token counts on long requests
Compare countTokens with usageMetadata on the same Gemini payload. Isolate chat history, tools, cached input and multilingual text before disputing a bill.