Back to Agno

xAI Cookbook

cookbook/90_models/xai/README.md

2.6.5940 B
Original Source

xAI Cookbook

Note: Fork and clone this repository if needed

1. Create and activate a virtual environment

shell
python3 -m venv ~/.venvs/aienv
source ~/.venvs/aienv/bin/activate

2. Export your XAI_API_KEY

shell
export XAI_API_KEY=***

3. Install libraries

shell
uv pip install -U openai ddgs duckdb yfinance agno

4. Run basic Agent

  • Streaming on
shell
python cookbook/92_models/xai/basic_stream.py
  • Streaming off
shell
python cookbook/92_models/xai/basic.py

5. Run with Tools

  • DuckDuckGo Search
shell
python cookbook/92_models/xai/tool_use.py

6. Run Agent with Image URL Input

shell
python cookbook/92_models/xai/image_agent.py

7. Run Agent with Image Input

shell
python cookbook/92_models/xai/image_agent_bytes.py

8. Run Agent with Image Input and Memory

shell
python cookbook/92_models/xai/image_agent_with_memory.py
``