Image Agent

Stream an LMStudio vision agent's response describing an image fetched over HTTP with httpx.

Code

import httpx

from agno.agent import Agent
from agno.media import Image
from agno.models.lmstudio import LMStudio

agent = Agent(
    model=LMStudio(id="your-vision-model-id"),
    markdown=True,
)

response = httpx.get(
    "https://upload.wikimedia.org/wikipedia/commons/0/0c/GoldenGateBridge-001.jpg"
)

agent.print_response(
    "Tell me about this image",
    images=[Image(content=response.content)],
    stream=True,
)

Choose a vision model that accepts image input, and replace your-vision-model-id with its server ID.

Usage

Set up your virtual environment

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

Start the LM Studio API server

Install LM Studio, download and load a model, then open Developer and start the API server on port 1234. Keep the server running while you run Python in a terminal.

Check the model list:

curl http://127.0.0.1:1234/v1/models

Set LMStudio(id=...) in the example to the exact model id returned by your server. If you change the server port, set the matching base_url on LMStudio.

Install dependencies

uv pip install -U openai agno

Run Agent

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

python image_agent.py