The Error
In one sentence: this error is returned by OpenAI’s own servers, not by APIYI. Your code is currently calling
api.openai.com, so OpenAI rejects the APIYI key. The key is fine. The request address is wrong.How to Tell the Request Never Reached APIYI
Either of these two signs settles it:This is especially common when you ask an AI coding assistant to write the integration. Codex, Cursor, Claude Code and friends see the model name
gpt-image-2.5, default to the official OpenAI SDK pattern, and leave base_url at the SDK default https://api.openai.com/v1. The key you paste in is APIYI’s. The two do not match.Three Fixes, Pick by Situation
- ① Using Codex / a coding Agent: install the Skills
- ② Not a coder: hand the prompt to your AI
- ③ No integration needed: generate on the web
The lowest-effort path is to let the Agent “learn” APIYI before it writes code. Two levels of skill packs are available:
1
Site-wide skill pack (install this first)
Have your Agent run the command below to install the APIYI skill pack. If that fails, tell it to read This file is written for AI: base URLs, authentication, model naming rules and common pitfalls. Once installed, the code it writes will point
https://docs.apiyi.com/skill.md directly:base_url at https://api.apiyi.com/v1 automatically.2
Dedicated GPT-Image skill
The GPT-Image-2.5 / 2 Series Agent Skill page ships a ready-to-use Skill: two files and one script covering six models including
gpt-image-2.5-flare / gpt-image-2.5-sunburst / gpt-image-2, switched with --model. Text-to-image, multi-image fusion and inpainting are all included.Drop it into Codex, OpenClaw, Claude Code or any coding Agent that can run shell commands, then just say “generate an image of…” You never touch the base URL yourself.Fix It Yourself: One Line
If you already have code generated by Codex, the minimal change is addingbase_url to the client. Leave everything else untouched:
Follow-up Questions
I changed base_url but still get the same error. Why?
I changed base_url but still get the same error. Why?
Check in this order:
- Multiple config locations: Codex-generated projects often set the URL in
.env, a config file and the client constructor. Changing one leaves the others at the default - Environment variable precedence: if
OPENAI_BASE_URLis already set to something else on your system, it overrides whatever the code omits. Runecho $OPENAI_BASE_URLto check - No restart: the running process still holds the old config
- Spelling:
apiyi, notapiyiiorapiyl
platform.openai.com still appears, the request is still going to OpenAI.Codex says it already switched to APIYI, but the error is unchanged.
Codex says it already switched to APIYI, but the error is unchanged.
Send it the exact error together with this page. Every docs page has a “Copy page” button in the top-right corner. Paste the page content plus the error into the AI and it can pinpoint which config did not take effect. This is the fastest troubleshooting path.
What if the key is still rejected after the request reaches APIYI?
What if the key is still rejected after the request reaches APIYI?
Only then is it time to check the key itself: open the “Tokens” page in the console and confirm the key is enabled, the balance is sufficient and no model whitelist blocks it. Full checklist in Why is my API Key invalid?.
Which model name should I use for gpt-image-2.5?
Which model name should I use for gpt-image-2.5?
Default to
gpt-image-2.5-flare for text-to-image and gpt-image-2.5-sunburst for editing and inpainting. Both share the same price and parameters. For high-volume, low-cost work use the reverse channel gpt-image-2.5-all. The comparison table on the GPT-Image Series Agent Skill page covers all six.Related
Why is my API Key invalid?
Why base URL and key must match, with examples in every language.
How to configure Base URL?
/v1 for OpenAI, root domain for Claude, /v1beta for Gemini.
Is there one-click integration?
Hand the docs to your AI coding assistant and let it do the integration.
GPT-Image-2.5 / 2 Overview
Parameters, pricing, integration prompt and common errors.