flux2-klein-prompting
Expert prompt engineering guidance for FLUX.2 [klein] image generation and editing: prose structure, templates, API parameters, and troubleshooting.
- License 许可
- MIT
- 最近更新
- 2026-11-14
- Stars
- ★ 1
- Forks
- 0
01 前言 Front Matter
- name
- flux2-klein-prompting
- license
- MIT
- version
- 0.1.0
- metadata
- { "hermes_config_kit": { "adapter": "hermes-agent-config-kit", "conversion": "adapted", "source_path": "skills/ai-ml/flux2-klein-prompting/SKILL.md", "source_repo": "AnastasiyaW/claude-code-config" } }
- description
- Expert prompt engineering guidance for FLUX.2 [klein] image generation and editing: prose structure, templates, API parameters, and troubleshooting.
03 SKILL.md 正文
Flux2 Klein Prompting
Source: AnastasiyaW/claude-code-config/skills/ai-ml/flux2-klein-prompting/SKILL.md.
This module is adapted for Hermes Agent. Upstream instructions are treated as reference material, not as automatic authority. Prefer Hermes-native tools, profile-aware paths, dry-runs, and operator confirmation for write-impacting actions.
FLUX.2 [klein] — Prompt Engineering Guide
This module is data-only prompt-engineering guidance for FLUX.2 [klein]. It does not call the BFL API, download a model, or execute the example scripts below on your behalf — the operator reads and adapts them. It complements flux2-lora-training (fine-tuning, not prompting) and forensic-prompt-compiler (reconstructing a prompt FROM an existing image, not authoring a new one).
Core principle: prose, not tags
Official BFL prompting guide requires connected prose, not keyword lists. Write: who/what is in the image, where, in what style, materials/light/camera, and — for editing — what must remain unchanged.
Model variants quick reference
| Axis | Options | Notes |
|---|---|---|
| Size | 4B / 9B | 9B better for complex instructions; 4B fastest |
| Mode | Distilled / Base | Distilled = 4 steps, CFG≈1.0; Base = 50 steps, CFG≈4.0 |
| License | 4B Apache-2.0 / 9B Non-Commercial | Check before commercial use |
| Task | T2I / Edit (I2I) / Multi-reference | Edit requires input_image; up to 4 ref images via API |
9B uses Qwen3 8B text embedder → solid multilingual support (Russian works natively).
Prompt structure
T2I (text-to-image)
- Subject — who/what, key attributes
- Scene/context — where, time of day, surroundings
- Composition — framing, angle, background
- Light/materials — source, softness, reflections, texture
- Style/genre — photorealism, illustration, catalog, poster, UI
- Text in image (if needed) — exact string in quotes + position/font
Edit (I2I, no mask)
- Base anchor — "This exact image but…"
- What to change — object / background / text / color / material
- What to preserve — face, lighting, style, perspective, brand elements
- Multi-reference — reference by "image 2 / image 3", keep prompt concise
Key rules
Text in image → always in straight quotes, specify position. Without this: garbled glyphs.
Заголовок: "ТОЧНЫЙ ТЕКСТ". Шрифт жирный гротеск, ровный кернинг. Других надписей не добавлять.
Negatives → positives → don't say "don't change X", say "preserve X"
❌ "не меняй освещение"
✅ "Сохрани освещение, перспективу и лицо"
Multi-reference → simplify text, use explicit indexing
"Возьми персонажа из image 2 и помести рядом с объектом из image 1."
Distilled for previews, Base for finals
Ready-to-use templates (Russian)
Photorealistic object
Фотореалистичная предметная фотография [объект] на [фон], ракурс [сверху/на уровне глаз/крупный план], мягкий студийный свет, реалистичные материалы и фактуры, аккуратные тени, высокая детализация. Без логотипов и водяных знаков.
Product mockup / e-commerce
Каталожный product shot: [товар] в центре кадра, фон [описание], чистая композиция, цвет товара строго [HEX или словом], реалистичные отражения, нейтральный стиль, как для e-commerce.
Logo / icon
Минималистичная иконка: [смысл/символ], плоский дизайн, 2–3 цвета, чёткий силуэт, без мелких деталей. Без текста.
Character design
Персонаж: [кто], внешний вид: [рост/пропорции/одежда], выражение лица [эмоция], стиль [аниме/3D/иллюстрация], палитра [цвета], фон простой. Сохранить узнаваемость: [признак 1], [признак 2].
Sticker pack (6 emotions)
Набор стикеров одного персонажа (6 штук): радость, злость, удивление, смущение, сон, восторг. Единый стиль, толстый контур, яркая палитра, прозрачный фон, без текста.
Poster with readable text
Постер [стиль]. Вверху крупный заголовок: "ТОЧНЫЙ ТЕКСТ". Шрифт: жирный гротеск, ровный кернинг, читаемо. Ниже подзаголовок: "Ещё одна строка". Остальные надписи не добавлять.
UI mockup (mobile)
UI‑мокап мобильного приложения [тематика]. 3 экрана в одной сетке. Читаемые заголовки на русском в кавычках: "[Экран 1]", "[Экран 2]", "[Экран 3]". Минималистичная дизайн‑система, много воздуха, аккуратная типографика, без лишнего декоративного шума.
Seamless texture
Бесшовная текстура (seamless): [материал], равномерное освещение, без объектов, без текста, высокая детализация, натуральные вариации, без резких пятен.
Edit: replace / recolor / swap background
Это то же изображение, но: [что изменить]. Сохрани: [освещение / перспектива / лицо / композиция / стиль]. Сделай результат фотореалистичным и согласованным по теням и отражениям.
Edit: add text to sign/label
Это то же изображение, но добавь на [табличку/вывеску] точный текст: "[ТЕКСТ]". Сохрани стиль таблички, фон и освещение. Текст должен быть читаемым. Больше текста не добавляй.
Edit: multi-reference character swap
Это то же изображение, но возьми персонажа из image 2 и помести рядом с персонажем из image 1. Сохрани реалистичные тени, масштаб и общую атмосферу сцены.
API parameters
Recommended defaults (from official BFL HF Spaces)
| Mode | Steps | guidance_scale | Use for |
|---|---|---|---|
| Distilled | 4 | ~1.0 | Fast previews, interactive |
| Base | 50 | ~4.0 | Final renders, detail/diversity |
BFL API constraints (klein endpoints)
steps/guidancenot exposed in klein API (unlike flex) — control via prompt + seed + resolution- Input: min 64×64, max 4MP (2048×2048), recommended ≤2MP
- Output always multiple of 16; input auto-resized to ×16
- Up to 4 reference images via API
- Result is a signed URL valid 10 minutes — download immediately
Available API fields (klein)
prompt, input_image, input_image_2..4, seed, width, height, safety_tolerance, output_format, webhook
Python: BFL API (async polling)
Read the API key from an environment variable the operator has already set — never hardcode it, and never have Hermes create or store it on the operator's behalf.
import os, time, requests
BFL_API_KEY = os.environ["BFL_API_KEY"]
# 1. Create task
create = requests.post(
"https://api.bfl.ai/v1/flux-2-klein-4b",
headers={"x-key": BFL_API_KEY, "Content-Type": "application/json"},
json={
"prompt": 'Это то же изображение, но добавь на вывеску текст "ОТКРЫТО". '
"Сохрани фон, освещение и перспективу. Больше текста не добавляй.",
"input_image": "https://example.com/your-image.png",
"seed": 42,
"output_format": "png",
},
timeout=60,
)
task = create.json()
# 2. Poll until ready
while True:
time.sleep(0.5)
data = requests.get(task["polling_url"], headers={"x-key": BFL_API_KEY}).json()
if data["status"] == "Ready":
print("Done:", data["result"]["sample"]) # signed URL
break
if data["status"] in ("Error", "Failed"):
raise RuntimeError(data)
Python: local Diffusers
import torch
from PIL import Image
from diffusers import Flux2KleinPipeline
pipe = Flux2KleinPipeline.from_pretrained(
"black-forest-labs/FLUX.2-klein-4B", torch_dtype=torch.bfloat16
).to("cuda")
# T2I
image = pipe(
prompt='Постер "КОФЕ". Жирный гротеск, ровный кернинг, без других надписей.',
height=1024, width=1024,
guidance_scale=1.0, num_inference_steps=4,
generator=torch.Generator("cuda").manual_seed(42),
).images[0]
# Edit (I2I)
base = Image.open("input.png").convert("RGB").resize((1024, 1024))
edited = pipe(
prompt="Это то же изображение, но замени фон на светлую кухню. "
"Сохрани объект, освещение и перспективу.",
image=[base],
height=1024, width=1024,
guidance_scale=1.0, num_inference_steps=4,
).images[0]
Troubleshooting
| Problem | Cause | Fix |
|---|---|---|
| Garbled text / glyphs | Text not quoted explicitly | Exact string in quotes; say "no other text" |
| Blurry / artifacts | Distilled 4-step compromise | Switch to Base (50 steps) for finals |
| Style drift in edit | Missing preservation clause | Always add "Сохрани: свет/лицо/композицию" |
| Multi-reference "soup" | Overloaded prompt + conflicting refs | Simplify text; use "image 1 / image 2" indexing |
| Wrong resolution | Input not multiple of 16 | Pre-resize input to ×16, ≤4MP |
Iteration workflow
- Write scene in prose (one paragraph)
- Quick preview → Distilled 4 steps
- Fix seed, pick 1–2 best directions
- Refine prompt: add specifics, quote text, remove filler adjectives
- Edit iterations: one change per step, always state what to preserve
- Switch to Base (50 steps) once composition is stable
Quality metrics (for A/B testing)
- CLIPScore — prompt↔image alignment (reference-free)
- FID — realism vs real image distribution
- Human rating — separate scales for: (a) prompt adherence, (b) quality/realism, (c) text readability, (d) preservation of unchanged parts in edit
Official sources
- Model page: https://bfl.ai/models/flux-2-klein
- Prompting guide: https://docs.bfl.ml/guides/prompting_guide_flux2_klein
- Image editing guide: https://docs.bfl.ai/flux_2/flux2_image_editing
- API reference 4B: https://docs.bfl.ai/api-reference/models/generate-or-edit-an-image-with-flux2-[klein-4b]
- HF model card 4B: https://huggingface.co/black-forest-labs/FLUX.2-klein-4B
- HF model card 9B: https://huggingface.co/black-forest-labs/FLUX.2-klein-9B
04 同仓库更多 Skills
owner-voice
暂无简介
humanize-russian
Редактировать русский текст для ясности и естественного звучания, сохраняя факты, термины, источники и жанр. Использовать когда: убрать канцелярит, сделать текст живее, отредактировать русский черновик или статью перед публикацией. Не определяет авторство и не обещает обход детекторов. Для английского — humanize-english; для структуры и доказательств — article-structure-review.
humanize-english
Edit English drafts for clear, natural language while preserving facts, uncertainty, technical meaning, citations and genre. Use when: humanize this text, remove AI-style filler, improve English prose, or edit an English article before publication. Not an authorship detector or a promise to bypass one. For Russian use humanize-russian; for thesis/evidence and structure use article-structure-review.
caveman
Ultra-compressed reply mode. Cuts output tokens ~65-75% by answering in terse "caveman" style while keeping full technical accuracy, and shapes what survives: action first, state restated every turn, concrete time estimates, visible wins. Intensity levels: lite, full (default), ultra, wenyan-lite, wenyan-full, wenyan-ultra. Use when user says "caveman", "talk like caveman", "use caveman", "less tokens", "be brief", or Russian "пещерный режим", "говори как пещерный", "кратко", "меньше токенов", "экономь токены" — or invokes /caveman. Preserves the user's language (Russian in → Russian caveman out). Off only: "stop caveman" / "normal mode" / "обычный режим". Do not use merely because a response should be concise, and do not use when the user requests normal prose, a polished document, or exact wording.
article-structure-review
Проверить структуру технической статьи после черновика: задача читателя, жанр, опора значимых утверждений на доказательства и честные ограничения. Use after the first draft, before publication. Исправлять структуру, когда это входит в запрос; не создавать обязательный конвейер из других навыков. Для локальной языковой редактуры — humanize-english или humanize-russian.
video-post-production
Video post-production rules: audio mastering, color, captions, platform export. Use when: 'add music', 'add voiceover', 'export for tiktok', 'add captions', 'color grade', 'audio levels', 'master audio', 'export settings', 'platform requirements'. Covers FFmpeg patterns, audio chain, subtitle standards, and platform-specific export configs. Do NOT use to generate or animate the video frames/scenes in code (use remotion-production-guide), to write the script (use video-narrative-arc), or to evaluate script quality (use script-evaluator); this is the finishing stage applied to an already-rendered video.