Skip to content

Images

Create image
client.Images.Generate(ctx, body) (*ImagesResponse, error)
POST/images/generations
Create image edit
client.Images.Edit(ctx, body) (*ImagesResponse, error)
POST/images/edits
Create image variation
client.Images.NewVariation(ctx, body) (*ImagesResponse, error)
POST/images/variations
ModelsExpand Collapse
type Image struct{…}

Represents the content or the URL of an image generated by the OpenAI API.

B64JSON stringoptional

The base64-encoded JSON of the generated image. Returned by default for the GPT image models, and only present if response_format is set to b64_json for dall-e-2 and dall-e-3.

RevisedPrompt stringoptional

For dall-e-3 only, the revised prompt that was used to generate the image.

URL stringoptional

When using dall-e-2 or dall-e-3, the URL of the generated image if response_format is set to url (default value). Unsupported for the GPT image models.

type ImageEditCompletedEvent struct{…}

Emitted when image editing has completed and the final image is available.

B64JSON string

Base64-encoded final edited image data, suitable for rendering as an image.

Background ImageEditCompletedEventBackground

The background setting for the edited image.

Accepts one of the following:
const ImageEditCompletedEventBackgroundTransparent ImageEditCompletedEventBackground = "transparent"
const ImageEditCompletedEventBackgroundOpaque ImageEditCompletedEventBackground = "opaque"
const ImageEditCompletedEventBackgroundAuto ImageEditCompletedEventBackground = "auto"
CreatedAt int64

The Unix timestamp when the event was created.

OutputFormat ImageEditCompletedEventOutputFormat

The output format for the edited image.

Accepts one of the following:
const ImageEditCompletedEventOutputFormatPNG ImageEditCompletedEventOutputFormat = "png"
const ImageEditCompletedEventOutputFormatWebP ImageEditCompletedEventOutputFormat = "webp"
const ImageEditCompletedEventOutputFormatJPEG ImageEditCompletedEventOutputFormat = "jpeg"
Quality ImageEditCompletedEventQuality

The quality setting for the edited image.

Accepts one of the following:
const ImageEditCompletedEventQualityLow ImageEditCompletedEventQuality = "low"
const ImageEditCompletedEventQualityMedium ImageEditCompletedEventQuality = "medium"
const ImageEditCompletedEventQualityHigh ImageEditCompletedEventQuality = "high"
const ImageEditCompletedEventQualityAuto ImageEditCompletedEventQuality = "auto"
Size ImageEditCompletedEventSize

The size of the edited image.

Accepts one of the following:
const ImageEditCompletedEventSize1024x1024 ImageEditCompletedEventSize = "1024x1024"
const ImageEditCompletedEventSize1024x1536 ImageEditCompletedEventSize = "1024x1536"
const ImageEditCompletedEventSize1536x1024 ImageEditCompletedEventSize = "1536x1024"
const ImageEditCompletedEventSizeAuto ImageEditCompletedEventSize = "auto"
Type ImageEditCompleted

The type of the event. Always image_edit.completed.

Usage ImageEditCompletedEventUsage

For the GPT image models only, the token usage information for the image generation.

InputTokens int64

The number of tokens (images and text) in the input prompt.

InputTokensDetails ImageEditCompletedEventUsageInputTokensDetails

The input tokens detailed information for the image generation.

ImageTokens int64

The number of image tokens in the input prompt.

TextTokens int64

The number of text tokens in the input prompt.

OutputTokens int64

The number of image tokens in the output image.

TotalTokens int64

The total number of tokens (images and text) used for the image generation.

type ImageEditPartialImageEvent struct{…}

Emitted when a partial image is available during image editing streaming.

B64JSON string

Base64-encoded partial image data, suitable for rendering as an image.

Background ImageEditPartialImageEventBackground

The background setting for the requested edited image.

Accepts one of the following:
const ImageEditPartialImageEventBackgroundTransparent ImageEditPartialImageEventBackground = "transparent"
const ImageEditPartialImageEventBackgroundOpaque ImageEditPartialImageEventBackground = "opaque"
const ImageEditPartialImageEventBackgroundAuto ImageEditPartialImageEventBackground = "auto"
CreatedAt int64

The Unix timestamp when the event was created.

OutputFormat ImageEditPartialImageEventOutputFormat

The output format for the requested edited image.

Accepts one of the following:
const ImageEditPartialImageEventOutputFormatPNG ImageEditPartialImageEventOutputFormat = "png"
const ImageEditPartialImageEventOutputFormatWebP ImageEditPartialImageEventOutputFormat = "webp"
const ImageEditPartialImageEventOutputFormatJPEG ImageEditPartialImageEventOutputFormat = "jpeg"
PartialImageIndex int64

0-based index for the partial image (streaming).

Quality ImageEditPartialImageEventQuality

The quality setting for the requested edited image.

Accepts one of the following:
const ImageEditPartialImageEventQualityLow ImageEditPartialImageEventQuality = "low"
const ImageEditPartialImageEventQualityMedium ImageEditPartialImageEventQuality = "medium"
const ImageEditPartialImageEventQualityHigh ImageEditPartialImageEventQuality = "high"
const ImageEditPartialImageEventQualityAuto ImageEditPartialImageEventQuality = "auto"
Size ImageEditPartialImageEventSize

The size of the requested edited image.

Accepts one of the following:
const ImageEditPartialImageEventSize1024x1024 ImageEditPartialImageEventSize = "1024x1024"
const ImageEditPartialImageEventSize1024x1536 ImageEditPartialImageEventSize = "1024x1536"
const ImageEditPartialImageEventSize1536x1024 ImageEditPartialImageEventSize = "1536x1024"
const ImageEditPartialImageEventSizeAuto ImageEditPartialImageEventSize = "auto"
Type ImageEditPartialImage

The type of the event. Always image_edit.partial_image.

type ImageEditStreamEventUnion interface{…}

Emitted when a partial image is available during image editing streaming.

Accepts one of the following:
type ImageEditPartialImageEvent struct{…}

Emitted when a partial image is available during image editing streaming.

B64JSON string

Base64-encoded partial image data, suitable for rendering as an image.

Background ImageEditPartialImageEventBackground

The background setting for the requested edited image.

Accepts one of the following:
const ImageEditPartialImageEventBackgroundTransparent ImageEditPartialImageEventBackground = "transparent"
const ImageEditPartialImageEventBackgroundOpaque ImageEditPartialImageEventBackground = "opaque"
const ImageEditPartialImageEventBackgroundAuto ImageEditPartialImageEventBackground = "auto"
CreatedAt int64

The Unix timestamp when the event was created.

OutputFormat ImageEditPartialImageEventOutputFormat

The output format for the requested edited image.

Accepts one of the following:
const ImageEditPartialImageEventOutputFormatPNG ImageEditPartialImageEventOutputFormat = "png"
const ImageEditPartialImageEventOutputFormatWebP ImageEditPartialImageEventOutputFormat = "webp"
const ImageEditPartialImageEventOutputFormatJPEG ImageEditPartialImageEventOutputFormat = "jpeg"
PartialImageIndex int64

0-based index for the partial image (streaming).

Quality ImageEditPartialImageEventQuality

The quality setting for the requested edited image.

Accepts one of the following:
const ImageEditPartialImageEventQualityLow ImageEditPartialImageEventQuality = "low"
const ImageEditPartialImageEventQualityMedium ImageEditPartialImageEventQuality = "medium"
const ImageEditPartialImageEventQualityHigh ImageEditPartialImageEventQuality = "high"
const ImageEditPartialImageEventQualityAuto ImageEditPartialImageEventQuality = "auto"
Size ImageEditPartialImageEventSize

The size of the requested edited image.

Accepts one of the following:
const ImageEditPartialImageEventSize1024x1024 ImageEditPartialImageEventSize = "1024x1024"
const ImageEditPartialImageEventSize1024x1536 ImageEditPartialImageEventSize = "1024x1536"
const ImageEditPartialImageEventSize1536x1024 ImageEditPartialImageEventSize = "1536x1024"
const ImageEditPartialImageEventSizeAuto ImageEditPartialImageEventSize = "auto"
Type ImageEditPartialImage

The type of the event. Always image_edit.partial_image.

type ImageEditCompletedEvent struct{…}

Emitted when image editing has completed and the final image is available.

B64JSON string

Base64-encoded final edited image data, suitable for rendering as an image.

Background ImageEditCompletedEventBackground

The background setting for the edited image.

Accepts one of the following:
const ImageEditCompletedEventBackgroundTransparent ImageEditCompletedEventBackground = "transparent"
const ImageEditCompletedEventBackgroundOpaque ImageEditCompletedEventBackground = "opaque"
const ImageEditCompletedEventBackgroundAuto ImageEditCompletedEventBackground = "auto"
CreatedAt int64

The Unix timestamp when the event was created.

OutputFormat ImageEditCompletedEventOutputFormat

The output format for the edited image.

Accepts one of the following:
const ImageEditCompletedEventOutputFormatPNG ImageEditCompletedEventOutputFormat = "png"
const ImageEditCompletedEventOutputFormatWebP ImageEditCompletedEventOutputFormat = "webp"
const ImageEditCompletedEventOutputFormatJPEG ImageEditCompletedEventOutputFormat = "jpeg"
Quality ImageEditCompletedEventQuality

The quality setting for the edited image.

Accepts one of the following:
const ImageEditCompletedEventQualityLow ImageEditCompletedEventQuality = "low"
const ImageEditCompletedEventQualityMedium ImageEditCompletedEventQuality = "medium"
const ImageEditCompletedEventQualityHigh ImageEditCompletedEventQuality = "high"
const ImageEditCompletedEventQualityAuto ImageEditCompletedEventQuality = "auto"
Size ImageEditCompletedEventSize

The size of the edited image.

Accepts one of the following:
const ImageEditCompletedEventSize1024x1024 ImageEditCompletedEventSize = "1024x1024"
const ImageEditCompletedEventSize1024x1536 ImageEditCompletedEventSize = "1024x1536"
const ImageEditCompletedEventSize1536x1024 ImageEditCompletedEventSize = "1536x1024"
const ImageEditCompletedEventSizeAuto ImageEditCompletedEventSize = "auto"
Type ImageEditCompleted

The type of the event. Always image_edit.completed.

Usage ImageEditCompletedEventUsage

For the GPT image models only, the token usage information for the image generation.

InputTokens int64

The number of tokens (images and text) in the input prompt.

InputTokensDetails ImageEditCompletedEventUsageInputTokensDetails

The input tokens detailed information for the image generation.

ImageTokens int64

The number of image tokens in the input prompt.

TextTokens int64

The number of text tokens in the input prompt.

OutputTokens int64

The number of image tokens in the output image.

TotalTokens int64

The total number of tokens (images and text) used for the image generation.

type ImageGenCompletedEvent struct{…}

Emitted when image generation has completed and the final image is available.

B64JSON string

Base64-encoded image data, suitable for rendering as an image.

Background ImageGenCompletedEventBackground

The background setting for the generated image.

Accepts one of the following:
const ImageGenCompletedEventBackgroundTransparent ImageGenCompletedEventBackground = "transparent"
const ImageGenCompletedEventBackgroundOpaque ImageGenCompletedEventBackground = "opaque"
const ImageGenCompletedEventBackgroundAuto ImageGenCompletedEventBackground = "auto"
CreatedAt int64

The Unix timestamp when the event was created.

OutputFormat ImageGenCompletedEventOutputFormat

The output format for the generated image.

Accepts one of the following:
const ImageGenCompletedEventOutputFormatPNG ImageGenCompletedEventOutputFormat = "png"
const ImageGenCompletedEventOutputFormatWebP ImageGenCompletedEventOutputFormat = "webp"
const ImageGenCompletedEventOutputFormatJPEG ImageGenCompletedEventOutputFormat = "jpeg"
Quality ImageGenCompletedEventQuality

The quality setting for the generated image.

Accepts one of the following:
const ImageGenCompletedEventQualityLow ImageGenCompletedEventQuality = "low"
const ImageGenCompletedEventQualityMedium ImageGenCompletedEventQuality = "medium"
const ImageGenCompletedEventQualityHigh ImageGenCompletedEventQuality = "high"
const ImageGenCompletedEventQualityAuto ImageGenCompletedEventQuality = "auto"
Size ImageGenCompletedEventSize

The size of the generated image.

Accepts one of the following:
const ImageGenCompletedEventSize1024x1024 ImageGenCompletedEventSize = "1024x1024"
const ImageGenCompletedEventSize1024x1536 ImageGenCompletedEventSize = "1024x1536"
const ImageGenCompletedEventSize1536x1024 ImageGenCompletedEventSize = "1536x1024"
const ImageGenCompletedEventSizeAuto ImageGenCompletedEventSize = "auto"
Type ImageGenerationCompleted

The type of the event. Always image_generation.completed.

Usage ImageGenCompletedEventUsage

For the GPT image models only, the token usage information for the image generation.

InputTokens int64

The number of tokens (images and text) in the input prompt.

InputTokensDetails ImageGenCompletedEventUsageInputTokensDetails

The input tokens detailed information for the image generation.

ImageTokens int64

The number of image tokens in the input prompt.

TextTokens int64

The number of text tokens in the input prompt.

OutputTokens int64

The number of image tokens in the output image.

TotalTokens int64

The total number of tokens (images and text) used for the image generation.

type ImageGenPartialImageEvent struct{…}

Emitted when a partial image is available during image generation streaming.

B64JSON string

Base64-encoded partial image data, suitable for rendering as an image.

Background ImageGenPartialImageEventBackground

The background setting for the requested image.

Accepts one of the following:
const ImageGenPartialImageEventBackgroundTransparent ImageGenPartialImageEventBackground = "transparent"
const ImageGenPartialImageEventBackgroundOpaque ImageGenPartialImageEventBackground = "opaque"
const ImageGenPartialImageEventBackgroundAuto ImageGenPartialImageEventBackground = "auto"
CreatedAt int64

The Unix timestamp when the event was created.

OutputFormat ImageGenPartialImageEventOutputFormat

The output format for the requested image.

Accepts one of the following:
const ImageGenPartialImageEventOutputFormatPNG ImageGenPartialImageEventOutputFormat = "png"
const ImageGenPartialImageEventOutputFormatWebP ImageGenPartialImageEventOutputFormat = "webp"
const ImageGenPartialImageEventOutputFormatJPEG ImageGenPartialImageEventOutputFormat = "jpeg"
PartialImageIndex int64

0-based index for the partial image (streaming).

Quality ImageGenPartialImageEventQuality

The quality setting for the requested image.

Accepts one of the following:
const ImageGenPartialImageEventQualityLow ImageGenPartialImageEventQuality = "low"
const ImageGenPartialImageEventQualityMedium ImageGenPartialImageEventQuality = "medium"
const ImageGenPartialImageEventQualityHigh ImageGenPartialImageEventQuality = "high"
const ImageGenPartialImageEventQualityAuto ImageGenPartialImageEventQuality = "auto"
Size ImageGenPartialImageEventSize

The size of the requested image.

Accepts one of the following:
const ImageGenPartialImageEventSize1024x1024 ImageGenPartialImageEventSize = "1024x1024"
const ImageGenPartialImageEventSize1024x1536 ImageGenPartialImageEventSize = "1024x1536"
const ImageGenPartialImageEventSize1536x1024 ImageGenPartialImageEventSize = "1536x1024"
const ImageGenPartialImageEventSizeAuto ImageGenPartialImageEventSize = "auto"
Type ImageGenerationPartialImage

The type of the event. Always image_generation.partial_image.

type ImageGenStreamEventUnion interface{…}

Emitted when a partial image is available during image generation streaming.

Accepts one of the following:
type ImageGenPartialImageEvent struct{…}

Emitted when a partial image is available during image generation streaming.

B64JSON string

Base64-encoded partial image data, suitable for rendering as an image.

Background ImageGenPartialImageEventBackground

The background setting for the requested image.

Accepts one of the following:
const ImageGenPartialImageEventBackgroundTransparent ImageGenPartialImageEventBackground = "transparent"
const ImageGenPartialImageEventBackgroundOpaque ImageGenPartialImageEventBackground = "opaque"
const ImageGenPartialImageEventBackgroundAuto ImageGenPartialImageEventBackground = "auto"
CreatedAt int64

The Unix timestamp when the event was created.

OutputFormat ImageGenPartialImageEventOutputFormat

The output format for the requested image.

Accepts one of the following:
const ImageGenPartialImageEventOutputFormatPNG ImageGenPartialImageEventOutputFormat = "png"
const ImageGenPartialImageEventOutputFormatWebP ImageGenPartialImageEventOutputFormat = "webp"
const ImageGenPartialImageEventOutputFormatJPEG ImageGenPartialImageEventOutputFormat = "jpeg"
PartialImageIndex int64

0-based index for the partial image (streaming).

Quality ImageGenPartialImageEventQuality

The quality setting for the requested image.

Accepts one of the following:
const ImageGenPartialImageEventQualityLow ImageGenPartialImageEventQuality = "low"
const ImageGenPartialImageEventQualityMedium ImageGenPartialImageEventQuality = "medium"
const ImageGenPartialImageEventQualityHigh ImageGenPartialImageEventQuality = "high"
const ImageGenPartialImageEventQualityAuto ImageGenPartialImageEventQuality = "auto"
Size ImageGenPartialImageEventSize

The size of the requested image.

Accepts one of the following:
const ImageGenPartialImageEventSize1024x1024 ImageGenPartialImageEventSize = "1024x1024"
const ImageGenPartialImageEventSize1024x1536 ImageGenPartialImageEventSize = "1024x1536"
const ImageGenPartialImageEventSize1536x1024 ImageGenPartialImageEventSize = "1536x1024"
const ImageGenPartialImageEventSizeAuto ImageGenPartialImageEventSize = "auto"
Type ImageGenerationPartialImage

The type of the event. Always image_generation.partial_image.

type ImageGenCompletedEvent struct{…}

Emitted when image generation has completed and the final image is available.

B64JSON string

Base64-encoded image data, suitable for rendering as an image.

Background ImageGenCompletedEventBackground

The background setting for the generated image.

Accepts one of the following:
const ImageGenCompletedEventBackgroundTransparent ImageGenCompletedEventBackground = "transparent"
const ImageGenCompletedEventBackgroundOpaque ImageGenCompletedEventBackground = "opaque"
const ImageGenCompletedEventBackgroundAuto ImageGenCompletedEventBackground = "auto"
CreatedAt int64

The Unix timestamp when the event was created.

OutputFormat ImageGenCompletedEventOutputFormat

The output format for the generated image.

Accepts one of the following:
const ImageGenCompletedEventOutputFormatPNG ImageGenCompletedEventOutputFormat = "png"
const ImageGenCompletedEventOutputFormatWebP ImageGenCompletedEventOutputFormat = "webp"
const ImageGenCompletedEventOutputFormatJPEG ImageGenCompletedEventOutputFormat = "jpeg"
Quality ImageGenCompletedEventQuality

The quality setting for the generated image.

Accepts one of the following:
const ImageGenCompletedEventQualityLow ImageGenCompletedEventQuality = "low"
const ImageGenCompletedEventQualityMedium ImageGenCompletedEventQuality = "medium"
const ImageGenCompletedEventQualityHigh ImageGenCompletedEventQuality = "high"
const ImageGenCompletedEventQualityAuto ImageGenCompletedEventQuality = "auto"
Size ImageGenCompletedEventSize

The size of the generated image.

Accepts one of the following:
const ImageGenCompletedEventSize1024x1024 ImageGenCompletedEventSize = "1024x1024"
const ImageGenCompletedEventSize1024x1536 ImageGenCompletedEventSize = "1024x1536"
const ImageGenCompletedEventSize1536x1024 ImageGenCompletedEventSize = "1536x1024"
const ImageGenCompletedEventSizeAuto ImageGenCompletedEventSize = "auto"
Type ImageGenerationCompleted

The type of the event. Always image_generation.completed.

Usage ImageGenCompletedEventUsage

For the GPT image models only, the token usage information for the image generation.

InputTokens int64

The number of tokens (images and text) in the input prompt.

InputTokensDetails ImageGenCompletedEventUsageInputTokensDetails

The input tokens detailed information for the image generation.

ImageTokens int64

The number of image tokens in the input prompt.

TextTokens int64

The number of text tokens in the input prompt.

OutputTokens int64

The number of image tokens in the output image.

TotalTokens int64

The total number of tokens (images and text) used for the image generation.

type ImageModel string
Accepts one of the following:
const ImageModelGPTImage1_5 ImageModel = "gpt-image-1.5"
const ImageModelDallE2 ImageModel = "dall-e-2"
const ImageModelDallE3 ImageModel = "dall-e-3"
const ImageModelGPTImage1 ImageModel = "gpt-image-1"
const ImageModelGPTImage1Mini ImageModel = "gpt-image-1-mini"
type ImagesResponse struct{…}

The response from the image generation endpoint.

Created int64

The Unix timestamp (in seconds) of when the image was created.

Background ImagesResponseBackgroundoptional

The background parameter used for the image generation. Either transparent or opaque.

Accepts one of the following:
const ImagesResponseBackgroundTransparent ImagesResponseBackground = "transparent"
const ImagesResponseBackgroundOpaque ImagesResponseBackground = "opaque"
Data []Imageoptional

The list of generated images.

B64JSON stringoptional

The base64-encoded JSON of the generated image. Returned by default for the GPT image models, and only present if response_format is set to b64_json for dall-e-2 and dall-e-3.

RevisedPrompt stringoptional

For dall-e-3 only, the revised prompt that was used to generate the image.

URL stringoptional

When using dall-e-2 or dall-e-3, the URL of the generated image if response_format is set to url (default value). Unsupported for the GPT image models.

OutputFormat ImagesResponseOutputFormatoptional

The output format of the image generation. Either png, webp, or jpeg.

Accepts one of the following:
const ImagesResponseOutputFormatPNG ImagesResponseOutputFormat = "png"
const ImagesResponseOutputFormatWebP ImagesResponseOutputFormat = "webp"
const ImagesResponseOutputFormatJPEG ImagesResponseOutputFormat = "jpeg"
Quality ImagesResponseQualityoptional

The quality of the image generated. Either low, medium, or high.

Accepts one of the following:
const ImagesResponseQualityLow ImagesResponseQuality = "low"
const ImagesResponseQualityMedium ImagesResponseQuality = "medium"
const ImagesResponseQualityHigh ImagesResponseQuality = "high"
Size ImagesResponseSizeoptional

The size of the image generated. Either 1024x1024, 1024x1536, or 1536x1024.

Accepts one of the following:
const ImagesResponseSize1024x1024 ImagesResponseSize = "1024x1024"
const ImagesResponseSize1024x1536 ImagesResponseSize = "1024x1536"
const ImagesResponseSize1536x1024 ImagesResponseSize = "1536x1024"
Usage ImagesResponseUsageoptional

For gpt-image-1 only, the token usage information for the image generation.

InputTokens int64

The number of tokens (images and text) in the input prompt.

InputTokensDetails ImagesResponseUsageInputTokensDetails

The input tokens detailed information for the image generation.

ImageTokens int64

The number of image tokens in the input prompt.

TextTokens int64

The number of text tokens in the input prompt.

OutputTokens int64

The number of output tokens generated by the model.

TotalTokens int64

The total number of tokens (images and text) used for the image generation.

OutputTokensDetails ImagesResponseUsageOutputTokensDetailsoptional

The output token details for the image generation.

ImageTokens int64

The number of image output tokens generated by the model.

TextTokens int64

The number of text output tokens generated by the model.