Skip to content

The agent that grows with you

fix(krea): review follow-ups: edits keep their framing, schema follows the stored model, Krea 3 wording

Mariano Nicolinid1400be1f333
diff --git a/agent/image_gen_provider.py b/agent/image_gen_provider.py
index 447a2cf3799..4c96e06a244 100644
--- a/agent/image_gen_provider.py
+++ b/agent/image_gen_provider.py
@@ -35,7 +35,8 @@ class ImageGenProvider(CatalogProviderBase):
def capabilities(self) -> dict[str, Any]:
"""``modalities`` (``"text"`` and/or ``"image"``) and ``max_reference_images``; optionally
``supports_upscale`` (bool), ``creative_controls`` (names from the tool's creative-control
- vocabulary: ``creativity``, ``intensity``, ``complexity``, ``movement``) and
+ vocabulary: ``creativity``, ``intensity``, ``complexity``, ``movement``, ``thinking``,
+ ``resolution``) and
``source_image_role`` (``"style"`` when image inputs set the look and are not edited). Surfaced in the
dynamic tool schema so the model knows when ``image_url`` / ``upscale`` / each control is
honored, and only declared controls are passed to :meth:`generate`; the text-only default
diff --git a/hermes_cli/config_defaults.py b/hermes_cli/config_defaults.py
index 0cd83db0046..cb5d755900a 100644
--- a/hermes_cli/config_defaults.py
+++ b/hermes_cli/config_defaults.py
@@ -2932,7 +2932,7 @@ OPTIONAL_ENV_VARS = {
tools=["browser_navigate", "browser_click"], advanced=True),
"FAL_KEY": _tool("FAL API key for image and video generation", "FAL API key", "https://fal.ai/",
tools=["image_generate", "video_generate"]),
- "KREA_API_KEY": _tool("Krea API key for Krea 2 image generation (Medium + Large)",
+ "KREA_API_KEY": _tool("Krea API key for Krea 3 and Krea 2 image generation",
"Krea API key", "https://www.krea.ai/settings/api-tokens", tools=["image_generate"]),
"VOICE_TOOLS_OPENAI_KEY": _tool(
"OpenAI API key for voice transcription (Whisper) and OpenAI TTS",
diff --git a/hermes_cli/tools_config.py b/hermes_cli/tools_config.py
index e003741b081..4c99538f004 100644
--- a/hermes_cli/tools_config.py
+++ b/hermes_cli/tools_config.py
@@ -302,7 +302,7 @@ TOOL_CATEGORIES = {
# picks the gateway at run time (tools/image_generation_managed.py).
"providers": [
_row("Nous Subscription", "subscription",
- "Managed image generation (FAL, Krea 2, Nous Portal models) billed to your subscription", **_NOUS,
+ "Managed image generation (FAL, Krea 3 and Krea 2, Nous Portal models) billed to your subscription", **_NOUS,
managed_nous_feature="image_gen", override_env_vars=["FAL_KEY"], imagegen_backend="nous"),
],
},
diff --git a/plugins/image_gen/krea/__init__.py b/plugins/image_gen/krea/__init__.py
index 53ab9fb1b78..d5cada54831 100644
--- a/plugins/image_gen/krea/__init__.py
+++ b/plugins/image_gen/krea/__init__.py
@@ -75,7 +75,8 @@ _MAX_LOCAL_REFERENCE_BYTES = 3 * 1024 * 1024
_VALID_CREATIVITY = {"raw", "low", "medium", "high"}
# Krea 2 generative sliders: integers from -100 to 100, 0 means the slider is off.
_K2_SLIDERS = ("intensity", "complexity", "movement")
-# Krea 3 controls; the managed gateway caps its reference images at 4.
+# Krea 3 controls. Krea itself takes 8 reference images; the managed gateway caps them at 4 and
+# one cap keeps direct and managed behaviour the same.
_KREA3_CONTROLS = ("thinking", "resolution")
_KREA3_RESOLUTIONS = ("1K", "2K")
_MAX_KREA3_REFERENCE_IMAGES = 4
@@ -496,21 +497,24 @@ def _krea3_payload(
prompt: str, krea_ar: str, image_url: Optional[str], reference_image_urls: Optional[list[str]],
kwargs: dict[str, Any], fail: ErrorFn,
) -> tuple[dict[str, Any], Optional[dict[str, Any]]]:
- """Krea 3 request body: the pictures given are edited; resolution and thinking mode are priced."""
- image_urls, err = _inline_local_images(
- collect_source_images(image_url, reference_image_urls, _MAX_KREA3_REFERENCE_IMAGES), fail)
+ """Krea 3 request body: the pictures given are edited; resolution and thinking mode are priced.
+ An edit sends no aspect ratio, so Krea keeps the picture's own framing."""
+ sources = list(dict.fromkeys(collect_source_images(image_url, reference_image_urls)))
+ image_urls, err = _inline_local_images(sources[:_MAX_KREA3_REFERENCE_IMAGES], fail)
if err is not None:
return {}, err
- resolution = kwargs.get("resolution")
+ resolution = str(kwargs.get("resolution") or "").upper()
payload: dict[str, Any] = {
- "prompt": prompt, "aspect_ratio": krea_ar,
+ "prompt": prompt,
"resolution": resolution if resolution in _KREA3_RESOLUTIONS else DEFAULT_RESOLUTION,
"thinking_mode": "high" if kwargs.get("thinking") == "high" else "fast",
}
- if isinstance(kwargs.get("seed"), int):
- payload["seed"] = kwargs["seed"]
if image_urls:
payload["image_urls"] = image_urls
+ else:
+ payload["aspect_ratio"] = krea_ar
+ if isinstance(kwargs.get("seed"), int):
+ payload["seed"] = kwargs["seed"]
return payload, None
@@ -531,7 +535,10 @@ class KreaImageGenProvider(StaticImageGenProvider):
return bool(get_secret("KREA_API_KEY")) or _managed_krea_gateway_ready()
def capabilities(self) -> dict[str, Any]:
- _, meta = _resolve_model()
+ # The managed dispatcher names the stored ``image_gen.model`` explicitly; resolve the same way
+ # so the schema describes the model that will run, whatever KREA_IMAGE_MODEL says.
+ stored = _load_krea_config().get("model") if _resolve_managed_krea_gateway() is not None else None
+ _, meta = _resolve_model(stored if isinstance(stored, str) else None)
if meta.get("edit"):
return {
"modalities": ["text", "image"], "max_reference_images": _MAX_KREA3_REFERENCE_IMAGES,
@@ -627,12 +634,10 @@ class KreaImageGenProvider(StaticImageGenProvider):
"Krea image URL %s could not be cached (%s); falling back to bare URL.", result_image_url, exc,
)
image_ref = result_image_url
- extra: dict[str, Any] = {
- "krea_aspect_ratio": krea_ar, "resolution": payload["resolution"], "job_id": job_id, "upscaled": upscaled,
- }
- for key in ("creativity", "thinking_mode"):
+ extra: dict[str, Any] = {"resolution": payload["resolution"], "job_id": job_id, "upscaled": upscaled}
+ for key, name in (("aspect_ratio", "krea_aspect_ratio"), ("creativity", "creativity"), ("thinking_mode", "thinking_mode")):
if key in payload:
- extra[key] = payload[key]
+ extra[name] = payload[key]
if upscaled:
extra["upscale_factor"] = _ENHANCE_SCALE_FACTOR
if isinstance(job.get("completed_at"), str):
diff --git a/plugins/image_gen/krea/plugin.yaml b/plugins/image_gen/krea/plugin.yaml
index 9f42979ab75..65e2a9a9dba 100644
--- a/plugins/image_gen/krea/plugin.yaml
+++ b/plugins/image_gen/krea/plugin.yaml
@@ -1,6 +1,6 @@
name: krea
version: 1.1.0
-description: "Krea image generation backend (Krea 2 Large + Medium + Medium Turbo foundation models). Direct KREA_API_KEY or managed Nous Subscription gateway."
+description: "Krea image generation backend: Krea 3 (generates and edits) and Krea 2 Medium, Large and Medium Turbo. Direct KREA_API_KEY or managed Nous Subscription gateway."
author: NousResearch
kind: backend
requires_env:
diff --git a/tests/plugins/image_gen/test_krea_provider.py b/tests/plugins/image_gen/test_krea_provider.py
index ca33a7e4a2f..13a46f3acd3 100644
--- a/tests/plugins/image_gen/test_krea_provider.py
+++ b/tests/plugins/image_gen/test_krea_provider.py
@@ -773,18 +773,18 @@ class TestKrea3:
assert (result["resolution"], result["thinking_mode"]) == ("1K", "fast")
assert "creativity" not in result
- def test_controls_and_references_reach_the_payload_and_krea_2_fields_do_not(self, monkeypatch, tmp_path):
+ def test_an_edit_keeps_the_pictures_framing_and_sends_only_krea_3_fields(self, monkeypatch, tmp_path):
image = tmp_path / "mug.png"
image.write_bytes(b"\x89PNG\r\n\x1a\nmug")
_, call = self._generate(
- monkeypatch, image_url=str(image), reference_image_urls=["https://example.com/red.png"],
- thinking="high", resolution="2K", creativity="raw", intensity=50)
+ monkeypatch, image_url=str(image), reference_image_urls=[str(image), "https://example.com/red.png"],
+ thinking="high", resolution="2k", creativity="raw", intensity=50)
payload = call.kwargs["json"]
- assert payload["image_urls"] == [
+ assert payload["image_urls"] == [ # the repeated source is sent, and billed, once
"data:image/png;base64," + base64.b64encode(image.read_bytes()).decode("ascii"),
"https://example.com/red.png"]
assert (payload["resolution"], payload["thinking_mode"]) == ("2K", "high")
- assert not {"creativity", "intensity", "image_style_references"} & set(payload)
+ assert not {"aspect_ratio", "creativity", "intensity", "image_style_references"} & set(payload)
def test_caps_reference_images_at_the_gateway_limit(self, monkeypatch):
_, call = self._generate(monkeypatch, reference_image_urls=[f"https://example.com/{i}.png" for i in range(6)])
@@ -801,3 +801,15 @@ class TestKrea3:
krea2 = KreaImageGenProvider().capabilities()
assert krea2["source_image_role"] == "style"
assert "creativity" in krea2["creative_controls"]
+
+ def test_managed_capabilities_describe_the_stored_model_the_dispatcher_sends(self, monkeypatch):
+ """On the managed path generate() receives ``image_gen.model`` explicitly, so the schema must
+ describe that model even when KREA_IMAGE_MODEL names another one."""
+ import plugins.image_gen.krea as krea_mod
+
+ monkeypatch.setenv("KREA_IMAGE_MODEL", "krea-2-large")
+ monkeypatch.setattr(krea_mod, "_load_krea_config", lambda: {"provider": "nous", "model": "krea-3"})
+ monkeypatch.setattr(krea_mod, "_resolve_managed_krea_gateway", lambda: _managed_cfg())
+ assert krea_mod.KreaImageGenProvider().capabilities()["creative_controls"] == ["thinking", "resolution"]
+ monkeypatch.setattr(krea_mod, "_resolve_managed_krea_gateway", lambda: None)
+ assert "creativity" in krea_mod.KreaImageGenProvider().capabilities()["creative_controls"]
diff --git a/tests/tools/test_image_generate_schema.py b/tests/tools/test_image_generate_schema.py
index e5ac0fb1d1e..5a37018b2c6 100644
--- a/tests/tools/test_image_generate_schema.py
+++ b/tests/tools/test_image_generate_schema.py
@@ -9,6 +9,7 @@ default fails closed to text-only/no-upscale.
import os
import sys
import unittest
+from pathlib import Path
from unittest.mock import patch
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", ".."))
@@ -149,11 +150,12 @@ class TestDynamicParamGating(unittest.TestCase):
reference cap, and the schema offers Krea 3's controls and none of Krea 2's."""
from plugins.image_gen.krea import KreaImageGenProvider
- with patch.dict(os.environ, {"KREA_IMAGE_MODEL": "krea-3"}), \
- patch.object(ig, "_read_configured_image_provider", return_value="nous"), \
- patch.object(ig, "_read_configured_image_model", return_value="krea-3"):
- props = _build_dynamic_image_schema()["parameters"]["properties"]
- cap = KreaImageGenProvider().capabilities()["max_reference_images"]
+ # The tool and the plugin read the same stored selection, no env override needed.
+ home = Path(os.environ["HERMES_HOME"])
+ home.mkdir(parents=True, exist_ok=True)
+ (home / "config.yaml").write_text("image_gen:\n provider: nous\n model: krea-3\n")
+ props = _build_dynamic_image_schema()["parameters"]["properties"]
+ cap = KreaImageGenProvider().capabilities()["max_reference_images"]
self.assertIs(props["image_url"], ig._IMAGE_URL_PARAM)
self.assertEqual(props["reference_image_urls"]["maxItems"], cap)
self.assertLessEqual({"thinking", "resolution"}, set(props))
diff --git a/tools/image_generation_managed.py b/tools/image_generation_managed.py
index 337d49249f2..cbbb332d92f 100644
--- a/tools/image_generation_managed.py
+++ b/tools/image_generation_managed.py
@@ -32,6 +32,7 @@ _PORTAL_DUPLICATE_OF = {
"krea/krea-2-medium": "krea-2-medium",
"krea/krea-2-medium-turbo": "krea-2-medium-turbo",
"krea/krea-2-large": "krea-2-large",
+ "krea/krea-3": "krea-3",
}
_FAL_KREA_PREFIX = "fal-ai/krea/"
diff --git a/website/docs/developer-guide/image-gen-provider-plugin.md b/website/docs/developer-guide/image-gen-provider-plugin.md
index 3f8a603c279..6b1edf902f7 100644
--- a/website/docs/developer-guide/image-gen-provider-plugin.md
+++ b/website/docs/developer-guide/image-gen-provider-plugin.md
@@ -120,7 +120,7 @@ class MyBackendImageGenProvider(ImageGenProvider):
# text-only: {"modalities": ["text"], "max_reference_images": 0}.
# Optional keys: "supports_upscale" (bool) adds an `upscale` param, and
# "creative_controls" lists the controls you honor from `creativity`,
- # `intensity`, `complexity`, `movement`. Only declared controls appear
+ # `intensity`, `complexity`, `movement`, `thinking`, `resolution`. Only declared controls appear
# in the schema and reach generate() as kwargs. "source_image_role": "style"
# tells the model that image inputs set the look and are not edited.
return {"modalities": ["text", "image"], "max_reference_images": 4}
diff --git a/website/docs/reference/environment-variables.md b/website/docs/reference/environment-variables.md
index ca0e4c0aca4..f34cec7f944 100644
--- a/website/docs/reference/environment-variables.md
+++ b/website/docs/reference/environment-variables.md
@@ -174,7 +174,7 @@ For native Anthropic auth, Hermes prefers Claude Code's own credential files whe
| `AGENT_BROWSER_ARGS` | Extra Chromium launch flags (comma- or newline-separated). Hermes auto-injects `--no-sandbox,--disable-dev-shm-usage` when running as root or on AppArmor-restricted unprivileged user namespaces (Ubuntu 23.10+, DGX Spark, many container images); set this manually only to override or add other flags. |
| `AGENT_BROWSER_ENGINE` | Local browser engine: `auto` (default — Chromium-family via CDP), `lightpanda` (Browser Use mode spawns `lightpanda serve`; the built-in tools pass `--engine lightpanda` to agent-browser), or `chrome`. Same as `browser.engine` in config.yaml. |
| `FAL_KEY` | Image generation ([fal.ai](https://fal.ai/)) |
-| `KREA_API_KEY` | Krea API key for Krea 2 image generation ([krea.ai](https://krea.ai/)) |
+| `KREA_API_KEY` | Krea API key for Krea 3 and Krea 2 image generation ([krea.ai](https://krea.ai/)) |
| `GROQ_API_KEY` | Groq Whisper STT API key ([groq.com](https://groq.com/)) |
| `ELEVENLABS_API_KEY` | ElevenLabs premium TTS voices ([elevenlabs.io](https://elevenlabs.io/)) |
| `PORCUPINE_ACCESS_KEY` | Picovoice Porcupine wake-word engine ([console.picovoice.ai](https://console.picovoice.ai/)) — required when Porcupine is selected; openWakeWord and sherpa need no key |
diff --git a/website/docs/user-guide/features/image-generation.md b/website/docs/user-guide/features/image-generation.md
index 573fe4373e7..8badf33d14f 100644
--- a/website/docs/user-guide/features/image-generation.md
+++ b/website/docs/user-guide/features/image-generation.md
@@ -32,7 +32,7 @@ Prices are FAL's pricing at time of writing; check [fal.ai](https://fal.ai/) for
:::tip Nous Subscribers
If you have a paid [Nous Portal](https://portal.nousresearch.com) subscription, you can use image generation through the **[Tool Gateway](tool-gateway.md)** without a FAL API key. Your model selection persists across both paths. New installs can run `hermes setup --portal` to log in and turn on every gateway tool at once; existing installs can pick **Nous Subscription** as the image-gen backend via `hermes tools`.
-The **Nous Subscription** row is the only managed row. Its model picker spans every gateway the subscription runs — the FAL catalog above, native **Krea 3** (`krea-3`) and **Krea 2** (`krea-2-medium`, `krea-2-large`, `krea-2-medium-turbo`) and any Nous Portal image models — each model listed once, and the model you pick decides which gateway serves the request. Free tool-pool accounts see the FAL models only; Krea and Portal models are paid-subscription. With Krea 3 selected, `image_url` is a picture to edit (up to 4 reference images in total) and `image_generate` offers `thinking` (`fast` or `high`) and `resolution` (`1K` or `2K`). With a Krea 2 model selected, it offers Krea's `creativity` setting and its `intensity`, `complexity` and `movement` sliders (-100 to 100) instead.
+The **Nous Subscription** row is the only managed row. Its model picker spans every gateway the subscription runs — the FAL catalog above, native **Krea 3** (`krea-3`) and **Krea 2** (`krea-2-medium`, `krea-2-large`, `krea-2-medium-turbo`) and any Nous Portal image models — each model listed once, and the model you pick decides which gateway serves the request. Free tool-pool accounts see the FAL models only; Krea and Portal models are paid-subscription. With Krea 3 selected, `image_url` is a picture to edit (up to 4 reference images in total; an edit keeps the picture's own framing) and `image_generate` offers `thinking` (`fast` or `high`) and `resolution` (`1K` or `2K`). With a Krea 2 model selected, it offers Krea's `creativity` setting and its `intensity`, `complexity` and `movement` sliders (-100 to 100) instead.
If the managed gateway returns `HTTP 4xx` for a specific model, that model isn't yet proxied on the portal side — the agent will tell you so, with remediation steps (switch to FAL.ai in `hermes tools` with your own `FAL_KEY` for direct access, or pick a different model).
:::