mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-25 01:02:15 +00:00
fix(fal_ai): read only the documented FAL_AI_API_KEY env var
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
parent
aa5f0858f7
commit
e0b455e94e
2 changed files with 22 additions and 3 deletions
|
|
@ -207,10 +207,9 @@ class FalAIVideoConfig(BaseVideoConfig):
|
|||
api_key
|
||||
or (litellm_params.api_key if litellm_params is not None else None)
|
||||
or get_secret_str("FAL_AI_API_KEY")
|
||||
or get_secret_str("FAL_KEY")
|
||||
)
|
||||
if not final_api_key:
|
||||
raise ValueError("fal.ai API key is required")
|
||||
raise ValueError("FAL_AI_API_KEY is not set")
|
||||
validated_headers: Final[_VideoHeaders] = {
|
||||
**headers,
|
||||
"Authorization": f"Key {final_api_key}",
|
||||
|
|
@ -224,7 +223,7 @@ class FalAIVideoConfig(BaseVideoConfig):
|
|||
api_base: str | None,
|
||||
litellm_params: _VideoParams,
|
||||
) -> str:
|
||||
return (api_base or get_secret_str("FAL_AI_QUEUE_API_BASE") or "https://queue.fal.run").rstrip("/")
|
||||
return (api_base or "https://queue.fal.run").rstrip("/")
|
||||
|
||||
def transform_video_create_request(
|
||||
self,
|
||||
|
|
|
|||
|
|
@ -91,6 +91,26 @@ class TestFalAIVideoTransformation:
|
|||
}
|
||||
assert "model" not in body
|
||||
|
||||
def test_get_complete_url_respects_api_base_override(self):
|
||||
url = self.config.get_complete_url(
|
||||
model=MODEL,
|
||||
api_base="https://proxy.internal/",
|
||||
litellm_params={},
|
||||
)
|
||||
|
||||
assert url == "https://proxy.internal"
|
||||
|
||||
def test_validate_environment_requires_fal_ai_api_key(self, monkeypatch):
|
||||
monkeypatch.setattr(fal_video_module, "get_secret_str", lambda _: None)
|
||||
|
||||
with pytest.raises(ValueError, match="FAL_AI_API_KEY is not set"):
|
||||
self.config.validate_environment(
|
||||
headers={},
|
||||
model=MODEL,
|
||||
api_key=None,
|
||||
litellm_params=GenericLiteLLMParams(),
|
||||
)
|
||||
|
||||
def test_transform_video_create_response_encodes_model_and_usage(self):
|
||||
response = Mock(spec=httpx.Response)
|
||||
response.json.return_value = {"request_id": "abc"}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue