Image Agent

Code

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

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 CO_API_KEY=xxx

Install dependencies

1uv pip install -U cohere kern-ai

Run Agent

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