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

# xAI

> 了解如何将 xAI 与 Agno 结合使用。

xAI 是一个为大型语言模型提供终端的平台。
在此查看他们的模型列表：[https://docs.x.ai/docs/models](https://docs.x.ai/docs/models)。

我们建议通过实验来找到最适合您用例的模型。`grok-3` 模型适用于大多数用例。

## 身份验证

设置您的 `XAI_API_KEY` 环境变量。您可以在 [xAI 这里](https://console.x.ai/) 获取一个。

<CodeGroup>
  ```bash Mac theme={null}
  export XAI_API_KEY=sk-***
  ```

  ```bash Windows theme={null}
  setx XAI_API_KEY sk-***
  ```
</CodeGroup>

## 示例

将 `xAI` 与您的 `Agent` 一起使用：

<CodeGroup>
  ```python agent.py theme={null}

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

  agent = Agent(
      model=xAI(id="grok-3"),
      markdown=True
  )

  agent.print_response("写一个两句话的恐怖故事。")
  ```
</CodeGroup>

## 实时搜索

xAI 模型支持实时搜索功能，可以访问实时信息：

<CodeGroup>
  ```python live_search.py theme={null}
  from agno.agent import Agent
  from agno.models.xai import xAI

  agent = Agent(
      model=xAI(
          id="grok-3",
          search_parameters={
              "mode": "on",
              "max_search_results": 20,
              "return_citations": True,
          },
      ),
      markdown=True,
  )

  agent.print_response("关于 AI 的最新发展有哪些新闻？")
  ```
</CodeGroup>

<Note> 在此查看更多示例：[../examples/models/xai](../examples/models/xai)。 </Note>

## 参数

<Snippet file="model-xai-params.mdx" />

`xAI` 还支持 [OpenAI](/reference/models/openai) 的参数。
