Add resolution parameter to video generation requests and implement video status polling endpoint
Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
@@ -74,6 +74,7 @@ class VideoRequest(BaseModel):
|
||||
prompt: str
|
||||
duration_seconds: int | None = None
|
||||
aspect_ratio: str = "16:9"
|
||||
resolution: str | None = None # e.g. "480p", "720p", "1080p"
|
||||
|
||||
|
||||
class VideoFromImageRequest(BaseModel):
|
||||
@@ -82,6 +83,7 @@ class VideoFromImageRequest(BaseModel):
|
||||
prompt: str
|
||||
duration_seconds: int | None = None
|
||||
aspect_ratio: str = "16:9"
|
||||
resolution: str | None = None # e.g. "480p", "720p", "1080p"
|
||||
|
||||
|
||||
class VideoResponse(BaseModel):
|
||||
|
||||
@@ -100,6 +100,7 @@ async def generate_video(
|
||||
prompt=body.prompt,
|
||||
duration_seconds=body.duration_seconds,
|
||||
aspect_ratio=body.aspect_ratio,
|
||||
resolution=body.resolution,
|
||||
)
|
||||
except Exception as exc:
|
||||
raise HTTPException(
|
||||
@@ -131,6 +132,7 @@ async def generate_video_from_image(
|
||||
prompt=body.prompt,
|
||||
duration_seconds=body.duration_seconds,
|
||||
aspect_ratio=body.aspect_ratio,
|
||||
resolution=body.resolution,
|
||||
)
|
||||
except Exception as exc:
|
||||
raise HTTPException(
|
||||
|
||||
@@ -81,6 +81,7 @@ async def generate_video(
|
||||
prompt: str,
|
||||
duration_seconds: int | None = None,
|
||||
aspect_ratio: str = "16:9",
|
||||
resolution: str | None = None,
|
||||
) -> dict[str, Any]:
|
||||
"""Request text-to-video generation via OpenRouter."""
|
||||
base_url = os.getenv("OPENROUTER_BASE_URL", OPENROUTER_BASE_URL)
|
||||
@@ -91,6 +92,8 @@ async def generate_video(
|
||||
}
|
||||
if duration_seconds is not None:
|
||||
payload["duration_seconds"] = duration_seconds
|
||||
if resolution is not None:
|
||||
payload["resolution"] = resolution
|
||||
async with httpx.AsyncClient(timeout=120) as client:
|
||||
resp = client.build_request(
|
||||
"POST", f"{base_url}/videos", headers=_headers(), json=payload
|
||||
@@ -106,6 +109,7 @@ async def generate_video_from_image(
|
||||
prompt: str,
|
||||
duration_seconds: int | None = None,
|
||||
aspect_ratio: str = "16:9",
|
||||
resolution: str | None = None,
|
||||
) -> dict[str, Any]:
|
||||
"""Request image-to-video generation via OpenRouter."""
|
||||
base_url = os.getenv("OPENROUTER_BASE_URL", OPENROUTER_BASE_URL)
|
||||
@@ -117,6 +121,8 @@ async def generate_video_from_image(
|
||||
}
|
||||
if duration_seconds is not None:
|
||||
payload["duration_seconds"] = duration_seconds
|
||||
if resolution is not None:
|
||||
payload["resolution"] = resolution
|
||||
async with httpx.AsyncClient(timeout=120) as client:
|
||||
resp = client.build_request(
|
||||
"POST", f"{base_url}/videos", headers=_headers(), json=payload
|
||||
|
||||
Reference in New Issue
Block a user