diff --git a/sdk/api/handlers/openai/openai_videos_handlers.go b/sdk/api/handlers/openai/openai_videos_handlers.go index 1748eaa6..e5565018 100644 --- a/sdk/api/handlers/openai/openai_videos_handlers.go +++ b/sdk/api/handlers/openai/openai_videos_handlers.go @@ -371,10 +371,6 @@ func buildXAIVideosCreateRequest(rawJSON []byte, model string) ([]byte, xaiVideo if imageURL != "" && len(referenceImages) > 0 { return nil, xaiVideoCreateMetadata{}, fmt.Errorf("image and reference_images cannot be combined on xAI") } - if len(referenceImages) > 0 && duration > 10 { - duration = 10 - seconds = "10" - } videoModel := canonicalXAIVideosModel(model) req := []byte(`{}`) diff --git a/sdk/api/handlers/openai/openai_videos_handlers_test.go b/sdk/api/handlers/openai/openai_videos_handlers_test.go index 29666d88..d64150f5 100644 --- a/sdk/api/handlers/openai/openai_videos_handlers_test.go +++ b/sdk/api/handlers/openai/openai_videos_handlers_test.go @@ -311,6 +311,40 @@ func TestBuildXAIVideosCreateRequestAllowsCustomSeconds(t *testing.T) { } } +func TestBuildXAIVideosCreateRequestPreservesMultiReferenceSeconds(t *testing.T) { + tests := []struct { + seconds string + duration int64 + }{ + {seconds: "1", duration: 1}, + {seconds: "6", duration: 6}, + {seconds: "10", duration: 10}, + {seconds: "11", duration: 11}, + {seconds: "15", duration: 15}, + } + + for _, tt := range tests { + t.Run("seconds_"+tt.seconds, func(t *testing.T) { + rawJSON := []byte(`{"prompt":"animate","seconds":"` + tt.seconds + `","reference_images":["https://example.com/first.png","https://example.com/second.png"]}`) + + req, meta, err := buildXAIVideosCreateRequest(rawJSON, defaultXAIVideosModel) + if err != nil { + t.Fatalf("buildXAIVideosCreateRequest() error = %v", err) + } + + if got := gjson.GetBytes(req, "duration").Int(); got != tt.duration { + t.Fatalf("duration = %d, want %d", got, tt.duration) + } + if meta.Seconds != tt.seconds { + t.Fatalf("meta seconds = %q, want %q", meta.Seconds, tt.seconds) + } + if got := gjson.GetBytes(req, "reference_images.#").Int(); got != 2 { + t.Fatalf("reference image count = %d, want 2", got) + } + }) + } +} + func TestBuildXAIVideosCreateRequestRejectsFileIDReference(t *testing.T) { rawJSON := []byte(`{"prompt":"animate","input_reference":{"file_id":"file_123"}}`)