Skip to content

fix veo3 - #2140

Merged
Calcium-Ion merged 1 commit into
QuantumNous:mainfrom
seefs001:fix/veo3-url
Oct 31, 2025
Merged

fix veo3#2140
Calcium-Ion merged 1 commit into
QuantumNous:mainfrom
seefs001:fix/veo3-url

Conversation

@seefs001

@seefs001 seefs001 commented Oct 31, 2025

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • New Features

    • Extended Gemini channel support for video operations with improved API key management.
    • Added remote URL field for enhanced task result tracking.
  • Bug Fixes

    • Enhanced error handling for missing API keys with clear error responses.
    • Improved Gemini video URL resolution with comprehensive fallback mechanisms.
  • Chores

    • Extended video fetch response handling to support Gemini channels alongside existing platforms.

@coderabbitai

coderabbitai Bot commented Oct 31, 2025

Copy link
Copy Markdown
Contributor

Caution

Review failed

The pull request is closed.

Walkthrough

This PR adds Gemini video proxy support by introducing a stored API key flow in the Task model. It creates a new video_proxy_gemini.go module for URL resolution, extends the Task struct with a PrivateData field to store Gemini API keys populated during task initialization, adds a ConvertToOpenAIVideo method to the Gemini adaptor for format conversion, and expands the relay task builder to handle Gemini channels.

Changes

Cohort / File(s) Summary
Video Proxy Gemini Implementation
controller/video_proxy.go, controller/video_proxy_gemini.go
Replaces direct URL construction with stored API key flow for Gemini channels. Retrieves apiKey from task.PrivateData.Key, resolves Gemini video URL via getGeminiVideoURL(), sets x-goog-api-key header, and returns structured errors on missing key or URL resolution failure. New module implements nested payload parsing to extract video URLs from Gemini task responses.
Task Model Private Data
model/task.go
Adds PrivateData field of type TaskPrivateData to Task struct with database column mapping. Introduces TaskPrivateData struct with Key field and implements Scan/Value methods for JSON serialization. Extends InitTask to instantiate and populate PrivateData.Key with API key from relay info when channel type is Gemini. Enhanced Properties scanning to handle empty JSON.
Gemini Adaptor Enhancement
relay/channel/task/gemini/adaptor.go
Adds ConvertToOpenAIVideo method to TaskAdaptor for OpenAI video format conversion. Introduces regex-based model extraction from operation names. Modifies task result handling to assign dedicated TaskID and direct content URL, with RemoteUrl reserved for generated sample URIs.
Task Info Extension
relay/common/relay_info.go
Adds RemoteUrl field to TaskInfo struct for JSON serialization of remote URLs associated with tasks.
Relay Task Builder
relay/relay_task.go
Expands videoFetchByIDRespBodyBuilder to allow Gemini channel type alongside VertexAi for video fetch response handling.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant VideoProxy as video_proxy.go
    participant GeminiResolver as video_proxy_gemini.go
    participant TaskDB as Task Model
    participant GeminiAPI as Gemini API
    
    Client->>VideoProxy: GET /video/{task_id}
    VideoProxy->>TaskDB: Fetch Task with PrivateData
    TaskDB-->>VideoProxy: Task + PrivateData.Key
    alt API Key Exists
        VideoProxy->>GeminiResolver: getGeminiVideoURL(channel, task, apiKey)
        GeminiResolver->>TaskDB: Extract URL from task data
        alt URL Found in Data
            GeminiResolver-->>VideoProxy: videoURL
        else Fetch from Relay
            GeminiResolver->>GeminiAPI: Retrieve task via relay adaptor
            GeminiAPI-->>GeminiResolver: TaskResult with RemoteUrl/payload
            GeminiResolver->>GeminiResolver: Parse nested structures (uri, response, generateVideoResponse, videos, etc.)
            GeminiResolver-->>VideoProxy: videoURL + apiKey appended
        end
        VideoProxy->>GeminiAPI: Proxy request with x-goog-api-key header
        GeminiAPI-->>Client: Video response
    else Missing Key
        VideoProxy-->>Client: HTTP 500 - API key not stored
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

  • PrivateData serialization logic: Task model now includes database-mapped JSON columns with custom Scan/Value methods; verify marshaling handles nil/empty states correctly and doesn't introduce schema migration issues.
  • Nested payload parsing: video_proxy_gemini.go contains multiple layers of payload structure checks (uri, response, generateVideoResponse, videos array, video maps, generatedSamples); review error handling, nil checks, and parsing robustness.
  • Task initialization flow: InitTask now conditionally populates PrivateData.Key based on channel type; ensure relay info is always available and API key extraction is correct.
  • API key security: Verify API keys are properly validated, not logged in plaintext, and don't leak through error responses.
  • Header handling change: Transition from Authorization header to x-goog-api-key for Gemini; confirm this aligns with Gemini API expectations and doesn't break existing non-Gemini channels.

Possibly related PRs

Poem

🐰 A Gemini hop through keys and frames,
Where private data holds the flames,
URLs parsed from nested deep,
Video proxies through relay steep—
API keys now safely tucked,
Gemini streaming luck! 🎬✨

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fc56f45 and 87999de.

📒 Files selected for processing (6)
  • controller/video_proxy.go (1 hunks)
  • controller/video_proxy_gemini.go (1 hunks)
  • model/task.go (3 hunks)
  • relay/channel/task/gemini/adaptor.go (3 hunks)
  • relay/common/relay_info.go (1 hunks)
  • relay/relay_task.go (1 hunks)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Calcium-Ion
Calcium-Ion merged commit 9629c8a into QuantumNous:main Oct 31, 2025
1 check was pending
ennnnny pushed a commit to ennnnny/new-api that referenced this pull request Mar 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants