Image Agent

Code

1from kern.agent import Agent
2from kern.media import Image
3from kern.models.groq import Groq
4
5agent = Agent(model=Groq(id="meta-llama/llama-4-scout-17b-16e-instruct"))
6
7agent.print_response(
8 "Tell me about this image",
9 images=[
10 Image(url="https://upload.wikimedia.org/wikipedia/commons/f/f2/LPU-v1-die.jpg"),
11 ],
12 stream=True,
13)

Usage

Set up your virtual environment

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

Set your API key

1export GROQ_API_KEY=xxx

Install dependencies

1uv pip install -U groq kern-ai

Run Agent

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