A FastAPI backend for AI-powered image editing, logo generation, and campaign asset creation using Google Gemini image models.
Grace exposes a lightweight REST API that transforms text prompts and image uploads into edited or generated graphics.
Key capabilities:
- edit a selected region in a base image using a prompt and optional mask
- generate logo concepts from a prompt and optional reference image
- produce cohesive campaign image sets as a downloadable ZIP
- automatically save output assets to
artifacts/and serve them from/images
This API is useful for designers, marketing teams, and developers who want to prototype visual content quickly.
It is especially helpful when you need:
- rapid image editing with targeted prompts
- quick logo generation from brand descriptions
- batch generation of campaign visuals with consistent style
- an easily deployable backend for AI-assisted creative workflows
- Python 3.11 or newer
- A Google Gemini API key
- Git clone of this repository
python -m venv .venv
.venv\Scripts\activate
pip install -r requirements.txtCopy example.env to .env and update the value:
copy example.env .envThen open .env and set:
GEMINI_API_KEY=YOUR_API_KEY_HEREpython -m uvicorn main:app --reloadThe service will be available at http://127.0.0.1:8000.
GET /healthReturns a simple service status response.
POST /edit/areaForm fields:
prompt(string, required)base_image(file, required)mask_image(file, optional)
Example curl:
curl -X POST http://127.0.0.1:8000/edit/area \
-F "prompt=Change the logo color to gold and sharpen the text" \
-F "base_image=@input.png" \
-F "mask_image=@mask.png"POST /logo/generateForm fields:
prompt(string, required)reference_image(file, optional)
Example curl:
curl -X POST http://127.0.0.1:8000/logo/generate \
-F "prompt=Minimalist technology brand logo for a premium SaaS product" \
-F "reference_image=@style.png"POST /campaign/generateForm fields:
prompt(string, required)brand_image(file, optional)count(integer, optional, default30)
Example curl:
curl -X POST http://127.0.0.1:8000/campaign/generate \
-F "prompt=Bold social media campaign for a modern coffee brand" \
-F "brand_image=@brand.png" \
-F "count=10" --output campaign.zipmain.py— FastAPI app and middleware setupconfig.py— environment configuration loaderrouters/— route handlers for editing, logo, and campaign featuresservices/gemini.py— Google Gemini client integration and image generation logicinstruction.py— instruction prompts used by the AI modelartifacts/— generated image and ZIP output storagerequirements.txt— Python dependenciesexample.env— environment variable template
If you need help:
- open an issue in this repository
- inspect the source code in
routers/andservices/ - review
example.envfor configuration guidance
Contributions are welcome through issues and pull requests.
Please keep changes focused on usability, API stability, and compatibility with the Gemini image generation workflow.
This project is licensed under the terms in LICENSE.