From 2884a67ed02a9c0989b3b3db42a0d07684fd466f Mon Sep 17 00:00:00 2001 From: Luis Pater Date: Tue, 16 Jun 2026 21:06:27 +0800 Subject: [PATCH] feat(videos): add support for video_url extraction and validation in handlers - Updated `openai_videos_handlers` to extract and set `video_url` from payloads when available. - Enhanced unit tests to validate correct `video_url` extraction and inclusion in responses. --- sdk/api/handlers/openai/openai_videos_handlers.go | 3 +++ sdk/api/handlers/openai/openai_videos_handlers_test.go | 3 +++ 2 files changed, 6 insertions(+) diff --git a/sdk/api/handlers/openai/openai_videos_handlers.go b/sdk/api/handlers/openai/openai_videos_handlers.go index 5ec6a6a6..c6fd9931 100644 --- a/sdk/api/handlers/openai/openai_videos_handlers.go +++ b/sdk/api/handlers/openai/openai_videos_handlers.go @@ -559,6 +559,9 @@ func buildVideosRetrieveAPIResponseFromXAI(videoID string, payload []byte, fallb } else if duration := gjson.GetBytes(payload, "video.duration"); duration.Exists() { out, _ = sjson.SetBytes(out, "seconds", duration.String()) } + if videoURL := strings.TrimSpace(gjson.GetBytes(payload, "video.url").String()); videoURL != "" { + out, _ = sjson.SetBytes(out, "video_url", videoURL) + } out = setOpenAIVideoErrorFromXAI(out, payload) return out, nil } diff --git a/sdk/api/handlers/openai/openai_videos_handlers_test.go b/sdk/api/handlers/openai/openai_videos_handlers_test.go index b5d7be63..c17ea48d 100644 --- a/sdk/api/handlers/openai/openai_videos_handlers_test.go +++ b/sdk/api/handlers/openai/openai_videos_handlers_test.go @@ -317,6 +317,9 @@ func TestBuildVideosRetrieveAPIResponseFromXAI(t *testing.T) { if got := gjson.GetBytes(out, "seconds").String(); got != "4" { t.Fatalf("seconds = %q, want 4", got) } + if got := gjson.GetBytes(out, "video_url").String(); got != "https://vidgen.x.ai/xai-vidgen-bucket/xai-video-08609066-e7e9-43ba-bd8d-bd29cb6221d9.mp4" { + t.Fatalf("video_url = %q", got) + } if gjson.GetBytes(out, "video").Exists() { t.Fatalf("video field must not be exposed in OpenAI retrieve response: %s", string(out)) }