Image Agent

Code

1import httpx
2
3from kern.agent import Agent
4from kern.media import Image
5from kern.models.lmstudio import LMStudio
6
7agent = Agent(
8 model=LMStudio(id="llama3.2-vision"),
9 markdown=True,
10)
11
12response = httpx.get(
13 "https://upload.wikimedia.org/wikipedia/commons/0/0c/GoldenGateBridge-001.jpg"
14)
15
16agent.print_response(
17 "Tell me about this image",
18 images=[Image(content=response.content)],
19 stream=True,
20)

Usage

Set up your virtual environment

1uv venv --python 3.12
2source .venv/bin/activate
1uv venv --python 3.12
2.venv\Scripts\activate

Install LM Studio

Install LM Studio from here and download the model you want to use.

Install dependencies

bash uv pip install -U kern-ai

Run Agent

1python cookbook/11_models/lmstudio/image_agent.py