Skip to content

Commit 8dde037

Browse files
committed
docs: update documentation for image editing feature
- Add /edit endpoint examples and description - Update model tables with editing capabilities - Rename BASE_URL to IMAGE_BASE_URL in docs - Add DEFAULT_MODEL documentation - Remove "production-ready" marketing language
1 parent 6c0c930 commit 8dde037

2 files changed

Lines changed: 101 additions & 89 deletions

File tree

CONFIGURATION.md

Lines changed: 44 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,19 @@ Complete configuration reference for the Image Generation API.
3737
- Default: `./generated_images`
3838
- Docker: Use volume mount (e.g., `/app/generated_images`)
3939

40-
**`BASE_URL`**
40+
**`IMAGE_BASE_URL`**
4141
- Public base URL for serving images
4242
- Default: `http://localhost:8000`
43-
- Production: Your domain (e.g., `https://api.example.com`)
43+
- Example: `https://api.example.com`
4444
- Used to construct full image URLs
4545

46+
### Model Defaults
47+
48+
**`DEFAULT_MODEL`**
49+
- Default model for generation/editing when not specified in request
50+
- Example: `gpt-image-1`, `dall-e-3`
51+
- Optional - if not set, first available model is used
52+
4653
### Security
4754

4855
**`API_BEARER_TOKEN`**
@@ -76,36 +83,30 @@ Complete configuration reference for the Image Generation API.
7683
### OpenAI Models
7784

7885
**dall-e-2**
79-
- Aspect Ratios: `1:1` only (all others fallback to square)
86+
- Aspect Ratios: `1:1` only
8087
- Quality: Not supported
8188
- Max Images (n): 4
82-
- Sizes: 1024x1024
89+
- Editing: Yes (mask-based)
8390

8491
**dall-e-3**
8592
- Aspect Ratios: `1:1`, `16:9`, `9:16`
8693
- Quality: `standard`, `hd`
8794
- Max Images (n): 1
88-
- Sizes: 1024x1024, 1792x1024, 1024x1792
95+
- Editing: No
8996

9097
**gpt-image-1**
9198
- Aspect Ratios: `1:1`, `16:9`, `9:16`
9299
- Quality: Not supported
93100
- Max Images (n): 4
94-
- Sizes: 1024x1024, 1536x1024, 1024x1536
101+
- Editing: Yes (mask-based)
95102

96103
### Google Gemini Models
97104

98105
**gemini-2.0-flash-preview-image-generation**
99106
- Aspect Ratios: `1:1`, `16:9`, `9:16`, `4:3`, `3:4`
100107
- Quality: Not supported
101108
- Max Images (n): 4
102-
- Fast generation
103-
104-
**imagen-3.0-generate-002**
105-
- Aspect Ratios: `1:1`, `16:9`, `9:16`, `4:3`, `3:4`
106-
- Quality: Not supported
107-
- Max Images (n): 4
108-
- High quality output
109+
- Editing: Yes (prompt-based)
109110

110111
## Provider Setup
111112

@@ -204,6 +205,35 @@ Constraints:
204205
- dall-e-3: max 1
205206
- Others: max 4
206207

208+
## Image Editing
209+
210+
The `/edit` endpoint supports two editing modes:
211+
212+
### Mask-based Editing (OpenAI)
213+
214+
Used with `dall-e-2` and `gpt-image-1`. Requires:
215+
- `image`: Source image (upload or URL)
216+
- `mask`: PNG with transparent areas marking regions to edit
217+
- `prompt`: Description of what to generate in masked area
218+
219+
The mask should have transparent (alpha=0) pixels where editing should occur.
220+
221+
### Prompt-based Editing (Gemini)
222+
223+
Used with `gemini-2.0-flash-preview-image-generation`. Requires:
224+
- `image`: Source image (upload or URL)
225+
- `prompt`: Natural language description of the edit
226+
227+
No mask needed - Gemini understands what to change from the prompt alone.
228+
229+
### Input Methods
230+
231+
Images can be provided two ways:
232+
- **File upload**: `image=@photo.png` (multipart form)
233+
- **URL reference**: `image_url=http://localhost:8000/images/abc.png`
234+
235+
URL reference works with previously generated images or external URLs.
236+
207237
## Authentication
208238

209239
### No Authentication
@@ -245,7 +275,7 @@ volumes:
245275
For reverse proxy or custom domain:
246276
247277
```env
248-
BASE_URL=https://api.yourdomain.com
278+
IMAGE_BASE_URL=https://api.yourdomain.com
249279
```
250280

251281
Images will be served at: `https://api.yourdomain.com/images/filename.png`

README.md

Lines changed: 57 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
# Image Generation OpenAPI Server
22

3-
Production-ready OpenAPI server for AI image generation with LiteLLM proxy integration (cost tracking) and direct API fallback support for OpenAI DALL-E and Google Gemini models.
3+
OpenAPI server for AI image generation and editing. Supports LiteLLM proxy (for cost tracking) and direct API access to OpenAI and Google Gemini.
44

55
## Features
66

7-
- **LiteLLM Integration**: Primary provider with automatic cost tracking and unified API
8-
- **Multi-Provider Support**: OpenAI (DALL-E 3, GPT-Image-1) + Google Gemini (Imagen 3.0, Flash)
9-
- **Dynamic Model Discovery**: Auto-loads available models from LiteLLM
10-
- **SSE Streaming**: Real-time progress updates during generation
11-
- **Flexible Responses**: JSON, SSE stream, or HTML preview
12-
- **Local Storage**: Images saved locally and served via static files
13-
- **Comprehensive API**: Full OpenAPI/Swagger documentation
14-
- **Production Ready**: Docker support, health checks, authentication
7+
- **Image Generation**: Create images from text prompts
8+
- **Image Editing**: Edit existing images with mask-based inpainting (OpenAI) or prompt-based editing (Gemini)
9+
- **Multi-Provider**: OpenAI (DALL-E 3, GPT-Image-1) and Google Gemini
10+
- **LiteLLM Integration**: Unified API with cost tracking
11+
- **Dynamic Models**: Auto-discovers available models from LiteLLM
12+
- **Multiple Response Formats**: URL, base64, or markdown
1513

1614
## Quick Start
1715

@@ -62,51 +60,48 @@ docker-compose up -d
6260

6361
## API Examples
6462

65-
### Generate Image (Standard)
63+
### Generate Image
6664

6765
```bash
6866
curl -X POST "http://localhost:8000/generate" \
6967
-H "Content-Type: application/json" \
7068
-d '{
71-
"prompt": "A serene mountain landscape at sunset",
72-
"provider": "litellm",
69+
"prompt": "A mountain landscape at sunset",
7370
"model": "dall-e-3",
74-
"aspect_ratio": "16:9",
75-
"quality": "hd"
71+
"aspect_ratio": "16:9"
7672
}'
7773
```
7874

79-
### Generate with SSE Streaming
75+
### Edit Image (Mask-based, OpenAI)
8076

8177
```bash
82-
curl -N "http://localhost:8000/generate-stream" \
83-
-H "Content-Type: application/json" \
84-
-d '{
85-
"prompt": "A futuristic city skyline",
86-
"aspect_ratio": "9:16"
87-
}'
78+
curl -X POST "http://localhost:8000/edit" \
79+
-F "image=@photo.png" \
80+
-F "mask=@mask.png" \
81+
-F "prompt=Replace the sky with a sunset" \
82+
-F "provider=openai" \
83+
-F "model=gpt-image-1"
8884
```
8985

90-
### Python Client
86+
### Edit Image (Prompt-based, Gemini)
9187

92-
```python
93-
import requests
88+
```bash
89+
curl -X POST "http://localhost:8000/edit" \
90+
-F "image=@photo.png" \
91+
-F "prompt=Make the background more colorful" \
92+
-F "provider=gemini"
93+
```
9494

95-
response = requests.post(
96-
"http://localhost:8000/generate",
97-
json={
98-
"prompt": "A cute cat wearing sunglasses",
99-
"provider": "litellm", # or "openai", "gemini"
100-
"aspect_ratio": "1:1",
101-
"n": 1
102-
}
103-
)
95+
### Edit via URL Reference
10496

105-
result = response.json()
106-
print(f"Image URL: {result['image_url']}")
97+
```bash
98+
curl -X POST "http://localhost:8000/edit" \
99+
-F "image_url=http://localhost:8000/images/abc123.png" \
100+
-F "prompt=Add a hat to the person" \
101+
-F "provider=gemini"
107102
```
108103

109-
### List Available Models
104+
### List Models
110105

111106
```bash
112107
curl "http://localhost:8000/models"
@@ -136,16 +131,19 @@ GEMINI_API_KEY=...
136131

137132
### OpenAI
138133

139-
- **dall-e-3**: HD quality, multiple aspect ratios, n=1 only
140-
- **gpt-image-1**: Newest model, multiple sizes
141-
- **dall-e-2**: Square only, fast generation
134+
| Model | Generation | Editing | Notes |
135+
|-------|------------|---------|-------|
136+
| dall-e-3 | Yes | No | HD quality, multiple aspect ratios |
137+
| gpt-image-1 | Yes | Yes (mask) | Fast, supports inpainting |
138+
| dall-e-2 | Yes | Yes (mask) | Square only |
142139

143140
### Google Gemini
144141

145-
- **gemini-2.0-flash-preview-image-generation**: Fast generation
146-
- **imagen-3.0-generate-002**: High quality
142+
| Model | Generation | Editing | Notes |
143+
|-------|------------|---------|-------|
144+
| gemini-2.0-flash-preview-image-generation | Yes | Yes (prompt) | Fast, prompt-based editing |
147145

148-
See [CONFIGURATION.md](CONFIGURATION.md) for detailed model capabilities.
146+
See [CONFIGURATION.md](CONFIGURATION.md) for details.
149147

150148
## Open WebUI Integration
151149

@@ -161,20 +159,21 @@ For admin/global tools, configure in Admin Settings with server-accessible URL.
161159

162160
### Image Generation
163161

164-
- `POST /generate` - Generate image (JSON response)
165-
- `POST /generate-stream` - Generate with SSE progress
166-
- `POST /generate-preview` - Generate with HTML preview
162+
- `POST /generate` - Generate image from prompt
163+
164+
### Image Editing
165+
166+
- `POST /edit` - Edit existing image (supports file upload or URL reference)
167167

168-
### Model Management
168+
### Models
169169

170170
- `GET /models` - List available models
171171
- `POST /models/refresh` - Refresh model list from LiteLLM
172172

173-
### Health & Info
173+
### Info
174174

175175
- `GET /health` - Health check + provider status
176-
- `GET /` - API information
177-
- `GET /docs` - Interactive API documentation
176+
- `GET /docs` - API documentation
178177

179178
## Configuration
180179

@@ -200,36 +199,19 @@ With coverage:
200199
pytest --cov=app --cov-report=html
201200
```
202201

203-
## Development
202+
## Project Structure
204203

205-
Project structure:
206-
207-
```txt
204+
```
208205
app/
209-
├── main.py # FastAPI application
210-
├── core/ # Configuration & utilities
211-
├── api/routes/ # API endpoints
212-
├── schemas/ # Pydantic models
213-
├── services/ # Business logic
214-
└── utils/ # Helpers
215-
216-
tests/ # Test suite
206+
├── main.py # FastAPI app
207+
├── core/ # Config, security
208+
├── api/routes/ # Endpoints (generate, edit, models, health)
209+
├── schemas/ # Request/response models
210+
└── services/ # Provider integrations
211+
212+
tests/ # Tests
217213
```
218214
219215
## License
220216
221217
MIT
222-
223-
## Contributing
224-
225-
Contributions welcome! Please ensure:
226-
227-
- Tests pass (`pytest`)
228-
- Code follows project style
229-
- Documentation updated
230-
231-
## Support
232-
233-
- Issues: GitHub Issues
234-
- Docs: `/docs` endpoint
235-
- Health: `/health` endpoint

0 commit comments

Comments
 (0)