AI Image Generation in Bubble.io Using Stable Diffusion or DALL·E
Add AI image generation to your Bubble.io application — covering DALL·E 3 via OpenAI and Stable Diffusion via third-party APIs, with setup instructions, prompt patterns, and storage management.
DALL·E 3 vs Stable Diffusion for Bubble.io
Both work through Bubble’s API Connector. The choice depends on output style, control, and cost.
| Factor | DALL·E 3 (OpenAI) | Stable Diffusion (via Stability AI / Replicate) |
|---|---|---|
| Setup complexity | Simple — same API key as GPT | Moderate — separate API account |
| Output quality | Excellent — realistic, polished | Excellent — highly customisable style |
| Style control | Limited — prompt-driven only | Fine-grained — model, steps, CFG scale |
| Image variations | Limited without editing API | img2img, inpainting available |
| Cost per image | ~$0.04–0.08 per image | Variable — often lower at scale |
| Content policy | Strict — enforced by OpenAI | Moderate — depends on provider |
| Best for | Quick integration, consistent quality | Custom art styles, brand-specific aesthetics |
Connecting DALL·E to Bubble.io
If you already have OpenAI connected for text generation, add a new call to the same API.
Add a new call within your existing OpenAI API in the API Connector:
Call name: Generate Image
Method: POST
URL: https://api.openai.com/v1/images/generations
Request body:
{
"model": "dall-e-3",
"prompt": "",
"n": 1,
"size": "",
"quality": "standard",
"response_format": "url"
} 📌 Available sizes for DALL·E 3: 1024×1024, 1792×1024 (landscape), 1024×1792 (portrait). The response returns a temporary URL valid for 1 hour — always save the image to your storage immediately.
After initialising the call, Bubble maps data[0].url — this is the generated image URL. Also map data[0].revised_prompt which shows the prompt DALL·E actually used (it sometimes revises your input).
Using Stability AI or Replicate in Bubble
For more control over output style, Stability AI and Replicate both work well with Bubble’s API Connector.
Create a Stability AI account
Register at platform.stability.ai. Generate an API key. Their SDXL model produces excellent quality and is well-priced for production use.
Configure the API call
New API in API Connector: name it Stability AI. Authentication: Private key in header, key name: Authorization, value: Bearer YOUR_STABILITY_KEY. Add header: Content-Type: application/json.
Set up the image generation call
Method: POST. URL: https://api.stability.ai/v1/generation/stable-diffusion-xl-1024-v1-0/text-to-image. Body includes text_prompts array, cfg_scale (7), height/width (1024), steps (30), and samples (1).
Handle the base64 response
Stability AI returns base64-encoded image data, not a URL. In your workflow, decode the base64 string and upload it to Bubble’s file storage or an S3 bucket. Bubble’s built-in base64 decode operator handles this.
Saving Generated Images Properly
Generated image URLs are temporary. You must store images permanently as part of your workflow.
Save to Bubble File Storage
After receiving the DALL·E URL or decoded base64, use Bubble’s ‘Upload a file’ action to store the image in Bubble’s native file storage. Store the resulting permanent URL in your database record.
Use S3 for Scale
For apps that generate many images, Bubble’s native file storage becomes expensive. Connect Amazon S3 via the API Connector and upload generated images there. Store the S3 URL in Bubble.
Clean Up Unused Generations
Users often regenerate until they find an image they like. Add a cleanup workflow that deletes rejected generations from storage after 24 hours — this controls storage costs significantly.
Writing Prompts That Produce Consistent Brand Output
Effective Prompt Structure
- Subject first: “A modern office building in Islamabad”
- Style second: “in the style of architectural photography”
- Lighting/mood: “golden hour lighting, warm tones”
- Quality markers: “highly detailed, 4K, professional”
- Negative elements (Stable Diffusion): “no people, no cars, no text”
For Brand Consistency
- Store your brand style as a prefix template in the database
- Always prepend brand style to user-provided descriptions
- Test with 20+ prompts before launching to users
- Save the full prompt used with each image for reproducibility
- Use DALL·E revised_prompt field to understand what was actually generated
Building an App With AI Image Generation?
SA Solutions integrates DALL·E and Stable Diffusion into Bubble.io products — handling image storage, generation UX, prompt engineering, and cost management.