| --- |
| title: PixVerse Video Generator API |
| emoji: π¬ |
| colorFrom: purple |
| colorTo: blue |
| sdk: docker |
| pinned: false |
| license: mit |
| --- |
| |
| # PixVerse Video Generation API |
|
|
| FastAPI application for generating videos from images using PixVerse AI, with storage on Digital Ocean Spaces. |
|
|
| ## Features |
|
|
| - **Health Check Endpoint**: `/health` - Verify service status |
| - **Video Generation Endpoint**: `/generate-video` - Generate video from image |
| - Firebase authentication |
| - Hugging Face token authorization |
| - Digital Ocean Spaces storage |
|
|
| ## Storage Structure |
|
|
| ``` |
| milestone/ |
| βββ valentine/ |
| βββ source/ # User uploaded images |
| βββ results/ # Generated videos |
| ``` |
|
|
| ## Environment Variables |
|
|
| Create a `.env` file with: |
|
|
| ```env |
| # PixVerse API Configuration |
| PIXVERSE_API_KEY=your-pixverse-api-key |
| |
| # Digital Ocean Spaces Configuration |
| DO_SPACES_KEY=your-digital-ocean-spaces-key |
| DO_SPACES_SECRET=your-digital-ocean-spaces-secret |
| DO_SPACES_BUCKET=your-bucket-name |
| DO_SPACES_REGION=nyc3 |
| DO_SPACES_ENDPOINT=https://nyc3.digitaloceanspaces.com |
| |
| # Firebase Configuration |
| FIREBASE_PROJECT_ID=your-firebase-project-id |
| |
| # Hugging Face Token (for authorization) |
| HF_TOKEN=your-hugging-face-token |
| ``` |
|
|
| ## Installation |
|
|
| ```bash |
| pip install -r requirements.txt |
| ``` |
|
|
| ## Running Locally |
|
|
| ```bash |
| python main.py |
| ``` |
|
|
| Or with uvicorn: |
|
|
| ```bash |
| uvicorn main:app --host 0.0.0.0 --port 7860 --reload |
| ``` |
|
|
| ## API Endpoints |
|
|
| ### 1. Health Check |
|
|
| **GET** `/health` |
|
|
| Response: |
| ```json |
| { |
| "success": true, |
| "message": "Service is running", |
| "data": { |
| "status": "healthy", |
| "service": "PixVerse Video Generation API", |
| "version": "1.0.0" |
| } |
| } |
| ``` |
|
|
| ### 2. Generate Video |
|
|
| **POST** `/generate-video` |
|
|
| **Headers:** |
| - `Authorization`: `Bearer <hf_token>` |
|
|
| **Form Data:** |
| - `image`: Image file (JPG, PNG, WebP) |
| - `user_id`: User ID string (optional) |
| - `prompt_text`: Prompt text for video generation (must contain keywords to match category) |
| - `firebase_id_token`: Firebase ID token |
| - `appname`: App name for database routing (optional) |
|
|
| **Category Matching (4 video types):** |
| The prompt_text is automatically matched to one of 4 categories: |
| - Contains "kiss" β Ai Kiss Video |
| - Contains "hug" β Ai Hug Video |
| - Contains "bf" or "boyfriend" β Ai BF |
| - Contains "gf" or "girlfriend" β Ai GF |
| |
| **Success Response:** |
| ```json |
| { |
| "success": true, |
| "message": "Video created successfully", |
| "data": { |
| "result_url": "https://your-bucket.nyc3.digitaloceanspaces.com/milestone/valentine/results/...", |
| "source_image": "https://your-bucket.nyc3.digitaloceanspaces.com/milestone/valentine/source/...", |
| "video_id": 12345 |
| } |
| } |
| ``` |
| |
| **Error Response:** |
| ```json |
| { |
| "success": false, |
| "message": "Error description", |
| "data": null |
| } |
| ``` |
|
|
| ## Hugging Face Deployment |
|
|
| The API is configured to run on port 7860 for Hugging Face Spaces deployment. |
|
|
| ### Hugging Face Secrets |
|
|
| Set these secrets in your Hugging Face Space: |
| - `PIXVERSE_API_KEY` |
| - `DO_SPACES_KEY` |
| - `DO_SPACES_SECRET` |
| - `DO_SPACES_BUCKET` |
| - `DO_SPACES_REGION` |
| - `DO_SPACES_ENDPOINT` |
| - `FIREBASE_PROJECT_ID` |
| - `HF_TOKEN` |
|
|
| ## cURL Example |
|
|
| ```bash |
| curl -X POST "http://localhost:7860/generate-video" \ |
| -H "Authorization: Bearer your-hf-token" \ |
| -F "image=@/path/to/image.jpg" \ |
| -F "user_id=user123" \ |
| -F "prompt_text=A romantic kiss scene with beautiful effects" \ |
| -F "firebase_id_token=firebase-id-token" \ |
| -F "appname=collage-maker" |
| ``` |
|
|