@@ -1900,3 +1900,99 @@ type Usage struct {
19001900 // Only populated for /v1/chat/completions endpoint, not for /v1/completions.
19011901 PromptTokensDetails * PromptTokensDetails `json:"prompt_tokens_details,omitempty"` //nolint:tagliatelle //follow openai api
19021902}
1903+
1904+ // ImageGenerationRequest represents the request body for /v1/images/generations.
1905+ // https://platform.openai.com/docs/api-reference/images/create
1906+ type ImageGenerationRequest struct {
1907+ // A text description of the desired image(s). The maximum length is 1000 characters for DALL-E 2,
1908+ // 4000 characters for DALL-E 3, and 32000 characters for gpt-image-1.
1909+ Prompt string `json:"prompt"`
1910+ // The model to use for image generation. Defaults to dall-e-2.
1911+ Model string `json:"model,omitempty"`
1912+ // The number of images to generate. Must be between 1 and 10. For DALL-E 3, only n=1 is supported.
1913+ // Defaults to 1.
1914+ N int `json:"n,omitempty"`
1915+ // The quality of the image that will be generated.
1916+ // - hd or standard for DALL-E 3.
1917+ // - high, medium, or low for gpt-image-1.
1918+ // Defaults to standard for DALL-E 3, auto for gpt-image-1.
1919+ Quality string `json:"quality,omitempty"`
1920+ // The format in which the generated images are returned. Must be one of url or b64_json.
1921+ // URLs are only valid for 60 minutes after the image has been generated.
1922+ // This parameter isn't supported for gpt-image-1 which will always return base64-encoded images.
1923+ // Defaults to url.
1924+ ResponseFormat string `json:"response_format,omitempty"`
1925+ // The size of the generated images.
1926+ // - DALL-E 2: 256x256, 512x512, or 1024x1024.
1927+ // - DALL-E 3: 1024x1024, 1792x1024, or 1024x1792.
1928+ // - gpt-image-1: 1024x1024, 1536x1024, 1024x1536, or auto.
1929+ // Defaults to 1024x1024 (DALL-E 2/3) or auto (gpt-image-1).
1930+ Size string `json:"size,omitempty"`
1931+ // The style of the generated images. vivid or natural. DALL-E 3 only.
1932+ // Defaults to vivid.
1933+ Style string `json:"style,omitempty"`
1934+ // A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse.
1935+ User string `json:"user,omitempty"`
1936+ // The output format of the image generation. Either png, webp, or jpeg.
1937+ // This parameter is only supported for gpt-image-1.
1938+ // Defaults to png.
1939+ OutputFormat string `json:"output_format,omitempty"`
1940+ // The background parameter used for the image generation. Either transparent, opaque, or auto.
1941+ // This parameter is only supported for gpt-image-1.
1942+ // Defaults to auto.
1943+ Background string `json:"background,omitempty"`
1944+ // Control the content-moderation level for images generated by gpt-image-1. Must be either low or auto.
1945+ // Defaults to auto.
1946+ Moderation string `json:"moderation,omitempty"`
1947+ // The compression level (0-100%) for the generated images.
1948+ // This parameter is only supported for gpt-image-1 with the webp or jpeg output formats.
1949+ // Defaults to 100.
1950+ OutputCompression * int `json:"output_compression,omitempty"`
1951+ // The number of partial images to generate.
1952+ // This parameter is used for streaming responses that return partial images. Value must be between 0 and 3.
1953+ // Defaults to 0.
1954+ PartialImages int `json:"partial_images,omitempty"`
1955+ // Generate the image in streaming mode.
1956+ // This parameter is only supported for gpt-image-1.
1957+ // Defaults to false.
1958+ Stream bool `json:"stream,omitempty"`
1959+ }
1960+
1961+ // ImageGenerationInputTokensDetails breakdown of tokens used in the prompt for image generation.
1962+ type ImageGenerationInputTokensDetails struct {
1963+ TextTokens int `json:"text_tokens,omitempty"`
1964+ ImageTokens int `json:"image_tokens,omitempty"`
1965+ }
1966+
1967+ // ImageGenerationUsage represents the usage information for image generation requests.
1968+ type ImageGenerationUsage struct {
1969+ TotalTokens int `json:"total_tokens"`
1970+ InputTokens int `json:"input_tokens"`
1971+ OutputTokens int `json:"output_tokens"`
1972+ InputTokensDetails * ImageGenerationInputTokensDetails `json:"input_tokens_details,omitempty"`
1973+ }
1974+
1975+ // ImageGenerationResponse represents the response body for /v1/images/generations.
1976+ // https://platform.openai.com/docs/api-reference/images/object
1977+ type ImageGenerationResponse struct {
1978+ // The Unix timestamp (in seconds) of when the image was created.
1979+ Created int64 `json:"created"`
1980+ // The list of generated images.
1981+ Data []ImageGenerationResponseData `json:"data"`
1982+ // For gpt-image-1 only, the token usage information for the image generation.
1983+ Usage * ImageGenerationUsage `json:"usage,omitempty"`
1984+ // The output format of the image generation. Either png, webp, or jpeg.
1985+ OutputFormat string `json:"output_format,omitempty"`
1986+ // The quality of the image generated. Either low, medium, or high.
1987+ Quality string `json:"quality,omitempty"`
1988+ // The size of the image generated. Either 1024x1024, 1024x1536, or 1536x1024.
1989+ Size string `json:"size,omitempty"`
1990+ // The background parameter used for the image generation. Either transparent or opaque.
1991+ Background string `json:"background,omitempty"`
1992+ }
1993+
1994+ type ImageGenerationResponseData struct {
1995+ B64JSON string `json:"b64_json,omitempty"`
1996+ URL string `json:"url,omitempty"`
1997+ RevisedPrompt string `json:"revised_prompt,omitempty"`
1998+ }
0 commit comments