From ca5f2e2ed13c03e5e6f76b4c4e5428a45839268d Mon Sep 17 00:00:00 2001 From: joesun Date: Fri, 27 Feb 2026 19:47:38 +0800 Subject: [PATCH] [diffusion] fix: Support default response_format=url in /v1/images/generations to avoid 400 errors when response_format is omitted (#19360) Co-authored-by: Makcum888e <79456407+Makcum888e@users.noreply.github.com> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --- docs/diffusion/api/openai_api.md | 6 ++++-- .../multimodal_gen/runtime/entrypoints/openai/image_api.py | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/diffusion/api/openai_api.md b/docs/diffusion/api/openai_api.md index 2eda86fdf..30d8d5312 100644 --- a/docs/diffusion/api/openai_api.md +++ b/docs/diffusion/api/openai_api.md @@ -102,7 +102,8 @@ curl -sS -X POST "http://localhost:30010/v1/images/generations" \ ``` > **Note** -> The `response_format=url` option is not supported for `POST /v1/images/generations` and will return a `400` error. +> If `response_format=url` is used and cloud storage is not configured, the API returns +> a relative URL like `/v1/images//content`. **Edit an image** @@ -136,7 +137,8 @@ curl -sS -X POST "http://localhost:30010/v1/images/edits" \ **Download image content** -When `response_format=url` is used with `POST /v1/images/edits`, the API returns a relative URL like `/v1/images//content`. +When `response_format=url` is used with `POST /v1/images/generations` or `POST /v1/images/edits`, +the API returns a relative URL like `/v1/images//content`. **Endpoint:** `GET /v1/images/{image_id}/content` diff --git a/python/sglang/multimodal_gen/runtime/entrypoints/openai/image_api.py b/python/sglang/multimodal_gen/runtime/entrypoints/openai/image_api.py index 9dc2a043a..7d6f1a5db 100644 --- a/python/sglang/multimodal_gen/runtime/entrypoints/openai/image_api.py +++ b/python/sglang/multimodal_gen/runtime/entrypoints/openai/image_api.py @@ -159,6 +159,8 @@ async def generations( result, b64_list=b64_list, cloud_url=cloud_url, + # Provide a local fallback URL when cloud upload is unavailable, mirroring /v1/images/edits. + fallback_url=f"/v1/images/{request_id}/content", ) return ImageResponse(**response_kwargs)