Before turning CometAPI’s GPT Image 2.5(sunburst) sample into a repeatable development command, replace its credential fallback with a local stop. The sample is useful for showing the request target; its placeholder should not become executable configuration.
In the version captured on September 10, 2026, the Python example reads COMETAPI_KEY and falls back to the literal <YOUR_COMETAPI_KEY>. The JavaScript example does the same. Both construct a client with https://api.cometapi.com/v1, then call images.generate with model="gpt-image-2.5-sunburst".
That makes the first debugging decision quite specific: if this copied Sunburst command has no usable local key value, stop before client construction—not after trying image generation. Changing the model string or image prompt does not fix missing local configuration.
Replace the fallback, not the request target
The fallback expressions cover absent and empty values by supplying a nonempty placeholder. They do not establish that a real key was configured. A whitespace-only value needs an explicit check too.
For a Python adaptation, this is a proposed replacement for the sample’s key assignment, placed before its client construction:
import os
key = os.environ.get("COMETAPI_KEY")
if (
key is None
or not key.strip()
or key.strip() == "<YOUR_COMETAPI_KEY>"
):
raise SystemExit("Configure COMETAPI_KEY before running the Sunburst command.")
API_KEY = key
The guard checks a stripped copy but passes the original value onward. It does not silently repair credentials or print their contents. Keep the sample’s CometAPI base URL and gpt-image-2.5-sunburst request target unchanged while making this configuration-only change.
For the JavaScript adaptation, apply the same decision before new OpenAI(...): reject an undefined value, an empty or whitespace-only value, and the known placeholder after trimming for comparison. Do not retain the || placeholder fallback after adding the guard.
Local acceptance table
These are proposed checks for the command, not results from a live CometAPI test. Use synthetic inputs and a client-construction stub to check that rejected cases never reach the client boundary.
| Configuration supplied to the guard | Expected local decision |
|---|---|
| Variable absent | Stop with the configuration message |
| Empty string or whitespace only | Stop with the same message |
| Literal sample placeholder, including surrounding whitespace | Stop with the same message |
| Another nonempty value | Allow client construction; authorization remains unproven |
Do not include the supplied value in errors or test reports. The last row is especially important: passing this guard is not evidence of a valid key, permission to use Sunburst, available quota, or a successful generated image.
What this fixes—and what it does not
This is a documentation-to-command change for CometAPI’s published GPT Image 2.5 Sunburst example, not a claim that Sunburst has a special authentication mechanism. The guard technique is reusable; the evidence for the placeholder, base URL and model string comes from this particular sample. It does not establish how a different model’s example is written.
No authentication request or image generation was run here. The supported outcome is narrower: the proposed command can distinguish missing or known-placeholder configuration locally, before attempting the documented Sunburst request. Once that check passes, authentication and model access still need separate verification—without exposing the key.