Skip to content

Image Generation ​

Overview ​

GhostAI supports multi-provider image generation directly in chat. Choose from multiple image models across different providers, and your selection is automatically saved so it persists across sessions.

Image prompts are privacy-protected through the same PII detection pipeline used for text, preventing accidental data leakage through image generation requests.

Availability

Image generation is available on Personal and above when a valid provider key is configured. The image generation tool must be enabled in the chat toolbar.

Supported Image Models ​

Direct Provider Models ​

ModelProviderKey RequiredNotes
DALL-E 3OpenAIopenaiHigh-quality, prompt-following, multiple sizes
Gemini 2.5 Flash ImageGoogle GeminigeminiNative Gemini image generation, fast

OpenRouter Models ​

These models are accessed through your OpenRouter API key:

ModelProviderNotes
Flux 2 ProBlack Forest LabsState-of-the-art open model
GPT-5 Image MiniOpenAI (via OpenRouter)Lightweight OpenAI image generation
Seedream 3.0ByteDanceHigh-quality Asian art styles
Stable Diffusion 3.5 LargeStability AIOpen-source, highly customizable

OpenRouter Gateway

OpenRouter provides access to many image models with a single API key. If you have an OpenRouter key configured, these models appear automatically in the image model selector.

Selecting an Image Model ​

Image Model Selector ​

The image model selector appears in the chat toolbar when the Image Generation tool is enabled. Click the selector dropdown to choose from available models.

Your selected model is automatically saved to your user preferences and restored when you return to GhostAI -- even across browser sessions and devices.

Enabling the Image Tool ​

  1. Look for the tool toggles in the chat toolbar (below the message input)
  2. Enable Image Generation (camera icon)
  3. The image model selector appears next to the tool toggles
  4. Select your preferred model from the dropdown

Model Availability ​

Models appear in the selector based on which provider keys you have configured:

If You Have...You Can Use...
OpenAI keyDALL-E 3
Gemini keyGemini 2.5 Flash Image (direct)
OpenRouter keyFlux 2 Pro, GPT-5 Image Mini, Seedream, Stable Diffusion, Gemini (via OpenRouter)
No keysPlatform default models (if cloud keys are configured)

How It Works ​

Generation Flow ​

User prompt → PII Detection → Tokenized prompt → Image Model API → Image saved to disk → URL returned in chat
  1. PII Protection -- Your image prompt passes through the PII detection pipeline
  2. Model Routing -- GhostAI routes the request to the correct provider based on your selected model
  3. Key Resolution -- The system resolves the appropriate API key using the multi-tier hierarchy (User > Org > Cloud, where environment keys are registered as platform defaults)
  4. Image Generation -- The provider generates the image
  5. Disk Storage -- Generated images are saved to the server's persistent storage
  6. Chat Display -- The image URL is returned and displayed inline in the chat

Image Storage ​

Generated images are stored on the server and served via static file URLs. This approach:

  • Avoids large base64 data in chat messages
  • Enables reliable browser rendering
  • Supports image caching and CDN delivery in production
  • Keeps chat history lightweight

Persistent Model Selection ​

Your image model preference is saved to your user settings on the backend:

  • Saved automatically when you change the model selector
  • Restored on load in both regular chat and comparison chat
  • Per-user -- each user has their own preference
  • Synced via API -- uses the PUT /api/settings/model-config/user endpoint with the default_image_model field

Using in Comparison Chat ​

Image generation works in comparison chat mode too. When comparing models:

  1. Each model pane generates its own unique image independently
  2. The same image model is used across all panes (your selected preference)
  3. Results are routed to the correct pane using unique pane indices
  4. You can compare how different LLMs interpret and describe the same image generation task

Provider Key Requirements ​

To use image generation, you need at least one of these keys configured:

ProviderKey TypeWhere to Get It
OpenAIAPI Key (sk-proj-...)platform.openai.com/api-keys
Google GeminiAPI Key (AIza...)aistudio.google.com/apikey
OpenRouterAPI Key (sk-or-v1-...)openrouter.ai/keys

Keys can be configured at any tier:

  • Personal -- Settings > Provider Keys > User
  • Organization -- Settings > Provider Keys > Organization (admin)
  • Platform -- Settings > Provider Keys > Cloud (cloud admin)

See Bring Your Own Key for details on key management.

Error Handling ​

If image generation fails, GhostAI:

  1. Shows an error message in the chat with the failure reason
  2. Creates an in-app notification alerting you to the issue
  3. Logs the failure for key health monitoring
  4. The health system may mark the key as degraded or unhealthy after repeated failures

Common failure reasons:

ErrorCauseFix
"API key not configured"No key available for the selected model's providerAdd a key in Settings > Provider Keys
"Rate limit exceeded"Too many requests to the providerWait and retry, or switch models
"Content policy violation"Provider rejected the promptRephrase the prompt
"Insufficient quota"Provider account out of creditsTop up your provider account

FAQ ​

Can I use different image models in different chats? ​

Your image model selection is global (per-user). Changing the model affects all new image generations. Previously generated images are not affected.

Do generated images contain my PII? ​

No. Image prompts pass through PII detection and tokenization before being sent to the provider. The provider never sees your original sensitive data.

Where are generated images stored? ​

Images are stored on the GhostAI server in the data/generated_images/ directory and served via /api/generated-images/. In production deployments, this can be backed by cloud storage.

Can my organization admin control which image models are available? ​

Yes. Organization admins can lock or disable specific providers, which affects which image models appear in the selector. For example, disabling the OpenAI provider hides DALL-E 3.

SOC 2 Type II Certified | BAA Available | HIPAA-Ready