How to use tool to fetch images from URLs

I want to use a tool to fetch images from URLs and pass the image content to the model,
Here is my code:

import httpx
from agno.agent import Agent
from agno.models.openai import OpenAIChat
from agno.media import Image
from loguru import logger

def fetch_image_from_url(image_url: str):

    try:
        logger.info(f"--- download image from {image_url}... ---")
        response = httpx.get(image_url)
        response.raise_for_status()
        
        content_type = response.headers.get('content-type', '')
        content_length = len(response.content)
        
        image = Image(content=response.content)
        
        logger.info(f"--- finish download image from  {image_url} ---")
        return image
        
    except Exception as e:
        return f"❌ failed to fetch image: {str(e)}"
    


from app.config import (
    BASE_URL,
    OPENAI_API_KEY,
    model_name,
)
agent = Agent(
    model=OpenAIChat(id=model_name,base_url=BASE_URL,api_key=OPENAI_API_KEY),
    tools=[fetch_image_from_url],
    instructions=[
          "When the user provides an image URL, use the fetch_image_from_url tool to fetch the image",
          "Analyze image information and provide detailed descriptions",
    ],
    show_tool_calls=True,
    markdown=True
)

url='https://ecs32.top/Snipaste_2025-07-09_11-26-30.png'
resp = agent.run(message=url)


res = resp.content
print(res)

The code execution successfully called fetch_image_from_url, but the output of the model has no relation to the image content,
The llm model I use is gemini-2.5-pro

Hi @chenyuduo, thanks for reaching out and supporting Agno. I’ve shared this with the team, we’re working through all requests one by one and will get back to you soon.
If it’s urgent, please let us know. We appreciate your patience!

1 Like

Hi @chenyuduo this is a feature under development. We are making it such that the media types generated by tools- image/video/files are passed along to the chat run and is accessible by the model.

We expect to release this by later next week. Thanks for using Agno! We will keep you posted!