Chameleon

Image Generation

Generate images with AI using multiple providers

Image Generation

Create AI-generated images from text descriptions using OpenAI DALL-E, Replicate Flux, or Kling AI.

Supported Providers

OpenAI DALL-E 3

Model: dall-e-3

Features:

  • Highest quality images
  • Best prompt understanding
  • 1024×1024 or 1792×1024 resolution
  • Natural language prompts

Cost: 5 credits per image

Best For: Professional images, realistic photos, detailed artwork

OpenAI DALL-E 2

Model: dall-e-2

Features:

  • Good quality
  • Faster generation
  • 512×512, 1024×1024 resolution
  • Lower cost alternative

Cost: 5 credits per image

Best For: Quick iterations, concept art

Replicate Flux Schnell

Model: black-forest-labs/flux-schnell

Features:

  • Fast generation (10-20 seconds)
  • Good quality
  • Open source model
  • Cost-effective

Cost: 3 credits per image

Best For: Rapid prototyping, bulk generation

Kling AI

Model: kling-v1

Features:

  • Asian art style support
  • Good quality
  • Moderate speed

Cost: 4 credits per image

Best For: Asian aesthetics, anime style

Quick Start

Using AI Generator

  1. Visit /ai-generator
  2. Select Image Generation
  3. Choose provider (default: OpenAI)
  4. Select model (default: dall-e-3)
  5. Enter prompt
  6. Click Generate
  7. Wait 10-30 seconds
  8. View and download

Using API

const generateImage = async () => {
  const response = await fetch("/api/generator/generate", {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({
      ai_type: "image",
      provider: "openai",
      model: "dall-e-3",
      prompt: "A serene Japanese garden with koi pond",
    }),
  });
  
  const { data } = await response.json();
  
  // Poll for result
  setTimeout(async () => {
    const result = await fetch("/api/generator/query", {
      method: "POST",
      headers: { "Content-Type": "application/json" },
      body: JSON.stringify({ gen_id: data.gen_id }),
    });
    
    const { data: { result_urls } } = await result.json();
    console.log("Image URL:", result_urls[0]);
  }, 15000); // Wait 15 seconds
};

Prompt Engineering

Structure of a Good Prompt

[Subject] + [Action/Pose] + [Environment] + [Style] + [Details]

Example:

Subject: A red sports car
Action: drifting around a corner
Environment: in a neon-lit cyberpunk city
Style: cinematic, dramatic lighting
Details: motion blur, rain reflections, 4K quality

Full Prompt:

A red sports car drifting around a corner in a neon-lit cyberpunk city,
cinematic dramatic lighting, motion blur, rain reflections, 4K quality

Prompt Examples

Portrait:

Professional headshot of a business woman, confident expression,
office background, natural lighting, sharp focus, corporate style

Landscape:

Majestic mountain landscape at sunrise, misty valleys, 
golden hour lighting, wide angle, nature photography

Product:

Modern smartphone on a clean white surface, minimalist composition,
soft shadows, product photography, high-end commercial style

Artistic:

Abstract art, flowing liquid colors, purple and gold gradient,
smooth curves, digital art, 8K resolution

Fantasy:

Dragon flying over ancient castle, magical atmosphere,
fantasy art style, detailed scales, dramatic clouds

Tips for Better Results

  1. Be Specific:

    • Instead of "a dog", say "a golden retriever puppy"
    • Instead of "nice lighting", say "soft morning sunlight"
  2. Include Style:

    • Photography: "professional photo", "DSLR", "bokeh"
    • Art: "oil painting", "watercolor", "digital art"
    • 3D: "3D render", "octane render", "unreal engine"
  3. Mention Quality:

    • "4K", "8K", "high resolution"
    • "professional", "award-winning"
    • "detailed", "intricate"
  4. Avoid Negatives:

    • DALL-E doesn't support negative prompts well
    • Focus on what you WANT, not what you don't want

Configuration

API Keys

Method 1: Admin UI (Recommended)

  1. Visit /admin/ai-config
  2. Add providers: openai, replicate, kling
  3. Enter API keys
  4. Enable and save

Method 2: Environment Variables

OPENAI_API_KEY="sk-proj-xxx"
REPLICATE_API_TOKEN="r8_xxx"
KLING_ACCESS_KEY="xxx"

Get API Keys

OpenAI:

  1. Visit platform.openai.com
  2. Sign up / Sign in
  3. Go to API keys
  4. Create new secret key
  5. Copy and save (shown only once)

Replicate:

  1. Visit replicate.com
  2. Sign up / Sign in
  3. Go to Account > API tokens
  4. Copy default token or create new

Kling:

  1. Visit Kling AI platform
  2. Sign up and verify account
  3. Get API access key from dashboard

Advanced Usage

Batch Generation

Generate multiple images:

const prompts = [
  "A red apple on white background",
  "A green apple on white background", 
  "A yellow apple on white background",
];

for (const prompt of prompts) {
  await fetch("/api/generator/generate", {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({
      ai_type: "image",
      provider: "replicate", // Cheaper for batch
      model: "black-forest-labs/flux-schnell",
      prompt,
    }),
  });
  
  // Add delay to avoid rate limiting
  await new Promise(r => setTimeout(r, 1000));
}

Style Transfer

Create variations of a concept in different styles:

const basePrompt = "A coffee cup on a wooden table";
const styles = [
  "photorealistic, DSLR, shallow depth of field",
  "oil painting, impressionist style, visible brush strokes",
  "minimalist vector art, flat design, pastel colors",
  "anime style, vibrant colors, cel shading",
];

styles.forEach(style => {
  generateImage(`${basePrompt}, ${style}`);
});

Credit Costs Comparison

ProviderModelCostSpeedQuality
OpenAIDALL-E 35MediumHighest
OpenAIDALL-E 25FastGood
ReplicateFlux3FastGood
Klingkling-v14MediumGood

Recommendation:

  • Best Quality: OpenAI DALL-E 3
  • Best Value: Replicate Flux Schnell
  • Balanced: Kling v1

Troubleshooting

Image not generating

Check:

  1. Credit balance (need 3-5 credits)
  2. API key configured
  3. Provider service status
  4. Prompt doesn't violate policies

Poor quality results

Try:

  1. Switch to DALL-E 3
  2. Add quality keywords: "high resolution", "professional"
  3. Be more specific in prompt
  4. Regenerate with refined prompt

Content policy violation

Error: "Your request was rejected as a result of our safety system"

Solutions:

  • Avoid violence, gore, explicit content
  • Rephrase prompt to be more general
  • Use different provider
  • Check provider's content policy

Rate limit exceeded

Error: "Rate limit exceeded"

Solutions:

  • Wait a few minutes before retrying
  • Use different API key
  • Upgrade API quota with provider
  • Use alternative provider

Best Practices

  1. Test prompts iteratively:

    • Start simple
    • Refine based on results
    • Build a prompt library
  2. Choose right provider:

    • Quality needed? → DALL-E 3
    • Cost conscious? → Replicate Flux
    • Specific style? → Try different providers
  3. Download immediately:

    • URLs expire
    • Save important results
  4. Monitor credits:

    • Check balance regularly
    • Plan generations accordingly

Next Steps