Cloudflare Worker: keep the image model id in KV and swap it live
A Worker that proxies POST /v1/images and reads the Sume model id from Workers KV, so replacing gpt-image-1 is a wrangler command, not a deploy.

Store the image model id in a Workers KV key and read it per request. The Worker below forwards a prompt to POST https://api.sume.com/v1/images with the id from KV, then returns Sume's status and JSON untouched. Replacing a retired id is one wrangler kv key put, and the Worker script never changes.
Allow a short delay for a KV write to reach every location. Keep a default in code for the empty-key case so a missing key never sends model: undefined.
The Worker
The X-Image-Model response header tells the caller which id ran. Sume's 200 body has data as an image list; a 202 has the job envelope, and the Worker passes either through.
export default {
async fetch(request, env) {
const model =
(await env.CONFIG.get("image_model")) ?? "openai/gpt-image-2.5-sunburst";
const { prompt } = await request.json();
const upstream = await fetch("https://api.sume.com/v1/images", {
method: "POST",
headers: {
Authorization: `Bearer ${env.SUME_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({ model, prompt }),
});
return new Response(upstream.body, {
status: upstream.status,
headers: { "Content-Type": "application/json", "X-Image-Model": model },
});
},
};Swap the id
Bind the namespace as CONFIG in your Wrangler config and write the key from a terminal:
npx wrangler kv key put --binding=CONFIG image_model "openai/gpt-image-2.5-sunburst"Which ids are valid
An id that Sume does not list returns 404 model_not_found, which the Worker passes through. For the 200 versus 202 handling in a caller, see the status-code post. The id mapping itself is in the model map.
| Use case | Value |
|---|---|
| ChatGPT Image 2.5 (Sunburst) | openai/gpt-image-2.5-sunburst |
| ChatGPT Image 2.5 (Flare) | openai/gpt-image-2.5 |
| Gemini-family image model | google/nano-banana-2 |
Sources
Related posts
More in Integrations
- GitHub Actions repository variable for the image model id: no commit
Keep the Sume image model id in a GitHub Actions repository variable, so a gpt-image-1 replacement is a settings change or one gh command, not a pull request.
- Intercom outbound message with a Sume avatar clip: email or in-app
Intercom's create-message API sends in_app, email or whatsapp with an HTML or plain body. It documents no video field, so link a Sume clip. How to set it up.
- jobs_wait for 20 transcription jobs in one MCP call
The hosted MCP jobs_wait takes up to 20 job_ids, wait_for all or any, and include_results returns each finished transcript. Retry slices of 55 seconds.
- jobs_wait outcomes: wait_slice_expired, operator_stopped, omitted
What each jobs_wait answer means on Sume's hosted MCP and what your agent should do next: call again, stop waiting on stopped ids, or read omitted results.
Written by Sume