Add text-to-image generation support

Implemented complete text-to-image functionality across all AI providers:

Backend additions:
- Added text_to_image() method to AIProvider abstract class
- Implemented for all providers:
  * OpenAI: DALL-E generations API
  * Stability AI: SDXL text-to-image with negative prompts
  * Replicate: SDXL with full parameter control
  * Mock: Placeholder image generation for testing

New API endpoints (/generate):
- POST /generate/text-to-image
  * Generate image from prompt
  * Optional: create new project automatically
  * Configurable width/height (256-2048px)
  * Negative prompt support
  * Provider and model selection

- POST /generate/layer/text-to-image
  * Generate image as layer in existing project
  * Smaller dimensions for layer composition
  * Position control (x, y coordinates)
  * Saves to project layers directory

Features:
- Full provider support (OpenAI, Stability, Replicate, Mock)
- Negative prompts for better control
- Auto-project creation option
- Layer-based generation for compositing
- Dimension validation (256-2048px range)
- Model selection per request

Use cases:
- Create new images from scratch
- Generate elements to add as layers
- Quick ideation and iteration
- Base image creation for further editing

Next: Advanced canvas UI with layers and real-time preview
This commit is contained in:
Claude
2026-01-24 04:06:19 +00:00
parent fc394d76cf
commit 4b936b7a10
4 changed files with 407 additions and 1 deletions
+2 -1
View File
@@ -5,7 +5,7 @@ from contextlib import asynccontextmanager
from app.config import settings
from app.database import init_db
from app.routers import projects, edits, images, patches
from app.routers import projects, edits, images, patches, generate
@asynccontextmanager
@@ -36,6 +36,7 @@ app.include_router(projects.router)
app.include_router(edits.router)
app.include_router(images.router)
app.include_router(patches.router)
app.include_router(generate.router)
@app.get("/")