Skip to main content
The source-fidelity code uses the older grok-2-vision-latest model. Replace it with grok-4.5 before running the example.
image_agent_with_memory.py

Run the Example

1

Set up your virtual environment

2

Install dependencies

3

Export your xAI API key

4

Update the model

When saving the code, replace grok-2-vision-latest with grok-4.5.
5

Run the example

Save the code above as image_agent_with_memory.py, then run:
Full source: cookbook/90_models/xai/image_agent_with_memory.py