The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
docs: fix image generation response format from 'image' to 'images' (#16378)
Cesar Garciad65a29b88d44
diff --git a/docs/my-website/docs/completion/image_generation_chat.md b/docs/my-website/docs/completion/image_generation_chat.mdindex 58ae70e2fff..98b718ef4ce 100644--- a/docs/my-website/docs/completion/image_generation_chat.md+++ b/docs/my-website/docs/completion/image_generation_chat.md@@ -15,16 +15,22 @@ Supported Providers:- Google AI Studio (`gemini`)- Vertex AI (`vertex_ai/`)-LiteLLM will standardize the `image` response in the assistant message for models that support image generation during chat completions.+LiteLLM will standardize the `images` response in the assistant message for models that support image generation during chat completions.```python title="Example response from litellm""message": {..."content": "Here's the image you requested:",- "image": {- "url": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA...",- "detail": "auto"- }+ "images": [+ {+ "image_url": {+ "url": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA...",+ "detail": "auto"+ },+ "index": 0,+ "type": "image_url"+ }+ ]}```@@ -47,7 +53,7 @@ response = completion()print(response.choices[0].message.content) # Text response-print(response.choices[0].message.image) # Image data+print(response.choices[0].message.images) # List of image objects```</TabItem>@@ -103,10 +109,16 @@ curl http://0.0.0.0:4000/v1/chat/completions \"message": {"content": "Here's the image you requested:","role": "assistant",- "image": {- "url": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA...",- "detail": "auto"- }+ "images": [+ {+ "image_url": {+ "url": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA...",+ "detail": "auto"+ },+ "index": 0,+ "type": "image_url"+ }+ ]}}],@@ -141,8 +153,8 @@ response = completion()for chunk in response:- if hasattr(chunk.choices[0].delta, "image") and chunk.choices[0].delta.image is not None:- print("Generated image:", chunk.choices[0].delta.image["url"])+ if hasattr(chunk.choices[0].delta, "images") and chunk.choices[0].delta.images is not None:+ print("Generated image:", chunk.choices[0].delta.images[0]["image_url"]["url"])break```@@ -175,7 +187,7 @@ data: {"id":"chatcmpl-123","object":"chat.completion.chunk","created":1723323084data: {"id":"chatcmpl-123","object":"chat.completion.chunk","created":1723323084,"model":"gemini/gemini-2.5-flash-image-preview","choices":[{"index":0,"delta":{"content":"Here's the image you requested:"},"finish_reason":null}]}-data: {"id":"chatcmpl-123","object":"chat.completion.chunk","created":1723323084,"model":"gemini/gemini-2.5-flash-image-preview","choices":[{"index":0,"delta":{"image":{"url":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA...","detail":"auto"}},"finish_reason":null}]}+data: {"id":"chatcmpl-123","object":"chat.completion.chunk","created":1723323084,"model":"gemini/gemini-2.5-flash-image-preview","choices":[{"index":0,"delta":{"images":[{"image_url":{"url":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA...","detail":"auto"},"index":0,"type":"image_url"}]},"finish_reason":null}]}data: {"id":"chatcmpl-123","object":"chat.completion.chunk","created":1723323084,"model":"gemini/gemini-2.5-flash-image-preview","choices":[{"index":0,"delta":{},"finish_reason":"stop"}]}@@ -200,8 +212,8 @@ async def generate_image():)print(response.choices[0].message.content) # Text response- print(response.choices[0].message.image) # Image data-+ print(response.choices[0].message.images) # List of image objects+return response# Run the async function@@ -215,18 +227,28 @@ asyncio.run(generate_image())| Google AI Studio | `gemini/gemini-2.5-flash-image-preview` || Vertex AI | `vertex_ai/gemini-2.5-flash-image-preview` |-## Spec+## Spec-The `image` field in the response follows this structure:+The `images` field in the response follows this structure:```python-"image": {- "url": "data:image/png;base64,<base64_encoded_image>",- "detail": "auto"-}+"images": [+ {+ "image_url": {+ "url": "data:image/png;base64,<base64_encoded_image>",+ "detail": "auto"+ },+ "index": 0,+ "type": "image_url"+ }+]```-- `url` - str: Base64 encoded image data in data URI format-- `detail` - str: Image detail level (always "auto" for generated images)+- `images` - List[ImageURLListItem]: Array of generated images+ - `image_url` - ImageURLObject: Container for image data+ - `url` - str: Base64 encoded image data in data URI format+ - `detail` - str: Image detail level (always "auto" for generated images)+ - `index` - int: Index of the image in the response+ - `type` - str: Type identifier (always "image_url")-The image is returned as a base64-encoded data URI that can be directly used in HTML `<img>` tags or saved to a file.+The images are returned as base64-encoded data URIs that can be directly used in HTML `<img>` tags or saved to files.