Lmstudio Image Agent
Send image bytes to a llama3.2-vision model in LM Studio and stream the description.
"""
Lmstudio Image Agent
====================
Cookbook example for `lmstudio/image_agent.py`.
"""
import httpx
from agno.agent import Agent
from agno.media import Image
from agno.models.lmstudio import LMStudio
# ---------------------------------------------------------------------------
# Create Agent
# ---------------------------------------------------------------------------
agent = Agent(
model=LMStudio(id="llama3.2-vision"),
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,
)
# ---------------------------------------------------------------------------
# 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 openaiPrepare LM Studio
Load llama3.2-vision in LM Studio and start its local server at http://127.0.0.1:1234/v1.
Run the example
Save the code above as image_agent.py, then run:
python image_agent.pyFull source: cookbook/90_models/lmstudio/image_agent.py