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

Principle:0xsline OpenChatCut AI Provider Dispatch

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

Overview

Integration principle that dispatches media generation requests to external AI providers (Fal.ai, OpenAI, Gemini, ElevenLabs, etc.) through provider-specific clients, with API key management via a server-side keystore and outbound proxy support.

Description

AI Provider Dispatch is the routing layer between the generation job lifecycle and external AI services. Each media type (image, video, voice, music, sound) has its own provider ecosystem:

  • Images: Fal.ai catalog, OpenAI DALL-E, Gemini Imagen.
  • Video: Fal.ai (Seedance, MiniMax, Kling) with first-frame, last-frame, and reference image upload support.
  • Voice (TTS): ElevenLabs, MiniMax, Doubao, Inworld, Fish Audio, Speechify, and AI-SDK providers.
  • Music: Atlas, Mureka, MiniMax, Sonilo.
  • Sound effects: ElevenLabs, Sonilo.

Key design decisions:

  • Server-side keys: API keys are stored in a server-side keystore (`server/keystore.ts`) and never reach the browser.
  • Outbound proxy: All provider requests route through `proxyDispatcher` for network control.
  • Reference upload: Fal.ai video generation supports uploading first/last frames, reference images, video, and audio via Fal's storage API.
  • Validation before upload: Requests are validated before uploading reference media to avoid wasting bandwidth on invalid requests.
  • Queue integration: Provider tasks are registered with the generation job lifecycle for progress tracking and resume support.

Usage

Use this principle when:

  • Routing generation requests to the correct AI provider based on media type and model.
  • Managing API keys securely on the server side.
  • Uploading reference media (images, video, audio) to provider storage before generation.

Theoretical Basis

The provider dispatch pattern:

# Abstract algorithm (NOT real implementation)
def dispatch_image(request):
    key = keystore.get('FAL_KEY')
    client = create_fal_client(key)
    validate_request(request)
    result = client.generate(request.model, request.prompt, request.aspect)
    return result.images  # [{ url: "..." }]

def dispatch_video(request, register):
    key = keystore.get('FAL_KEY')
    client = create_fal_client(key)
    upload_refs = [client.upload(p) for p in request.ref_images]
    result = client.queue(request.endpoint, {**request, refs: upload_refs}, register)
    return result.video.url

Related Pages

Implemented By

Page Connections

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