Add optional animated GIF output to image generation (#59073)

## What changed

- Gate GIF output behind `features.image_generation_animation`, disabled by default.
- Accept `gif` options for generation and editing, with optional `frame_count` and `frame_duration_ms` controls. Use `gif: {}` for API defaults.
- Preserve animated output with `.gif` filenames and `image/gif` data URLs while providing a still preview to the model.
- Add guidance for simple animations and spritesheet-based GIF edits.

## Testing

Add integration coverage for GIF generation and editing, explicit frame controls and API defaults, saved animation bytes, and still-preview replay across follow-up turns.

GitOrigin-RevId: 08afa0316ae3675921652157836191a649f563cf
This commit is contained in:
Gan Tu
2026-11-03 06:24:24 +00:00
committed by copyberry
parent 29eed28082
commit f9e7b19df8
14 changed files with 548 additions and 43 deletions
@@ -262,6 +262,7 @@ mod tests {
let (response, imagegen_request_id) = client
.generate(
&ImageGenerationRequest {
output: None,
prompt: "a red fox in a field".to_string(),
background: Some(ImageBackground::Opaque),
model: "gpt-image-1.5".to_string(),
@@ -311,6 +312,7 @@ mod tests {
let (response, _) = client
.generate(
&ImageGenerationRequest {
output: None,
prompt: "test".to_string(),
background: None,
model: "gpt-image-2".to_string(),
@@ -341,6 +343,7 @@ mod tests {
let (response, imagegen_request_id) = client
.edit(
&ImageEditRequest {
output: None,
images: vec![
ImageReference::Inline {
image_url: "data:image/png;base64,Zm9v".to_string(),
@@ -389,6 +392,7 @@ mod tests {
let error = client
.generate(
&ImageGenerationRequest {
output: None,
prompt: "a red fox in a field".to_string(),
background: None,
model: "gpt-image-1.5".to_string(),