Skip to content

Commit 2884a67

Browse files
committed
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.
1 parent f63cf98 commit 2884a67

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

sdk/api/handlers/openai/openai_videos_handlers.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,9 @@ func buildVideosRetrieveAPIResponseFromXAI(videoID string, payload []byte, fallb
559559
} else if duration := gjson.GetBytes(payload, "video.duration"); duration.Exists() {
560560
out, _ = sjson.SetBytes(out, "seconds", duration.String())
561561
}
562+
if videoURL := strings.TrimSpace(gjson.GetBytes(payload, "video.url").String()); videoURL != "" {
563+
out, _ = sjson.SetBytes(out, "video_url", videoURL)
564+
}
562565
out = setOpenAIVideoErrorFromXAI(out, payload)
563566
return out, nil
564567
}

sdk/api/handlers/openai/openai_videos_handlers_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,9 @@ func TestBuildVideosRetrieveAPIResponseFromXAI(t *testing.T) {
317317
if got := gjson.GetBytes(out, "seconds").String(); got != "4" {
318318
t.Fatalf("seconds = %q, want 4", got)
319319
}
320+
if got := gjson.GetBytes(out, "video_url").String(); got != "https://vidgen.x.ai/xai-vidgen-bucket/xai-video-08609066-e7e9-43ba-bd8d-bd29cb6221d9.mp4" {
321+
t.Fatalf("video_url = %q", got)
322+
}
320323
if gjson.GetBytes(out, "video").Exists() {
321324
t.Fatalf("video field must not be exposed in OpenAI retrieve response: %s", string(out))
322325
}

0 commit comments

Comments
 (0)