FastAPI async wrapper for Freepik cloud AI API supporting image generation (Mystic, Flux Dev/Pro, SeedReam), video generation (Kling, MiniMax, Seedance), image editing (upscale, relight, style transfer, expand, inpaint), and utilities (background removal, classifier, audio isolation). Includes async task tracking with polling, Docker containerization, and Gitea CI/CD workflow. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
32 lines
806 B
Python
32 lines
806 B
Python
import logging
|
|
import os
|
|
|
|
import psutil
|
|
from fastapi import APIRouter
|
|
|
|
from app.schemas.system import HealthResponse, SystemInfoResponse
|
|
from app.services import freepik_client, task_tracker
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
router = APIRouter(prefix='/api/v1', tags=['system'])
|
|
|
|
|
|
@router.get('/health', response_model=HealthResponse)
|
|
async def health_check():
|
|
return HealthResponse()
|
|
|
|
|
|
@router.get('/system', response_model=SystemInfoResponse)
|
|
async def system_info():
|
|
api_key_valid = await freepik_client.check_api_key()
|
|
mem = psutil.virtual_memory()
|
|
|
|
return SystemInfoResponse(
|
|
api_key_valid=api_key_valid,
|
|
active_tasks=task_tracker.active_count(),
|
|
cpu_count=os.cpu_count() or 1,
|
|
memory_total=mem.total,
|
|
memory_available=mem.available,
|
|
)
|