Genai Processors
GenAI Processors is a lightweight Python library that enables efficient, parallel content processing.
Last verified:
What is Genai Processors?
GenAI Processors is an open-source Python library from Google DeepMind designed to build modular, asynchronous, and composable AI pipelines for generative AI applications. The library provides a consistent Processor interface that serves as an abstraction layer for everything from input handling and pre-processing to model calls and output processing. At its core, it treats all input and output as asynchronous streams of ProcessorParts, enabling seamless chaining and composition of operations from low-level data manipulation to high-level model calls.
The library is specifically designed for building sophisticated AI applications with Large Language Models, especially those handling multimodal input (text, images, audio, JSON) and requiring real-time responsiveness. Key features include modular design that breaks complex workflows into reusable Processor units, full asyncio integration for concurrent execution without manual threading, built-in processors for Gemini API integration (GenaiModel for turn-based interaction and LiveProcessor for real-time streaming), unified multimodal handling through ProcessorPart wrappers, and stream manipulation utilities for splitting, concatenating, and merging asynchronous streams.
GenAI Processors is ideal for Python developers building Gemini applications, particularly those creating live agents capable of processing audio and video streams in real-time, research agents, trip planners, or any application where responsiveness and low time-to-first-token are critical. The library includes ready-to-use examples like a Real-Time Live Example with audio-in/audio-out and Google search tools, a Research Agent with multiple sub-processors, and a Live Commentary Example with event detection and conversation management.
Genai Processors pricing
Pricing model: Freemium
GenAI Processors is completely free and open-source, released under the Apache License Version 2.0. There are no paid plans or tiers. The library itself is free to install via pip and use. However, when using Gemini API via the GenaiModel or LiveProcessor processors, standard Gemini API pricing applies based on Google's usage-based pricing for the Gemini API.
Genai Processors pros
- Modular design breaks complex workflows into reusable Processor units
- Fully asynchronous and concurrent using Python asyncio
- No manual threading or complex concurrency management required
- Built-in GenaiModel processor for turn-based Gemini API calls
- Built-in LiveProcessor for real-time streaming with Gemini Live API
- Unified multimodal handling for text, images, audio, and JSON
- ProcessorPart wrapper provides consistent interface across data types
- Stream utilities for splitting, concatenating, and merging streams
- Easy extensibility through inheritance or function decorators
- Reduces boilerplate code for Gemini API integration
- Minimizes Time To First Token (TTFT) automatically
- Maintains output stream ordering relative to input stream
- Clear data flow using + operator for chaining processors
- Includes practical examples: live agent, research agent, commentary agent
- Open-source under Apache License 2.0
- Colab notebooks available for learning core concepts
- Community contributions encouraged in contrib/ directory
Genai Processors cons
- Currently supports only Python (no other languages)
- Requires Python 3.10 or higher
- Still in early stages of development
- Learning curve for asyncio and stream-based programming
- Primarily focused on Gemini API (not model-agnostic)
- Limited built-in processors in core/ directory
- No GUI or visual pipeline builder
- Documentation relies heavily on Colab notebooks rather than traditional docs
Frequently asked questions about Genai Processors
What is GenAI Processors?
GenAI Processors is a lightweight, open-source Python library from Google DeepMind that enables efficient, parallel content processing for generative AI applications. It provides a consistent Processor interface as an abstraction layer for building modular, asynchronous, and composable AI pipelines, treating all input and output as asynchronous streams of ProcessorParts.
How do I install GenAI Processors?
Install GenAI Processors using pip with the command: pip install genai-processors. The library requires Python 3.10 or higher.
What programming languages does GenAI Processors support?
GenAI Processors currently only supports Python. While the Google GenAI SDK is available in multiple languages, this library is Python-specific.
What is a Processor in GenAI Processors?
A Processor is a fundamental building block that encapsulates a specific unit of work. It takes a stream of ProcessorParts as input, performs an operation, and outputs a stream of results. Any class inheriting from processor.Processor and implementing the async call function is a Processor.
What is a ProcessorPart?
ProcessorPart is a wrapper around genai.types.Part enriched with metadata like MIME type, role, and custom attributes. It provides a consistent interface for handling diverse data types including text, images, audio, and custom JSON within the pipeline.
How does concurrency work in GenAI Processors?
The library optimizes concurrent execution under the hood using Python's asyncio. Any part can be generated concurrently when all its ancestors in the graph are computed. The flow maintains output stream ordering relative to input and minimizes Time To First Token by preferring earlier computations.
What built-in processors are available?
The core/ directory contains fundamental processors including GenaiModel for turn-based API calls, LiveProcessor for real-time streaming with Gemini Live API, audio_io for audio input/output, video for camera streams, speech_to_text, text_to_speech, and utilities for stream manipulation. More specialized processors are available in contrib/ through community contributions.
Can I create custom processors?
Yes, you can easily create custom processors by inheriting from base classes or using simple function decorators. This allows you to integrate your own data processing logic, external APIs, or specialized operations seamlessly into your pipelines.
What are some example applications built with GenAI Processors?
Examples include a Real-Time Live Example (audio-in/audio-out Live agent with Google search tools), a Research Agent with three sub-processors demonstrating chaining and ProcessorPart creation, and a Live Commentary Example with two agents for event detection and conversation management. Trip planners and turn-based agents also use the concurrency features.
How do I get started learning GenAI Processors?
Start with the provided Colab notebooks in recommended order: Content API Colab (explains ProcessorPart and ProcessorContent basics), Processor Intro Colab (core concepts), Create Your Own Processor (walkthrough for creating processors), and Work with the Live API (real-time processor examples). You can also explore the examples/ directory for practical demonstrations.