Team Ai
Apppublic

Esahe/ImageTool-Ai-Microservices

sourceHugging Facemitupdated 4mo agoView on Hugging Face
0likes
App README

ImageTools AI Service

FastAPI microservice for AI-powered image processing. Sibling service to the ImageTools Next.js frontend.

Local development

  1. 1.Create virtual environment:
bash
python -m venv .venv
source .venv/bin/activate  # Windows: .venv\Scripts\activate
  1. 1.Install dependencies:
bash
pip install -r requirements.txt
  1. 1.Configure environment:
bash
cp .env.example .env
# Edit .env and set INTERNAL_API_KEY
  1. 1.Run the server:
bash
uvicorn app.main:app --reload --port 7860

API 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

bash
docker build -t imagetools-ai .
docker run -p 7860:7860 -e INTERNAL_API_KEY=your_secret imagetools-ai

Deploy to Hugging Face Spaces

  1. 1.Create a new Space with Docker SDK.
  2. 2.Push this repo to the Space's git remote.
  3. 3.Set INTERNAL_API_KEY as a Space secret (Settings → Repository secrets).

The container exposes port 7860 which Hugging Face routes automatically.

Adding a new tool

  1. 1.Create app/services/<tool_name>.py with the business logic.
  2. 2.Create app/routers/<tool_name>.py with the FastAPI router.
  3. 3.Import and mount the router in app/main.py.

No other files need to change.