# Meta AI Image Generation Service FastAPI wrapper for Meta AI image generation using [metaai-api](https://github.com/mir-ashiq/metaai-api). ## Features - 🎨 **Image Generation** - Generate AI images via Meta AI - 🔐 **Cookie Auth** - Uses Facebook/Meta cookies for authentication - ⚡ **Rate Limiting** - Built-in rate limiting to prevent shadowban - 🐳 **Docker Ready** - Easy deployment with Docker ## Quick Start ### Local Development ```bash # Install dependencies pip install -r requirements.txt pip install git+https://github.com/mir-ashiq/metaai-api.git # Run server uvicorn app.main:app --reload --port 8000 ``` ### Docker ```bash docker build -t meta-ai-service . docker run -p 8000:8000 meta-ai-service ``` ## API Endpoints | Endpoint | Method | Description | |----------|--------|-------------| | `/health` | GET | Health check | | `/generate/sync` | POST | Sync generation (waits for result) | | `/generate` | POST | Async generation (returns task_id) | | `/status/{task_id}` | GET | Get async task status | | `/rate-limit` | GET | Get rate limit status | ## Usage Example ```python import requests response = requests.post("http://localhost:8000/generate/sync", json={ "prompt": "Imagine a beautiful sunset over mountains", "cookies": [ {"name": "c_user", "value": "..."}, {"name": "xs", "value": "..."}, # ... other Facebook/Meta cookies ] }) print(response.json()) # {"success": true, "images": [{"url": "...", "prompt": "...", "model": "imagine"}]} ``` ## Required Cookies You need Facebook/Meta cookies for authentication: | Cookie | Description | |--------|-------------| | `c_user` | Facebook user ID | | `xs` | Facebook session token | | `sb` | Session browser identifier | | `datr` | Device tracking | | `abra_sess` | Meta AI session | Export cookies from browser using Cookie-Editor extension. ## Environment Variables | Variable | Default | Description | |----------|---------|-------------| | `META_RATE_LIMIT_DELAY` | 30 | Seconds between requests | | `META_MAX_REQUESTS_HOUR` | 30 | Max requests per hour | ## Updating metaai-api To get the latest version of the underlying library: ```bash pip install -U git+https://github.com/mir-ashiq/metaai-api.git ``` ## License MIT