## Generate `client.images.generate(ImageGenerateParamsbody, RequestOptionsoptions?): ImageGenerateResponse | Stream` **post** `/images/generations` Creates a high-quality image from a text prompt using GPT-IMAGE-1, the latest image generation model with automatic prompt optimization and enhanced visual capabilities. ### Parameters - `ImageGenerateParams = ImageGenerateParamsNonStreaming | ImageGenerateParamsStreaming` - `ImageGenerateParamsBase` - `prompt: string` A text description of the desired image(s). GPT-IMAGE-1 supports up to 32,000 characters and provides automatic prompt optimization for best results. - `background?: string | null` The background setting for the image generation. GPT-IMAGE-1 supports: transparent, opaque, auto. - `model?: string` The model to use for image generation. GPT-IMAGE-1 is the latest model offering the best quality with automatic optimization and enhanced capabilities. - `moderation?: string | null` The moderation setting for the image generation. GPT-IMAGE-1 supports: low, auto. - `n?: number | null` The number of images to generate. GPT-IMAGE-1 only supports n=1. - `output_compression?: number | null` The output compression for the image generation. GPT-IMAGE-1 supports: 0-100. - `output_format?: string | null` The output format for the image generation. GPT-IMAGE-1 supports: png, webp, jpeg. - `partial_images?: number | null` The number of partial image chunks to return during streaming generation. This parameter is optional with a default of 0. When stream=true, this must be greater than 0 to receive progressive updates of the image as it's being generated. Higher values provide more frequent updates but may increase response overhead. - `quality?: string | null` The quality of the image that will be generated. GPT-IMAGE-1 supports: auto (automatically select best quality), high, medium, low. - `size?: string | null` The size of the generated images. GPT-IMAGE-1 supports: auto (automatically select best size), 1536x1024 (landscape), 1024x1536 (portrait). - `stream?: false | null` If set to true, partial image data will be streamed as the image is being generated. When streaming, the response will be sent as server-sent events with partial image chunks. When stream is true, partial_images must be greater than 0. - `false` - `user?: string | null` A unique identifier representing your end-user, which can help DigitalOcean to monitor and detect abuse. - `ImageGenerateParamsNonStreaming extends ImageGenerateParamsBase` - `stream?: false | null` If set to true, partial image data will be streamed as the image is being generated. When streaming, the response will be sent as server-sent events with partial image chunks. When stream is true, partial_images must be greater than 0. - `false` - `ImageGenerateParamsNonStreaming extends ImageGenerateParamsBase` - `stream?: false | null` If set to true, partial image data will be streamed as the image is being generated. When streaming, the response will be sent as server-sent events with partial image chunks. When stream is true, partial_images must be greater than 0. - `false` ### Returns - `ImageGenerateResponse` The response from the image generation endpoint - `created: number` The Unix timestamp (in seconds) of when the images were created - `data: Array` The list of generated images - `b64_json: string` The base64-encoded JSON of the generated image. GPT-IMAGE-1 returns images in b64_json format only. - `revised_prompt?: string` The optimized prompt that was used to generate the image. GPT-IMAGE-1 automatically optimizes prompts for best results. - `background?: string | null` The background setting used for the image generation - `output_format?: string | null` The output format of the generated image - `quality?: string | null` The quality setting used for the image generation - `size?: string | null` The size of the generated image - `usage?: Usage | null` Usage statistics for the image generation request - `input_tokens: number` Number of tokens in the input prompt - `total_tokens: number` Total number of tokens used (input + output) - `input_tokens_details?: InputTokensDetails | null` Detailed breakdown of input tokens - `text_tokens?: number` Number of text tokens in the input - `output_tokens?: number` Number of tokens in the generated output ### Example ```typescript import Gradient from '@digitalocean/gradient'; const client = new Gradient({ accessToken: 'My Access Token', }); const response = await client.images.generate({ prompt: 'A cute baby sea otter floating on its back in calm blue water', }); console.log(response.created); ```