Image File Input Agent

Analyze a local image file with Ministral 14B and search the web for related news.

Code

from pathlib import Path

from agno.agent import Agent
from agno.media import Image
from agno.models.mistral.mistral import MistralChat
from agno.tools.websearch import WebSearchTools

agent = Agent(
    model=MistralChat(id="ministral-14b-2512"),
    tools=[WebSearchTools()],
    markdown=True,
)

image_path = Path(__file__).parent.joinpath("sample.jpeg")

agent.print_response(
    "Tell me about this image and give me the latest news about it from the web.",
    images=[
        Image(filepath=image_path),
    ],
    stream=True,
)

Usage

Set up your virtual environment

uv venv --python 3.12
source .venv/bin/activate

Set your API key

export MISTRAL_API_KEY=xxx

Install dependencies

uv pip install -U mistralai ddgs agno

Add the image

Save the code above as image_file_input_agent.py. Place a JPEG named sample.jpeg in the same directory.

Run Agent

Save the code above as image_file_input_agent.py, then run:

python image_file_input_agent.py