# Image Generation

> Generate images with AI models.

**URL:** https://inference.sh/docs/examples/image-generation
**Last updated:** 2026-09-18

---

Generate images with AI models.

---

## Using the Grid

The fastest way to generate images:

1. Go to [Apps](https://inference.sh/apps)
2. Find `stable-diffusion` or `flux`
3. Enter a prompt
4. Click **Run**

---

## Example Prompts

| Style | Prompt |
|-------|--------|
| Photorealistic | "Professional headshot of a woman, studio lighting, 4k" |
| Illustration | "Cute cartoon fox in a forest, children's book style" |
| Abstract | "Flowing waves of blue and purple, digital art" |
| Product | "White sneakers on marble surface, product photography" |

---

## With Python SDK

```python
from inferencesh import inference

client = inference(api_key="inf_your_key")

result = client.run({
    "app": "infsh/stable-diffusion",
    "input": {
        "prompt": "A serene Japanese garden with cherry blossoms",
        "negative_prompt": "blurry, low quality",
        "num_images": 1,
        "size": "1024x1024"
    }
})

# Download the image
image_url = result["output"]["images"][0]["uri"]
print(f"Generated: {image_url}")
```

---

## With JavaScript SDK

```typescript
import { inference } from '@inferencesh/sdk';

const client = inference({ apiKey: 'inf_your_key' });

const result = await client.run({
  app: 'infsh/stable-diffusion',
  input: {
    prompt: 'A serene Japanese garden with cherry blossoms',
    negative_prompt: 'blurry, low quality',
    num_images: 1,
    size: '1024x1024'
  }
});

console.log('Generated:', result.output.images[0].uri);
```

---

## With Agent

Create an agent with `stable-diffusion` as a tool:

```
You: Generate a logo for a coffee shop called "Morning Brew"

Agent: I'll create a logo for Morning Brew.
       [Calling stable-diffusion...]
       
       Here's your logo! I generated a warm, inviting design
       with a coffee cup and sunrise motif.
       
       Would you like variations or a different style?
```

---

## Popular Image Apps

| App | Best For |
|-----|----------|
| `stable-diffusion` | General purpose, flexible |
| `flux` | High quality, detailed |
| `dalle` | Creative, artistic |
| `sdxl-turbo` | Fast generation |
| `controlnet` | Guided generation (pose, edge) |

---

## Model Configuration

Use **setup parameters** to load specific checkpoints or change precision:

```python
client.run({
    "app": "infsh/stable-diffusion",
    "setup": {
        "model_id": "stabilityai/stable-diffusion-xl-base-1.0",
        "precision": "fp16"
    },
    "input": { ... }
})
```

---

## Tips

**Be specific:**
```
❌ "a dog"
✓ "Golden retriever puppy playing in autumn leaves, warm sunlight, shallow depth of field"
```

**Use negative prompts:**
```
negative_prompt: "blurry, low quality, distorted, ugly, duplicate"
```

**Try different models:**
- SDXL for quality
- Turbo for speed
- Flux for details

---

## Next

→ [Audio Transcription](/docs/examples/audio-transcription)
