# Run Stable Diffusion and Flux as an API

Host SDXL, Flux, or any diffusion checkpoint behind a cloud API.

## Fast inference for image generation

Everything you need to serve generative models at scale.

**Serve any checkpoint or LoRA**  
SDXL, Flux, SD 1.5, or your own fine-tuned weights — load from Hugging Face or a volume, and stack LoRAs at runtime.

**GPU Checkpoint Restore**  
Speed up cold boots by creating snapshots of the GPU state. No need to reload model weights back into vRAM when your container spins up.

**Scale with bursts**  
Image traffic is spiky. Endpoints scale out on demand and back to zero.

**Hosted image outputs**  
Save results with Output and return public URLs straight from your endpoint — no need to push results to S3.

**Weights cached in volumes**  
Keep multi-gigabyte checkpoints on a persistent volume shared across containers. Storage is included, free of charge.

**GPUs from 4090s to B300s**  
Run lighter checkpoints on 4090s and reserve B300s for big models — one line to switch.

> “Switching to Beam has been really helpful. It has addressed all the pain points we had with Replicate, enabling us to provide a better, more reliable service to our customers.”  
> Simon Brami Founder, Gepetto

5xfaster cold boots than their previous provider  
$1,000ssaved monthly  
>99.9%production uptime

## How it works

### Ship an image API in three steps

01

### Load the pipeline once

Load your checkpoint when the container boots — requests reuse the warm pipeline instead of reloading weights.

02

### Deploy the endpoint

beam deploy gives you an authenticated HTTPS URL backed by autoscaling GPUs.

03

### Generate over HTTP

POST a prompt, get back a hosted image URL. Beam handles queuing, scaling, and auth.

```bash
$ beam deploy app.py:generate
=> Deployed 🎉
=> https://sdxl-abc123.app.beam.cloud

$ curl -X POST https://sdxl-abc123.app.beam.cloud \
    -H 'Authorization: Bearer YOUR_TOKEN' \
    -d '{"prompt": "isometric voxel city at dusk"}'

{"url": "https://app.beam.cloud/output/id/8b0d..."}
```

## Frequently asked questions

### Which models can I host?+

Anything diffusers can load: SDXL, SD 1.5, Flux, plus your own fine-tuned checkpoints and LoRAs.

### How does this compare to per-image APIs like Replicate or fal?+

Per-image platforms charge a markup on every generation, and your model options are limited to their catalog. On Beam you deploy your own checkpoints and LoRAs, pay per-second for the GPU while it's generating, and your code stays private.

### How are images returned?+

Save them with Output and return a hosted public URL, or base64-encode them into the JSON response.

### What about cold starts with large checkpoints?+

Keep weights on a volume so containers skip the download, and use on_start so each container loads the pipeline exactly once.

### Can I keep an endpoint warm?+

Yes — set keep_warm_seconds to hold containers hot for latency-sensitive apps, and let everything else scale to zero.

### Do I need to manage queues for burst traffic?+

No. Autoscaling is managed by Beam — set your scaling policy and containers are added as request volume grows.
