Spaces:
Sleeping
Sleeping
| title: Img Edit Agent API | |
| emoji: πΌοΈ | |
| colorFrom: indigo | |
| colorTo: blue | |
| sdk: docker | |
| app_port: 7860 | |
| pinned: false | |
| # AI Image Editor API | |
| FastAPI service powering the Img Edit Agent web app. It provides chat-driven image editing and generation. | |
| ## Features | |
| - **POST `/chat`** β Send a message and optional image metadata; receives an AI reply with optional generated image details. | |
| - **GET `/health`** β Reports service and database status. | |
| - **Rate limiting & startup hooks** β Initializes a rate-limit table on startup and logs shutdown events. | |
| - **Modular LLM tools** β Uses the `llm` package for agent logic, database connections, and utilities. | |
| ## Project Structure | |
| ``` | |
| api/ | |
| βββ server/ # FastAPI application | |
| βββ llm/ # LLM agent and helpers | |
| βββ tests/ # pytest suite | |
| βββ Dockerfile # Container build | |
| βββ README.md | |
| ``` | |
| ## Running Locally | |
| ```bash | |
| pip install -e .[dev] | |
| uvicorn server.main:app --host 0.0.0.0 --port 8000 | |
| ``` | |
| ## API Reference | |
| ### POST `/chat` | |
| Request body: | |
| ```json | |
| { | |
| "message": "Describe edit", | |
| "selected_images": [{ "id": "...", "url": "..." }], | |
| "user_id": "optional" | |
| } | |
| ``` | |
| Response: | |
| ```json | |
| { | |
| "response": "AI response", | |
| "status": "success", | |
| "generated_image": { "id": "...", "url": "..." } | |
| } | |
| ``` | |
| ### GET `/health` | |
| Returns service and database status. | |
| ## Deployment | |
| This API is built to run as a Docker container on [Hugging Face Spaces](https://huggingface.co/spaces). | |