Esahe/ImageTool-Ai-Microservices
0
ImageTools AI Service
FastAPI microservice for AI-powered image processing. Sibling service to the ImageTools Next.js frontend.
Local development
- Create virtual environment:
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate- Install dependencies:
pip install -r requirements.txt- Configure environment:
cp .env.example .env
# Edit .env and set INTERNAL_API_KEY- Run the server:
uvicorn app.main:app --reload --port 7860API docs available at http://localhost:7860/docs (only when INTERNAL_API_KEY is unset).
API
GET /health
Public health check. Returns {"status": "ok"}.
POST /remove-background
Remove the background from an image.
Headers:
X-Internal-Key: <your secret>(required)
Body: multipart/form-data
file: image file (JPEG, PNG, or WebP, max 10 MB)
Response: PNG image with transparent background (image/png).
Docker
docker build -t imagetools-ai .
docker run -p 7860:7860 -e INTERNAL_API_KEY=your_secret imagetools-aiDeploy to Hugging Face Spaces
- Create a new Space with Docker SDK.
- Push this repo to the Space's git remote.
- Set
INTERNAL_API_KEYas a Space secret (Settings → Repository secrets).
The container exposes port 7860 which Hugging Face routes automatically.
Adding a new tool
- Create
app/services/<tool_name>.pywith the business logic. - Create
app/routers/<tool_name>.pywith the FastAPI router. - Import and mount the router in
app/main.py.
No other files need to change.
