GenAI Processors is a lightweight Python library that enables efficient, parallel content processing.
See the codeBuild Modular, Asynchronous, and Composable AI Pipelines for Generative AI.
GenAI Processors is a lightweight Python library that enables efficient, parallel content processing. It addresses the fragmentation of LLM APIs through three core pillars:
asyncio.At the ecosystem's core lies the Processor, which encapsulates a unit of work.
Through a "dual-interface" pattern, it handles the complexity of asynchronous,
multimodal data streaming while exposing a simple API to developers:
from typing import AsyncIterable
from genai_processors import content_api
from genai_processors import processor
class EchoProcessor(processor.Processor):
# The PRODUCER interface (for the processor author):
# Takes a robust ProcessorStream as input, and yields part types.
async def call(
self, content: content_api.ProcessorStream
) -> AsyncIterable[content_api.ProcessorPartTypes]:
# Process content as it streams in!
async for part in content:
yield part
Applying a Processor is just as straightforward. The CONSUMER interface
accepts wide, forgiving input types and returns a powerful stream that can be
awaited entirely or streamed chunk-by-chunk:
# The CONSUMER interface (for the caller):
# Provide input effortlessly. Strings are automatically cast into Parts.
input_content = ["Hello ", content_api.ProcessorPart("World")]
# 1. Gather all outputs easily into one object:
result: content_api.ProcessorContent = await simple_text_processor(input_content).gather()
# 2. Or for text-only agents, get the text directly:
print(await simple_text_processor(input_content).text())
# 3. And for streaming use cases, iterate over the parts as they arrive:
async for part in simple_text_processor(input_content):
print(part.text, end="")
The concept of Processor provides a common abstraction for Gemini model calls
and increasingly complex behaviors built around them, accommodating both
turn-based interactions and live streaming.
Processor and
PartProcessor units, which are easily chained (+) or parallelized (//)
to create sophisticated data flows and agentic behaviors.GenaiModel for turn-based API calls and LiveProcessor for real-time
streaming interactions.ProcessorPart: A wrapper around genai.types.Part enriched with
metadata like MIME type, role, and custom attributes.asyncio
framework to orchestrate concurrent tasks (including network I/O and
communication with compute-heavy subthreads).ProcessorParts.The GenAI Processors library requires Python 3.10+.
Install it with:
pip install genai-processors
Generative models are often unaware of recent API and SDK updates and may suggest outdated or legacy code.
We recommend using our Code Generation instructions when generating code that uses GenAI Processors to guide your model towards using the more recent SDK features. Copy and paste the instructions into your development environment to provide the model with the necessary context.
We recommend to start with the documentation microsite which covers the core concepts, development guides, and architecture.
You can also check the following colabs to get familiar with GenAI processors (we recommend following them in order):
ProcessorPart, ProcessorContent, and how to
create them.Processor or a
PartProcessor.LiveProcessor class.Explore the examples/ directory for practical demonstrations:
ProcessorParts, etc.The core/ directory contains a set of basic processors that you can leverage in your own applications. It includes the generic building blocks needed for most real-time applications and will evolve over time to include more core components.
Community contributions expanding the set of built-in processors are located under contrib/ - see the section below on how to add code to the GenAI Processor library.
Contributions are welcome! Please see CONTRIBUTING.md for guidelines on how to contribute to this project.
This project is licensed under the Apache License, Version 2.0. See the LICENSE file for details.
If you make use of Gemini via the Genai Processors framework, please ensure you review the Terms of Service.
(top 24 of 28)
1,108 followers · starred Jun 2025
13,355 followers · starred Jun 2025
127 followers · starred Jul 2025
1,668 followers · starred May 2025
GenAI Processors is a lightweight Python library that enables efficient, parallel content processing.
See the codeBuild Modular, Asynchronous, and Composable AI Pipelines for Generative AI.
GenAI Processors is a lightweight Python library that enables efficient, parallel content processing. It addresses the fragmentation of LLM APIs through three core pillars:
asyncio.At the ecosystem's core lies the Processor, which encapsulates a unit of work.
Through a "dual-interface" pattern, it handles the complexity of asynchronous,
multimodal data streaming while exposing a simple API to developers:
from typing import AsyncIterable
from genai_processors import content_api
from genai_processors import processor
class EchoProcessor(processor.Processor):
# The PRODUCER interface (for the processor author):
# Takes a robust ProcessorStream as input, and yields part types.
async def call(
self, content: content_api.ProcessorStream
) -> AsyncIterable[content_api.ProcessorPartTypes]:
# Process content as it streams in!
async for part in content:
yield part
Applying a Processor is just as straightforward. The CONSUMER interface
accepts wide, forgiving input types and returns a powerful stream that can be
awaited entirely or streamed chunk-by-chunk:
# The CONSUMER interface (for the caller):
# Provide input effortlessly. Strings are automatically cast into Parts.
input_content = ["Hello ", content_api.ProcessorPart("World")]
# 1. Gather all outputs easily into one object:
result: content_api.ProcessorContent = await simple_text_processor(input_content).gather()
# 2. Or for text-only agents, get the text directly:
print(await simple_text_processor(input_content).text())
# 3. And for streaming use cases, iterate over the parts as they arrive:
async for part in simple_text_processor(input_content):
print(part.text, end="")
The concept of Processor provides a common abstraction for Gemini model calls
and increasingly complex behaviors built around them, accommodating both
turn-based interactions and live streaming.
Processor and
PartProcessor units, which are easily chained (+) or parallelized (//)
to create sophisticated data flows and agentic behaviors.GenaiModel for turn-based API calls and LiveProcessor for real-time
streaming interactions.ProcessorPart: A wrapper around genai.types.Part enriched with
metadata like MIME type, role, and custom attributes.asyncio
framework to orchestrate concurrent tasks (including network I/O and
communication with compute-heavy subthreads).ProcessorParts.The GenAI Processors library requires Python 3.10+.
Install it with:
pip install genai-processors
Generative models are often unaware of recent API and SDK updates and may suggest outdated or legacy code.
We recommend using our Code Generation instructions when generating code that uses GenAI Processors to guide your model towards using the more recent SDK features. Copy and paste the instructions into your development environment to provide the model with the necessary context.
We recommend to start with the documentation microsite which covers the core concepts, development guides, and architecture.
You can also check the following colabs to get familiar with GenAI processors (we recommend following them in order):
ProcessorPart, ProcessorContent, and how to
create them.Processor or a
PartProcessor.LiveProcessor class.Explore the examples/ directory for practical demonstrations:
ProcessorParts, etc.The core/ directory contains a set of basic processors that you can leverage in your own applications. It includes the generic building blocks needed for most real-time applications and will evolve over time to include more core components.
Community contributions expanding the set of built-in processors are located under contrib/ - see the section below on how to add code to the GenAI Processor library.
Contributions are welcome! Please see CONTRIBUTING.md for guidelines on how to contribute to this project.
This project is licensed under the Apache License, Version 2.0. See the LICENSE file for details.
If you make use of Gemini via the Genai Processors framework, please ensure you review the Terms of Service.
(top 24 of 28)
1,108 followers · starred Jun 2025
13,355 followers · starred Jun 2025
127 followers · starred Jul 2025
1,668 followers · starred May 2025