Skip to main content
Vision input and image generation are separate capabilities. Configure a model that supports the operation and inspect its supported size, quality, and format options.

Send an image input

Import responses, constants, and utils from the SDK. Given model and ctx:
Replace the illustrative URL with an accessible image. For application-owned files, use attachment references with an agent attachment middleware. An attachment:// reference is opaque SDK state, not a public URL that a direct provider call can fetch.

Generate an image

For generation through a compatible Responses model, add Tools: []responses.ToolUnion{{OfImageGeneration: &responses.ImageGenerationTool{}}} to the request. The completed OfImageGenerationCall item carries the result. Do not assume an image appears in a text delta. For a dedicated image endpoint, call model.NewImageGeneration with image_generation.Request. The result’s Images entries may contain base64 data or URLs; inspect the populated field and MIME type. NewImageEdit is a separate operation for editing input images.

Store and display results

Decode base64 with error checking and preserve the returned media type instead of guessing a file extension. Provider URLs may have limited lifetimes. Store media under your application’s retention/access policy if later conversation turns need it. The attachment middleware externalizes complete generated images into immutable references before durable agent state stores them. It suppresses binary partial previews while preserving other streaming events. Without that middleware, provider-native image output continues through the SDK’s normal response types.