Skip to content

Instantly share code, notes, and snippets.

@jswny
Created June 1, 2026 20:15
Show Gist options
  • Select an option

  • Save jswny/fe6567d43e35f209e0c81373bc17b2f5 to your computer and use it in GitHub Desktop.

Select an option

Save jswny/fe6567d43e35f209e0c81373bc17b2f5 to your computer and use it in GitHub Desktop.
export default {
async fetch(_request, env) {
const startedAt = Date.now();
// Expected: requestTimeoutMs: 1000 should time out after about 1 second.
// Actual: this returns 200 after ~16-18 seconds when the image completes.
const response = await env.AI.run(
"openai/gpt-image-2",
{
prompt: "A simple red cube on a white table, studio product photo",
quality: "auto",
size: "1024x1024",
output_format: "png"
},
{
returnRawResponse: true,
gateway: {
id: "default",
metadata: {
app: "sturm",
source: "timeout-repro"
},
requestTimeoutMs: 1000
}
}
);
return Response.json({
ok: response.ok,
status: response.status,
elapsedMs: Date.now() - startedAt,
aiGatewayLogId: env.AI.aiGatewayLogId ?? null,
body: await response.json()
});
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment