Image Input
Pass images to workflows and chain vision analysis with web search.
Demonstrates passing image media into workflow runs and chaining analysis with follow-up research.
"""
Image Input
===========
Demonstrates passing image media into workflow runs and chaining analysis with follow-up research.
"""
from agno.agent import Agent
from agno.db.sqlite import SqliteDb
from agno.media import Image
from agno.models.openai import OpenAIChat
from agno.tools.websearch import WebSearchTools
from agno.workflow.step import Step
from agno.workflow.workflow import Workflow
# ---------------------------------------------------------------------------
# Create Agents
# ---------------------------------------------------------------------------
image_analyzer = Agent(
name="Image Analyzer",
model=OpenAIChat(id="gpt-5.6-luna"),
instructions="Analyze the provided image and extract key details, objects, and context.",
)
news_researcher = Agent(
name="News Researcher",
model=OpenAIChat(id="gpt-5.6-luna"),
tools=[WebSearchTools()],
instructions="Search for latest news and information related to the analyzed image content.",
)
# ---------------------------------------------------------------------------
# Define Steps
# ---------------------------------------------------------------------------
analysis_step = Step(
name="Image Analysis Step",
agent=image_analyzer,
)
research_step = Step(
name="News Research Step",
agent=news_researcher,
)
# ---------------------------------------------------------------------------
# Create Workflow
# ---------------------------------------------------------------------------
media_workflow = Workflow(
name="Image Analysis and Research Workflow",
description="Analyze an image and research related news",
steps=[analysis_step, research_step],
db=SqliteDb(session_table="workflow_session", db_file="tmp/workflow.db"),
)
# ---------------------------------------------------------------------------
# Run Workflow
# ---------------------------------------------------------------------------
if __name__ == "__main__":
media_workflow.print_response(
input="Please analyze this image and find related news",
images=[
Image(
url="https://upload.wikimedia.org/wikipedia/commons/0/0c/GoldenGateBridge-001.jpg"
)
],
markdown=True,
)Run the Example
Set up your virtual environment
uv venv --python 3.12
source .venv/bin/activateInstall dependencies
uv pip install -U agno ddgs fastapi openai sqlalchemyExport your OpenAI API key
export OPENAI_API_KEY="your_openai_api_key_here"Run the example
Save the code above as image_input.py, then run:
python image_input.pyFull source: cookbook/04_workflows/06_advanced_concepts/structured_io/image_input.py