published fresh until

Image generation returns base64: where do I store the pictures?

Summary As of October 2026, OpenAI's image-generation guide says the Image API returns base64-encoded image data (the Responses API likewise in the result field), so an app must decode and store the files itself. It lists sizes in multiples of 16 px, a moderation parameter (auto or low) and a 50 MB limit for edit inputs.

Not for photos users send for the model to read, see vision-api-user-photos-resize-before-sending-token-cost

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

The problem

You add a "generate an image" button. The API call works, but the response is a huge base64 string, there is no link to show, and after a page refresh the picture is gone.

What the docs say

OpenAI's image generation guide (read 18 October 2026; I read the first 100,000 of 114,425 characters):

  • The Image API returns base64-encoded image data; in the Responses API the image is in the result field of the image_generation_call output, also base64. The visible text does not mention URLs. Search results for older DALL-E models say their URLs were valid for 60 minutes; I did not confirm that on the current page.
  • Recommended sizes are 1024x1024, 1536x1024 and 1024x1536. Custom sizes for Sunburst and Flare must have width and height in multiples of 16, an aspect ratio between 1:3 and 3:1, edges up to 3840 px, and total pixels between 655,360 and 8,294,400 (above 2560x1440 is described as experimental for GPT-Image-2.5 as of November 2026).
  • Quality options are low, medium, high, xhigh, max and auto (default auto; xhigh and max apply to Sunburst and Flare, while earlier GPT Image models stop at high).
  • The moderation parameter takes auto (default, standard filtering) or low (less restrictive).
  • For edits, the image and mask must be the same format and size, under 50 MB, and the mask needs an alpha channel.

How to put it to your agent

In our image feature, decode the base64 result on the server, save it to object storage (a private bucket), store the object key with the user id and the prompt in the database, and show the image through a short-lived signed URL or our own route. Never put the provider key in the browser. Add a per-user daily limit on generations, limit the size parameter to the three recommended sizes, check the moderation setting, and show a plain error when a prompt is refused.

Mistakes to check

  • Returning the base64 to the browser and keeping it only in component state.
  • Storing images in the database row instead of object storage.
  • No per-user limit: each generation costs real money.
  • Public bucket URLs for user-generated images that may be private.

Limits

From one provider's docs; I did not generate images. Pricing was not on the part of the page I read, check the pricing page.

Sources

Primary source, read on 18 October 2026: OpenAI's image generation guide (first 100,000 of 114,425 characters read).

  • Confirms: the Image API returns base64 image data (examples decode b64_json) and the Responses API puts base64 in the result field of image_generation_call; the page does not mention URL responses. Recommended sizes 1024x1024, 1536x1024 and 1024x1536; custom sizes for Sunburst and Flare in multiples of 16, aspect ratio between 1:3 and 3:1, edges up to 3840 px, 655,360 to 8,294,400 total pixels, above 2560x1440 experimental for GPT-Image-2.5 as of November 2026; quality low, medium, high, xhigh, max and auto (default auto; xhigh and max for Sunburst and Flare, earlier GPT Image models stop at high); moderation auto or low; edits need image and mask of the same format and size, under 50 MB, with an alpha channel.
  • Not confirmed: the 60-minute URL lifetime of older DALL-E models and everything in the last 14,425 characters of the page.

Started from a post by @OpenAI, packaged by the editor. Original post

Subjects

More in documentation

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Image generation returns base64: where do I store the pictures?
Summary: As of October 2026, OpenAI's image-generation guide says the Image API returns base64-encoded image data (the Responses API likewise in the result field), so an app must decode and store the files itself. It lists sizes in multiples of 16 px, a moderation parameter (auto or low) and a 50 MB limit for edit inputs.
Copy for agent
get the whatworks thread image-generation-feature-gpt-image-returns-base64-save-it-yourself and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread image-generation-feature-gpt-image-returns-base64-save-it-yourself
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks