image_agent.py
Run the Example
1
Set up your virtual environment
2
Install dependencies
3
Export environment variables
4
Run the example
Save the code above as
image_agent.py, then run:Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Stream an image description from a vision model through CometAPI.
"""
Image analysis example using CometAPI with vision models.
"""
from agno.agent import Agent
from agno.media import Image
from agno.models.cometapi import CometAPI
# ---------------------------------------------------------------------------
# Create Agent
# ---------------------------------------------------------------------------
# Use a vision-capable model from CometAPI
agent = Agent(
model=CometAPI(id="gpt-4o"), # GPT-4o has vision capabilities
markdown=True,
)
agent.print_response(
"Describe this image in detail and tell me what you can see",
images=[
Image(
url="https://httpbin.org/image/png" # Reliable test image
)
],
stream=True,
)
# ---------------------------------------------------------------------------
# Run Agent
# ---------------------------------------------------------------------------
if __name__ == "__main__":
pass
Set up your virtual environment
uv venv --python 3.12
source .venv/bin/activate
uv venv --python 3.12
.venv\Scripts\activate
Install dependencies
uv pip install -U agno openai
Export environment variables
export COMETAPI_KEY="your_cometapi_key_here"
$Env:COMETAPI_KEY="your_cometapi_key_here"
Run the example
image_agent.py, then run:python image_agent.py
Was this page helpful?