Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:0xsline OpenChatCut GenerateFalCatalogImage

From Leeroopedia
Knowledge Sources
Domains AI_Generation, Image_Generation, Provider_Integration
Last Updated 2026-10-22 14:00 GMT

Overview

Concrete function that generates AI images via the Fal.ai catalog API, with reference image upload support, request validation before upload, and result URL extraction.

Description

The generateFalCatalogImage function:

  • Validates the request via `buildFalCatalogImageRequest` before any uploads.
  • Uploads reference images (if provided) to Fal storage with per-type size limits (images 30 MB, audio 15 MB, video 50 MB).
  • Submits the generation request through `runFalQueue` which manages the Fal.ai queue and polling.
  • Extracts image URLs from the result — handles both `images[]` and single `image` responses.
  • Validates that at least one image URL was returned.

The companion generateFalVideo function handles video generation with support for:

  • First frame, last frame, reference images, reference video, and reference audio uploads.
  • Resume via `existingTaskId` (re-attaches to a running Fal queue task without re-uploading).
  • Catalog video request building and validation.

This is a Wrapper Doc — it wraps `@fal-ai/client` with OpenChatCut-specific credential management, proxy routing, and validation.

Usage

  • Image plugin: Called by the image generation plugin for Fal.ai image requests.
  • Video plugin: `generateFalVideo` is called by the video generation plugin.

Code Reference

Source Location

  • Repository: OpenChatCut
  • File:*** server/plugins/fal-client.ts

Signature

export async function generateFalCatalogImage(body: FalCatalogInput): Promise<ProviderImage[]>;

export async function generateFalVideo(
  body: ValidVideoRequest,
  register: RegisterGenerationProviderTask,
  existingTaskId?: string,
): Promise<string>;

Import

import { generateFalCatalogImage, generateFalVideo } from '../server/plugins/fal-client.ts';

I/O Contract

Inputs

Name Type Required Description
body.model string Yes Fal.ai model ID
body.prompt string Yes Generation prompt
body.aspect string No Aspect ratio
body.size string No Output size
body.quality string No Quality level
body.imageUrls string[] No Reference image paths to upload
body (video) ValidVideoRequest Yes Video request with model, prompt, duration, frame refs
register (video) RegisterGenerationProviderTask Yes Callback to register Fal queue task ID
existingTaskId (video) string No Existing Fal task ID for resume

Outputs

Name Type Description
generateFalCatalogImage() returns ProviderImage[] Array of { url: string } image results
generateFalVideo() returns string Video result URL

Usage Examples

Generate an Image

import { generateFalCatalogImage } from '../server/plugins/fal-client.ts';

const images = await generateFalCatalogImage({
  model: 'fal-ai/flux/schnell',
  prompt: 'sunset over mountains, cinematic',
  aspect: '16:9',
  size: '1920x1080',
});

for (const img of images) {
  console.log(`Image URL: ${img.url}`);
}

Generate a Video

import { generateFalVideo } from '../server/plugins/fal-client.ts';

const videoUrl = await generateFalVideo(
  {
    model: 'fal',
    falModel: 'fal-ai/seedance/v1',
    prompt: 'camera pans across a mountain range',
    duration: 5,
    firstFramePath: '/media/uploads/frame0.png',
  },
  (taskId) => console.log(`Fal task: ${taskId}`),
);
console.log(`Video: ${videoUrl}`);

Related Pages

Implements Principle

Requires Environment

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment