Llama Image Input File
Attach a local image file to a Llama 4 Maverick agent and stream its description.
"""
Meta Image Input File
=====================
Cookbook example for `meta/llama/image_input_file.py`.
"""
from pathlib import Path
from agno.agent import Agent
from agno.media import Image
from agno.models.meta import Llama
from agno.utils.media import download_image
# ---------------------------------------------------------------------------
# Create Agent
# ---------------------------------------------------------------------------
agent = Agent(
model=Llama(id="Llama-4-Maverick-17B-128E-Instruct-FP8"),
markdown=True,
)
image_path = Path(__file__).parent.joinpath("sample.jpg")
download_image(
url="https://upload.wikimedia.org/wikipedia/commons/0/0c/GoldenGateBridge-001.jpg",
output_path=str(image_path),
)
agent.print_response(
"Tell me about this image?",
images=[Image(filepath=image_path)],
stream=True,
)
# ---------------------------------------------------------------------------
# Run Agent
# ---------------------------------------------------------------------------
if __name__ == "__main__":
passRun the Example
Set up your virtual environment
uv venv --python 3.12
source .venv/bin/activateInstall dependencies
uv pip install -U agno llama-api-clientExport your Meta Llama API key
export LLAMA_API_KEY="your_llama_api_key_here"Run the example
Save the code above as image_input_file.py, then run:
python image_input_file.pyFull source: cookbook/90_models/meta/llama/image_input_file.py