Image generation · FLUX.2 [klein] 4B · diffusers · GB10 · 24 GB VRAM
published by @dh7 on
m64 m64_17808a488affFLUX.2 [klein] 4B text-to-image on GB10 (diffusers). Black Forest Labs' distilled 4B rectified-flow model (Qwen3-4B text encoder, Apache-2.0) at 1024x1024, 4 steps, guidance 1, bf16. A small, fast FLUX.2.
Lineage
- parent
- none declared
- derived from
- no published capsule shares half its files
- children
- none
Files
6 files- human/
- index.html4.0 KB
- AGENT.md3.1 KB
- capsule.toml1.3 KB
- Dockerfile1.1 KB
- flux2_server.py4.6 KB
- start.sh342 B
AGENT.md
FLUX.2 [klein] 4B text-to-image
This service turns a text prompt into a 1024x1024 PNG. It runs Black Forest Labs' FLUX.2 [klein] 4B, a distilled 4B rectified-flow model with a Qwen3-4B text encoder (Apache-2.0), through diffusers on one GPU. Generation settings are fixed: 1024x1024, 4 steps, guidance 1, as the distilled model wants. You send a prompt and, optionally, a seed.
Base URL: {{BASE_URL}}
Routes
POST /v1/images/generations
OpenAI-style image generation. Returns one image as base64 PNG.
curl -s {{BASE_URL}}/v1/images/generations {{AUTH}} \
-H "Content-Type: application/json" \
-d '{"prompt": "a lighthouse at sunset", "seed": 7}' \
| python3 -c 'import sys,json,base64; d=json.load(sys.stdin); open("out.png","wb").write(base64.b64decode(d["data"][0]["b64_json"])); print(d["seed"], d["params_used"])'
Request fields:
prompt(string, required): what to draw. English works best.seed(integer >= 0, optional): the random seed. The same prompt and seed give the same image. Leave it out for a random one; the response's top-levelseedfield says which seed was used, so you can reproduce a result you liked.
Also accepted, for stock OpenAI clients: model (any string), n (must be 1),
response_format (must be "b64_json"), size (must be "1024x1024"), user.
Any other field, or a different value for a fixed one (for example
"num_inference_steps": 4), is rejected with 400.
Response:
{"created": 1761530000, "model": "flux2-klein-4b", "seed": 7, "elapsed_seconds": 4.2,
"data": [{"b64_json": "<PNG, base64>"}],
"params_used": {"size": "1024x1024", "num_inference_steps": 4, "guidance_scale": 1.0}}
The OpenAI Python SDK works too:
from openai import OpenAI
client = OpenAI(base_url="{{BASE_URL}}/v1", api_key="unused")
r = client.images.generate(model="flux2-klein-4b", prompt="a lighthouse at sunset",
response_format="b64_json", extra_body={"seed": 7})
GET /v1/config
The fixed settings and the request fields this service accepts.
curl -s {{BASE_URL}}/v1/config {{AUTH}}
GET /status
Where the service is in its start-up: phase is one of building, downloading,
starting, loading, warming, ready, error, with eta_seconds and, while starting, a wait_hint.
curl -s {{BASE_URL}}/status {{AUTH}}
Timings and concurrency
- First start: builds a container image and downloads about 16 GB of weights. After that, loading and a warm-up take about 2 minutes (budgeted at 300 s).
- Each image takes about 4 s on a DGX Spark (GB10).
- Requests run one at a time; extra requests wait in line. Send them one by one, or a few in parallel at most, and allow at least 60 s per request in your client timeout.
Errors
503withRetry-Afterwhile the service is still starting: wait that many seconds and retry.GET /statusshows progress.400: a field was rejected; the body'serrorsays which and why.422: a request field has the wrong type (for examplepromptmissing or empty,seednegative).5xxotherwise: retry once, then checkGET /status.
capsule.toml
schema = "m64/capsule@1"description = "FLUX.2 [klein] 4B text-to-image on GB10 (diffusers). Black Forest Labs' distilled 4B rectified-flow model (Qwen3-4B text encoder, Apache-2.0) at 1024x1024, 4 steps, guidance 1, bf16. A small, fast FLUX.2."kinds = ["image.generate"]authors = ["dh7"]license = "apache-2.0"[hardware]platform = "linux-aarch64"gpu = "NVIDIA GB10"gpu_count = 1# ~8 GB transformer + ~8 GB Qwen3-4B text encoder (bf16) + VAE and activations.vram_gb = 24driver = ">=580"disk_gb = 18[runtime]sandbox = "container"# No image: the Dockerfile builds on nvcr.io/nvidia/pytorch:25.09-py3 pinned by digest.gpu = trueshm_gb = 8internal_port = 9019health = "/health"expected_load_seconds = 300model_name = "flux2-klein-4b"user = "65534:65534"[[artifacts]]type = "hf"repo = "black-forest-labs/FLUX.2-klein-4B"revision = "e7b7dc27f91deacad38e78976d1f2b499d76a294"# The diffusers folders only: not the 7.7 GB single-file (ComfyUI) checkpoint, not the# card's images.include = [ ".gitattributes", "LICENSE.md", "README.md", "model_index.json", "scheduler/*", "text_encoder/*", "tokenizer/*", "transformer/*", "vae/*",]mount = "/weights/flux2"[params]size = "1024x1024"num_inference_steps = 4guidance_scale = 1.0[routes]extra = ["/v1/config"]