Build a complete AI-powered image editing web application using StepFun's step-image-edit-2 API with a Flask backend and React (Vite) frontend.
Flask backend (port 5050) → Vite + React frontend (port 5174)
↓
StepFun step-image-edit-2 API
The backend proxies image uploads, applies feature-specific prompts, calls StepFun API, and returns results. The frontend provides the UI with feature selection, drag-and-drop upload, before/after comparison slider, and download.
Copy the template files from the assets/ directory:
assets/backend/ → <project>/backend/
assets/frontend/ → <project>/frontend/
Create the upload/results directories:
mkdir -p backend/uploads backend/results
Copy assets/backend/.env.example to backend/.env and set:
STEPFUN_API_KEY=<user's actual api key>
STEPFUN_BASE_URL=https://api.stepfun.com/v1
If using Step Plan subscription, change base URL to https://api.stepfun.com/step_plan/v1 instead.
cd backend && pip install -r requirements.txt
cd frontend && npm install
# Terminal 1: Backend
cd backend && python app.py
# Terminal 2: Frontend
cd frontend && npx vite --host 0.0.0.0
Backend runs on port 5050. Frontend runs on port 5174 (5173 is often occupied; if 5174 is also busy, Vite will auto-select the next available port).
The app has 4 features, each with a carefully crafted English prompt for the StepFun API:
feature=restorefeature=portraitfeature=landscapefeature=style&style=POST https://api.stepfun.com/v1/images/edit
{
"model": "step-image-edit-2",
"image": "<base64_encoded_image>",
"prompt": "<feature-specific_english_prompt>",
"response_format": "b64_json"
}
{
"data": [{ "b64_json": "<base64_result>" }]
}
Three stages:
/api, /uploads, /results to Flask backend at port 5050vite.config.js to use 5174clipPath with a range slider for smooth before/after transition.env file in assets/backend/ is renamed to .env.example to avoid leaking keys共 1 个版本