Render Anything Engine: tell your AI what to make. Videos, motion graphics, 3D and games as React and TypeScript, rendered on your own GPU. Rust + Bevy, macOS, Linux and Windows.
TypeScript 3dagent-skillsai-agentsai-videobevyclaude-codegame-enginegpulinuxmacosmotion-designmotion-graphicsreactrusttypescriptvideo-editingvideo-renderingwgpuwindows
raea gen: a picture step on a host with no made.app key goes to fal, then OpenRouter
shinyobjectz74ce0ff7371e
diff --git a/io/gen/src/cli.rs b/io/gen/src/cli.rsindex 7bb0812d..158150f2 100644--- a/io/gen/src/cli.rs+++ b/io/gen/src/cli.rs@@ -58,6 +58,7 @@ fn runner<'a>(args: &[String], base: &Path, local: Option<&'a dyn Local>) -> Runr.policy.exact = args.iter().any(|a| a == "--exact");r.policy.comfy_on_replicate = args.iter().any(|a| a == "--comfy-on-replicate") || crate::setting("RAEA_COMFY_ON") .as_deref() == Some("replicate");r.policy.tripo = !args.iter().any(|a| a == "--no-tripo") && crate::tripo::available();+ r.policy.keys = crate::route::Keys::here();if let Some(l) = local.filter(|_| !args.iter().any(|a| a == "--no-local")) {r.policy.local = l.names();r.local = Some(l);diff --git a/io/gen/src/lib.rs b/io/gen/src/lib.rsindex e50e7501..5c37e59a 100644--- a/io/gen/src/lib.rs+++ b/io/gen/src/lib.rs@@ -13,6 +13,8 @@ pub mod run;mod tests;#[cfg(test)]mod tests_tripo;+#[cfg(test)]+mod tests_keys;pub use raea_io_gen_comfy as comfy;pub use raea_io_gen_core::{direct, fal, fish, flow, http, made, modal, openrouter, replicate, setting, tripo, tsflow, types};diff --git a/io/gen/src/route.rs b/io/gen/src/route.rsindex 30c0656b..ea1e5992 100644--- a/io/gen/src/route.rs+++ b/io/gen/src/route.rs@@ -3,7 +3,8 @@//! Tripo 3D: through the tripo CLI on the user's own key when this host has both (tripo.rs), else the same Tripo model on fal. text.generate goes to//! OpenRouter (RAEA_GEN_TEXT_MODEL, else Kimi). Otherwise: a `comfy` step on the ComfyUI server; a step with ComfyUI weights on the server too when//! the flow asks for the exact weights (`--exact`), else made's model for that op, which is noted as standing in for-//! them; a local model when the host has one for the op (sao for effects); made for the rest.+//! them; a local model when the host has one for the op (sao for effects); made for the rest. A picture step on a host+//! with no made.app key goes to fal (nano-banana-2), else OpenRouter (Gemini's image model), when it has their key.use serde_json::{Map, Value as J, json};@@ -86,6 +87,52 @@ pub struct Policy {pub comfy_on_replicate: bool,/// the tripo CLI and a key are on this host (tripo::available), so mesh steps run on Tripo itselfpub tripo: bool,+ /// which picture services this host has a key for+ pub keys: Keys,+}++/// The picture services this host has a key for (MADE_API_KEY, FAL_KEY, OPENROUTER_API_KEY). With no made.app key, a+/// picture step that names no model goes to fal, then OpenRouter (the app's Images and video offers all three; Shane+/// 11-14: "maybe add openrouter and fal as other image options"). Default: made's, as before.+#[derive(Clone, Debug)]+pub struct Keys {+ pub made: bool,+ pub fal: bool,+ pub openrouter: bool,+}++impl Default for Keys {+ fn default() -> Self {+ Keys { made: true, fal: false, openrouter: false }+ }+}++impl Keys {+ /// what this host has, from the environment and ~/.raea/env+ pub fn here() -> Keys {+ let has = |k: &str| crate::setting(k).is_some_and(|v| !v.trim().is_empty());+ Keys { made: has("MADE_API_KEY"), fal: has("FAL_KEY"), openrouter: has("OPENROUTER_API_KEY") }+ }+}++/// fal's and OpenRouter's picture models, for a picture step on a host with no made.app key+pub const FAL_IMAGE: &str = "fal-ai/nano-banana-2";+pub const FAL_IMAGE_EDIT: &str = "fal-ai/nano-banana-2/edit";+pub const OPENROUTER_IMAGE: &str = "google/gemini-3.1-flash-image";++/// A picture step where made.app has no key here: fal's nano-banana-2 (made's own default for pictures), else+/// OpenRouter's Gemini image model; None for any other step, or with neither key.+fn without_made(s: &Step, k: &Keys) -> Option<(Backend, Option<String>)> {+ let edit = match s.op.as_str() {+ "image.generate" => false,+ "image.edit" => true,+ _ => return None,+ };+ if k.fal {+ let e = if edit { FAL_IMAGE_EDIT } else { FAL_IMAGE };+ return Some((Backend::Fal(e.into()), Some(format!("no made.app key here: fal's {e}"))));+ }+ k.openrouter.then(|| (Backend::OpenRouter(OPENROUTER_IMAGE.into()), Some(format!("no made.app or fal key here: OpenRouter's {OPENROUTER_IMAGE}"))))}/// Where a step runs, and a note when it stands in for something it was asked for.@@ -132,6 +179,11 @@ pub fn route(s: &Step, p: &Policy) -> Result<(Backend, Option<String>), String>if let Some(l) = local_default(s).filter(|l| p.local.iter().any(|x| x.as_str() == *l)) {return Ok((Backend::Local(l.into()), None));}+ if !p.keys.made {+ if let Some(r) = without_made(s, &p.keys) {+ return Ok(r);+ }+ }let m = made_default(s).ok_or(format!("nothing runs {} yet: give it a model (made:<id>, fal:<endpoint>, comfy)", s.op))?;Ok((Backend::Made(m.into()), None))}diff --git a/io/gen/src/tests_keys.rs b/io/gen/src/tests_keys.rsnew file mode 100644index 00000000..d3a01864--- /dev/null+++ b/io/gen/src/tests_keys.rs@@ -0,0 +1,40 @@+//! raea gen's picture steps on a host without a made.app key: fal, then OpenRouter (route.rs Keys).+use serde_json::json;++use crate::flow::Step;+use crate::route::{Backend, Keys, Policy, route};++fn on(made: bool, fal: bool, openrouter: bool) -> Policy {+ Policy { keys: Keys { made, fal, openrouter }, ..Default::default() }+}++#[test]+fn pictures_go_to_fal_then_openrouter_without_a_made_key() {+ let make = Step::new("image.generate", json!({"prompt": "a lighthouse in fog"}));+ let edit = Step::new("image.edit", json!({"prompt": "make it night", "image": "https://example.com/a.png"}));+ // made's key here: made, as before (and with no keys known at all, the default)+ assert!(matches!(route(&make, &on(true, true, true)).unwrap().0, Backend::Made(_)));+ assert!(matches!(route(&make, &Policy::default()).unwrap().0, Backend::Made(_)));+ // no made key: fal's nano-banana-2, its edit endpoint for an edit, said in the note+ let (b, note) = route(&make, &on(false, true, true)).unwrap();+ assert_eq!(b, Backend::Fal("fal-ai/nano-banana-2".into()));+ assert!(note.unwrap().contains("no made.app key"));+ assert_eq!(route(&edit, &on(false, true, false)).unwrap().0, Backend::Fal("fal-ai/nano-banana-2/edit".into()));+ // no made or fal key: OpenRouter's Gemini image model, for both+ assert_eq!(route(&make, &on(false, false, true)).unwrap().0, Backend::OpenRouter("google/gemini-3.1-flash-image".into()));+ assert_eq!(route(&edit, &on(false, false, true)).unwrap().0, Backend::OpenRouter("google/gemini-3.1-flash-image".into()));+ // none of the three: made, which then asks for its key when it runs+ assert!(matches!(route(&make, &on(false, false, false)).unwrap().0, Backend::Made(_)));+}++#[test]+fn only_picture_steps_and_unnamed_models_fall_back() {+ let none = on(false, true, true);+ // a video step stays on made (fal and OpenRouter take its key only when the step names them)+ let video = Step::new("video.generate", json!({"prompt": "waves"}));+ assert!(matches!(route(&video, &none).unwrap().0, Backend::Made(_)));+ // a step that names its model goes there whatever keys are here+ let mut named = Step::new("image.generate", json!({"prompt": "x"}));+ named.model = Some("made:nano_banana_2".into());+ assert_eq!(route(&named, &none).unwrap().0, Backend::Made("nano_banana_2".into()));+}