-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Add Vertex and Gemini Videos API with Cost Tracking + UI support #16323
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
… sensitive information Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Refactor Video API: Encode provider and model in video_id
merge main
Add Video Generation Mode to UI Model Management and Health Check
* Add veo with openai videos unified specs * Add videos testing to UI * remove mock code * Remove not need ui changes: * Fix mypy errors related to gemini * fix test_transform_video_create_request
merge main
Add vertex ai veo videos endpoint support and cost tracking
Add videos in stable branch
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
| litellm_params={} | ||
| ) | ||
|
|
||
| assert url.startswith("https://generativelanguage.googleapis.com") |
Check failure
Code scanning / CodeQL
Incomplete URL substring sanitization High test
https://generativelanguage.googleapis.com
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 6 hours ago
To fix this issue, we should parse the URL and check that its hostname matches the expected value (or ends with it, if subdomains are allowed), instead of performing a string match on the whole URL. In this test, we want to confirm that the returned URL points at generativelanguage.googleapis.com.
The change should be in the test method test_get_complete_url_default_api_base, replacing
assert url.startswith("https://generativelanguage.googleapis.com")with code that parses the URL and asserts .hostname equality with the correct host:
from urllib.parse import urlparse
...
parsed = urlparse(url)
assert parsed.scheme == "https"
assert parsed.hostname == "generativelanguage.googleapis.com"We may need to add the urllib.parse import at the top of the file if it isn't present.
-
Copy modified line R10 -
Copy modified lines R80-R82
| @@ -7,7 +7,7 @@ | ||
|
|
||
| import httpx | ||
| import pytest | ||
|
|
||
| from urllib.parse import urlparse | ||
| from litellm.llms.gemini.videos.transformation import GeminiVideoConfig | ||
| from litellm.llms.openai.cost_calculation import video_generation_cost | ||
| from litellm.types.router import GenericLiteLLMParams | ||
| @@ -77,9 +77,10 @@ | ||
| litellm_params={} | ||
| ) | ||
|
|
||
| assert url.startswith("https://generativelanguage.googleapis.com") | ||
| parsed = urlparse(url) | ||
| assert parsed.scheme == "https" | ||
| assert parsed.hostname == "generativelanguage.googleapis.com" | ||
| assert "veo-3.0-generate-preview:predictLongRunning" in url | ||
|
|
||
| def test_transform_video_create_request(self): | ||
| """Test transformation of video creation request.""" | ||
| prompt = "A cat playing with a ball of yarn" |
| litellm_params=litellm_params, | ||
| ) | ||
|
|
||
| assert url.startswith("https://custom-endpoint.example.com") |
Check failure
Code scanning / CodeQL
Incomplete URL substring sanitization High test
https://custom-endpoint.example.com
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 20 hours ago
The best way to fix this is to parse the constructed URL and verify that its host (and protocol) match the expected values. Instead of checking that the url string starts with the expected base string, we should use urllib.parse.urlparse to extract the netloc (host) and scheme (protocol) and compare them against the expected ones. This avoids problems where the expected domain/endpoint is present as a prefix but not in the actual host, or is embedded elsewhere in the URL.
We should replace line 87:
assert url.startswith("https://custom-endpoint.example.com")with code that parses url (using urlparse) and confirms both scheme and netloc are correct. This will require importing urlparse from urllib.parse if not already imported.
-
Copy modified line R10 -
Copy modified lines R88-R91
| @@ -7,6 +7,7 @@ | ||
| from unittest.mock import Mock, MagicMock, patch | ||
| import httpx | ||
| import base64 | ||
| from urllib.parse import urlparse | ||
|
|
||
| from litellm.llms.vertex_ai.videos.transformation import ( | ||
| VertexAIVideoConfig, | ||
| @@ -84,7 +85,10 @@ | ||
| litellm_params=litellm_params, | ||
| ) | ||
|
|
||
| assert url.startswith("https://custom-endpoint.example.com") | ||
| # Parse and assert host/scheme instead of unsafe prefix check | ||
| parsed_url = urlparse(url) | ||
| assert parsed_url.scheme == "https" | ||
| assert parsed_url.netloc == "custom-endpoint.example.com" | ||
| assert "test-project" in url | ||
| assert "us-west1" in url | ||
| assert "veo-002" in url |
|
this fails linting @Sameerlite |
|
fixed |

Title
Relevant issues
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
tests/litellm/directory, Adding at least 1 test is a hard requirement - see detailsmake test-unitType
🆕 New Feature
🐛 Bug Fix
🧹 Refactoring
📖 Documentation
🚄 Infrastructure
✅ Test
Changes