> ## Documentation Index
> Fetch the complete documentation index at: https://phidatainc.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

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

  <Step title="Install dependencies">
    ```bash theme={null}
    uv pip install -U agno openai
    ```
  </Step>

  <Step title="Export your xAI API key">
    <CodeGroup>
      ```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"
      ```
    </CodeGroup>
  </Step>

  <Step title="Run the example">
    Save the code above as `live_search_agent.py`, then run:

    ```bash theme={null}
    python live_search_agent.py
    ```
  </Step>
</Steps>

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