Support direct GCS output (storageUri) for 'gemini-2.5-flash-image' to prevent OOM in high concurrency
Maintainer thường phản hồi trong vòng 1 ngày
@hemasekhar-p đang làm issue này rồi.
Từ ngày 15/12/2025.
Đánh giá
Issue này chưa được đánh giá.
Mô tả
SDK Version
1.21.0
Model Used
gemini-2.5-flash-image
Description
I am using the google-genai SDK to generate images using the gemini-2.5-flash-image model via the client.models.generateContent method.
Currently, the SDK returns the generated image directly as raw bytes (inline data) in the response memory. While this works for single requests, it causes significant memory pressure (OOM) in high-concurrency scenarios because the application server must hold multiple large image buffers in the heap before uploading them to storage (e.g., S3/GCS).
In the legacy Vertex AI Imagen API (e.g., imagen-3.0), we could provide a storageUri parameter to instruct the model to write the output directly to Google Cloud Storage (GCS), returning only the URI. This allowed for "zero-copy" handling on the client side.
My question is:
Is there a way to configure a GCS destination (similar to storageUri or outputConfig) in GenerateContentConfig for Gemini image generation models? If not, are there any plans to support this feature?
Current Code Implementation
Here is how I am currently calling the API. The imageByte array is the bottleneck.
public GoogleVertexAiResponse imageGenByNanoBanana(GoogleVertexAiRequest aiRequest){
// ... validation logic ...
GenerateContentConfig.Builder contentConfigBuilder =
GenerateContentConfig.builder()
.candidateCount(1)
.httpOptions(HttpOptions.builder()
.apiVersion("v1")
.timeout(60000)
.build());
if(!StringUtils.isEmpty(aiRequest.getAspectRatio())){
contentConfigBuilder.imageConfig(ImageConfig.builder()
.aspectRatio(aiRequest.getAspectRatio())
.build());
}
GenerateContentConfig contentConfig = contentConfigBuilder.build();
try {
// The response contains the full image bytes in memory
GenerateContentResponse response =
client.models.generateContent(
aiRequest.getModelVersion(), // gemini-2.5-flash-image
aiRequest.getPrompt(),
contentConfig);
List<Part> parts =
response
.candidates()
.flatMap(candidates -> candidates.stream().findFirst())
.flatMap(Candidate::content)
.flatMap(Content::parts)
.orElse(new ArrayList<>());
byte[] imageByte = null;
for(Part part: parts){
// Memory bottleneck here:
if(part.inlineData().flatMap(Blob::data).isPresent()){
imageByte = part.inlineData().flatMap(Blob::data).get();
break;
}
}
// ... upload logic ...
} catch (Exception e){
log.error("Google Vertex Ai Image Gen Occur An Error: {}", e.getMessage(), e);
return handleException(e);
}
}
Expected Behavior
I would like to be able to specify a GCS URI in the config so that the response returns a reference to the file instead of the raw bytes.
Example (Hypothetical):
GenerateContentConfig.builder()
.imageConfig(ImageConfig.builder()
.storageUri("gs://my-bucket/output/") // feature request
.build())
.build();
Thanks
- Ngôn ngữ chính
- Java
- Star
- 398
- Fork
- 126
- Merge trung bình
- 1 ngày 12 giờ
- Pull request đã merge (30 ngày)
- 71
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của googleapis/java-genai
-
ResponseStream.close() can block on the reader lock before closing the HTTP responseCó thể đã có người làm @hirematha đã nhận 1 ngày trước. Đang mởpriority: p2 type: bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
googleapis/java-genai#1372 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Interactions API: GaosClientException.getMessage() only returns "400 . API error occurred" and omits the server error detailsCó thể đã có người làm @hemasekhar-p đã nhận 25 ngày trước. Đang mởpriority: p2 type: bug
googleapis/java-genai#1282 · 1 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Interactions API: store(false) omits "id", breaking Interaction and InteractionCompletedEvent deserializationCó thể đã có người làm @hemasekhar-p đã nhận 25 ngày trước. Đang mởpriority: p2 type: bug
googleapis/java-genai#1281 · 1 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Interaction.outputText() always returns Optional.empty() (SDK-computed field is never populated)Có thể đã có người làm @hemasekhar-p đã nhận 25 ngày trước. Đang mởpriority: p2 type: bug
googleapis/java-genai#1280 · 1 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Gen AI with structured output - `propertyOrdering` in Python vs. Java implementationsCó thể đã có người làm @hemasekhar-p đã nhận 79 ngày trước. Đang mởpriority: p3 type: feature request
googleapis/java-genai#1169 · 1 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của googleapis/java-genai
Issue tương tự
-
status: waiting-for-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
spring-projects/spring-framework#37614 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
azure-spring azure-spring-aad Client
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Azure/azure-sdk-for-java#51046 · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
helm-knative-apply.sh fails with Helm 4Có thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mởarea: triage theme: undefined
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
jhipster/generator-jhipster#35895 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
oracle/graalvm-reachability-metadata#11659 ·
Maintainer thường phản hồi trong vòng 1 ngày