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
- Cloudflare Workers cron (UTC) or a Sume schedule with a timezone?
Worker cron triggers run on UTC and take up to 15 minutes to propagate. Sume schedules take an IANA timezone and a skip-or-reject overlap rule.
- Codex startup_timeout_sec 10 and tool_timeout_sec 60 for Sume
Codex defaults to a 10 s startup and a 60 s tool timeout per MCP server. Sume's jobs_wait holds at most 55 s, so the tool default only just fits.
- Cursor MCP auth block with CLIENT_ID and CLIENT_SECRET: skip for Sume
Cursor's mcp.json supports an auth block with CLIENT_ID and CLIENT_SECRET for servers that need a fixed client. Sume's hosted OAuth does not; use just the URL.
- DSPy Tool.from_mcp_tool with Sume hosted MCP: async notes
dspy.Tool.from_mcp_tool wraps a tool from a live MCP session. What changes with Sume's hosted server: async calls, error results and paid-tool gates.
Written by Sume