Skip to content

Commit 4e97ef5

Browse files
authored
Merge pull request #518 from esokullu/claude/image-video-models
Separate image and video models for every media provider
2 parents fef499e + 541f86e commit 4e97ef5

20 files changed

Lines changed: 1546 additions & 238 deletions

‎docs/providers-and-models.md‎

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -266,17 +266,27 @@ An older Cloud deployment falls through to the active LLM and existing checks.
266266
Configure **Providers → Generative** for the
267267
`generate_image` agent tool. Select one provider and save its settings:
268268

269-
| Provider | Required settings | Generation |
270-
| --- | --- | --- |
271-
| fal.ai | API key, model ID (for example `fal-ai/flux/schnell`) | fal.ai queue API; existing saved fal.ai settings remain compatible |
272-
| OpenRouter | API key, image model ID | [Dedicated Image API](https://openrouter.ai/docs/guides/overview/multimodal/image-generation); inline images appear in chat with a save link |
273-
| Comfy Router | Comfy API key, `provider/model` ID (for example `bfl/flux-2-pro`) | [Queued requests](https://docs.comfy.org/development/comfy-router/queued-delivery); hosted or inline media |
274-
| ComfyUI (localhost) | Local server URL (default `http://127.0.0.1:8188`), workflow JSON in API format | Local `/prompt`, `/history/{prompt_id}`, and `/view` endpoints; no API key |
269+
| Provider | Settings | Default image / video model | Generation |
270+
| --- | --- | --- | --- |
271+
| fal.ai | API key; image and video model IDs (optional) | `fal-ai/flux/schnell` / `xai/grok-imagine-video/v1.5/lite/text-to-video` | fal.ai queue API; existing saved fal.ai settings remain compatible |
272+
| OpenRouter | API key; image and video model IDs (optional) | `google/gemini-2.5-flash-image` / `x-ai/grok-imagine-video-1.5-lite` | [Dedicated Image API](https://openrouter.ai/docs/guides/overview/multimodal/image-generation) and video API; inline media appears in chat with a save link |
273+
| Comfy Router | Comfy API key; image and video `provider/model` IDs (optional), each with optional input JSON | `bfl/flux-2-pro` / `xai/grok-imagine-video-1.5-lite` | [Queued requests](https://docs.comfy.org/development/comfy-router/queued-delivery); hosted or inline media |
274+
| ComfyUI (localhost) | Local server URL (default `http://127.0.0.1:8188`); image workflow JSON in API format, optional video workflow | — | Local `/prompt`, `/history/{prompt_id}`, and `/view` endpoints; no API key |
275+
276+
Each provider has an image model and a video model. `generate_image` uses the
277+
video model when the agent asks for a video (`media: "video"`, or any video
278+
option such as `duration` or `scenes`) and the image model otherwise. A model
279+
field left empty uses the default shown in it. For ComfyUI, a video request
280+
without a video workflow uses the image workflow. Settings saved when there was
281+
one model keep it as the image model; with OpenRouter, a saved model that the
282+
video catalog lists makes the videos instead, and calls that do not say what
283+
they want get a video from it, as before.
275284

276285
For Comfy Router models with native inputs other than `prompt`, paste their input
277-
JSON in **Model input JSON** and place `{{prompt}}` in the text field(s). Other
278-
values, such as duration or resolution, are preserved. Without a placeholder,
279-
WebBrain supplies the tool prompt as `prompt`. Refer to the model's
286+
JSON in **Image model input JSON** or **Video model input JSON** and place
287+
`{{prompt}}` in the text field(s). Other values, such as duration or resolution,
288+
are preserved. Without a placeholder, WebBrain supplies the tool prompt as
289+
`prompt`. Refer to the model's
280290
[input schema](https://docs.comfy.org/development/comfy-router/schemas).
281291

282292
For local ComfyUI, start the server, export a working workflow **in API format**,
@@ -286,8 +296,9 @@ other media output node. Only loopback URLs (`localhost`, `127.0.0.1`, or `[::1]
286296
are accepted. A connection test checks the server, not workflow execution.
287297

288298
**Test Connection** makes only free, read-only authentication/model/server probes;
289-
it does not generate media. OpenRouter also checks that the selected model appears
290-
in the image generation catalog. **Save / Clear** apply to the selected media
299+
it does not generate media. OpenRouter also checks both models in its image and
300+
video catalogs, Comfy Router reads both models' metadata, and the result names
301+
the image and video models requests will use. **Save / Clear** apply to the selected media
291302
configuration. Unsaved drafts survive provider switches while settings remain open;
292303
only the saved selection is used by the agent.
293304

@@ -310,7 +321,8 @@ checked against the model's catalog entry (`supported_durations`,
310321
submitted. A longer video is passed as `scenes`: WebBrain makes one clip per
311322
scene at a length the model offers (a scene longer than its longest clip is
312323
refused, so the agent splits it into scenes with their own prompts), generates
313-
up to three clips at a time with one retry each, and joins them into one MP4
324+
up to three clips at a time with one retry each (none when the provider refuses
325+
the request, such as for lack of credit), and joins them into one MP4
314326
without re-encoding (`src/*/src/agent/video-join.js`, which parses
315327
the clips with the vendored mp4box.js). A clip's sound often ends a little
316328
before its picture or starts after it; with AAC-LC sound (the usual MP4 audio,

‎src/chrome/src/agent/fal-media.js‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
// fal.ai generative media (assistive model).
22
//
3-
// Configured in Providers -> Generative (fal.ai provider).
4-
// and stored in extension storage as `imageGenModel = { apiKey, model }`.
3+
// Configured in Providers -> Generative (fal.ai provider) and stored in
4+
// extension storage as `imageGenModel = { apiKey, model, videoModel }`; the
5+
// caller passes the model a request uses as `config.model`.
56
// fal.ai uses a queue API: submit a prompt, poll status_url, then fetch
67
// response_url. Auth uses `Authorization: Key <FAL_KEY>`.
78

@@ -156,7 +157,8 @@ export async function runFalGeneration({
156157
if (!submitRes.ok) {
157158
let body = '';
158159
try { body = (await submitRes.text()).slice(0, 300); } catch { /* ignore */ }
159-
throw new Error(`fal.ai submit failed (HTTP ${submitRes.status}): ${body || submitRes.statusText}`);
160+
const credit = submitRes.status === 402 ? 'the account is out of credit; add credit and try again: ' : '';
161+
throw Object.assign(new Error(`fal.ai submit failed (HTTP ${submitRes.status}): ${credit}${body || submitRes.statusText}`), { status: submitRes.status });
160162
}
161163

162164
let queued;

0 commit comments

Comments
 (0)