genai-processors: a modular framework for building asynchronous and composable multimodal AI pipelines

genai-processors: a modular framework for building asynchronous and composable multimodal AI pipelines

What it solves

GenAI Processors is a lightweight Python library designed to reduce fragmentation in LLM APIs and simplify the creation of complex, asynchronous AI pipelines. It provides a unified way to handle multimodal content and stream data between different models, agents, and tools without requiring complex plumbing code.

How it works

The library is built around the Processor abstraction, which encapsulates a unit of work. It uses a "dual-interface" pattern to separate the logic for creating processors (the Producer) and using them (the Consumer).

Key mechanisms include:

  • Unified Content Model: Uses ProcessorPart to wrap multimodal data (text, images, audio, JSON) with metadata like MIME types and roles.
  • Asyncio Integration: Built on Python's asyncio for native asynchronous streaming and concurrent task orchestration.
  • Composable Pipelines: Processors can be chained together using the + operator or parallelized using the // operator to build sophisticated data flows.
  • Integrated API Support: Includes built-in processors like GenaiModel for standard API calls and LiveProcessor for real-time streaming interactions with the Gemini API.

Who it’s for

Developers building generative AI applications, specifically those needing to orchestrate multimodal streaming data and create modular, reusable agentic behaviors.

Highlights

  • Modular Design: Tasks are broken into reusable Processor and PartProcessor units.
  • Native Streaming: Asynchronous streaming is built-in by default.
  • Multimodal Support: Handles text, images, audio, and custom JSON seamlessly.
  • Flexible Orchestration: Supports both turn-based interactions and live, real-time streaming agents.

Sources