diff --git a/backend/app/routers/generate.py b/backend/app/routers/generate.py index fc4c9c2..284689b 100644 --- a/backend/app/routers/generate.py +++ b/backend/app/routers/generate.py @@ -1,6 +1,7 @@ """Generate router: text, image, video, and image-to-video generation.""" from datetime import datetime, timezone +import httpx from fastapi import APIRouter, Depends, HTTPException, status from ..db import get_conn, get_write_lock @@ -199,9 +200,16 @@ async def generate_video( aspect_ratio=body.aspect_ratio, resolution=body.resolution, ) + except httpx.HTTPStatusError as exc: + detail = ( + f"OpenRouter API error: {exc.response.status_code} - {exc.response.text}" + ) + raise HTTPException( + status_code=status.HTTP_502_BAD_GATEWAY, detail=detail) except Exception as exc: raise HTTPException( - status_code=status.HTTP_502_BAD_GATEWAY, detail=f"OpenRouter error: {exc}") + status_code=status.HTTP_502_BAD_GATEWAY, detail=f"OpenRouter error: {exc}" + ) user_id = current_user.get("id") or current_user.get("sub") job_id = result.get("id", "") @@ -245,9 +253,16 @@ async def generate_video_from_image( aspect_ratio=body.aspect_ratio, resolution=body.resolution, ) + except httpx.HTTPStatusError as exc: + detail = ( + f"OpenRouter API error: {exc.response.status_code} - {exc.response.text}" + ) + raise HTTPException( + status_code=status.HTTP_502_BAD_GATEWAY, detail=detail) except Exception as exc: raise HTTPException( - status_code=status.HTTP_502_BAD_GATEWAY, detail=f"OpenRouter error: {exc}") + status_code=status.HTTP_502_BAD_GATEWAY, detail=f"OpenRouter error: {exc}" + ) user_id = current_user.get("id") or current_user.get("sub") job_id = result.get("id", "") diff --git a/frontend/app/templates/generate_video.html b/frontend/app/templates/generate_video.html index 4b1d13f..2247c82 100644 --- a/frontend/app/templates/generate_video.html +++ b/frontend/app/templates/generate_video.html @@ -63,21 +63,14 @@ AI{% endblock %} {% block content %} - - + + @@ -143,21 +136,14 @@ AI{% endblock %} {% block content %} - - + +