> ## Documentation Index
> Fetch the complete documentation index at: https://agno-v2.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# xAI Live Search Agent

> Enable xAI Live Search on Grok with search parameters and citations for a news digest.

```python live_search_agent.py theme={null}
"""
Xai Live Search Agent
=====================

Cookbook example for `xai/live_search_agent.py`.
"""

from agno.agent import Agent
from agno.models.xai.xai import xAI

# ---------------------------------------------------------------------------
# Create Agent
# ---------------------------------------------------------------------------

agent = Agent(
    model=xAI(
        id="grok-3",
        search_parameters={
            "mode": "on",
            "max_search_results": 20,
            "return_citations": True,
        },
    ),
    markdown=True,
)
agent.print_response("Provide me a digest of world news in the last 24 hours.")

# ---------------------------------------------------------------------------
# Run Agent
# ---------------------------------------------------------------------------

if __name__ == "__main__":
    pass
```

## Run the Example

<Snippet file="create-venv-step.mdx" />

**1. Install dependencies**

```bash theme={null}
uv pip install -U agno openai
```

**2. Export your xAI API key**

```bash Mac/Linux theme={null}
export XAI_API_KEY="your_xai_api_key_here"
```

```bash Windows theme={null}
$Env:XAI_API_KEY="your_xai_api_key_here"
```

**3. Run the example**

Save the code above as `live_search_agent.py`, then run:

```bash theme={null}
python live_search_agent.py
```

Full source: [cookbook/90\_models/xai/live\_search\_agent.py](https://github.com/agno-agi/agno/blob/v3.0.4/cookbook/90_models/xai/live_search_agent.py)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.