> ## 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.

# 推理代理

## 代码

```python cookbook/models/xai/reasoning_agent.py theme={null}
from agno.agent import Agent
from agno.models.xai import xAI
from agno.tools.reasoning import ReasoningTools
from agno.tools.yfinance import YFinanceTools

reasoning_agent = Agent(
    model=xAI(id="grok-3-beta"),
    tools=[
        ReasoningTools(add_instructions=True, add_few_shot=True),
        YFinanceTools(
            stock_price=True,
            analyst_recommendations=True,
            company_info=True,
            company_news=True,
        ),
    ],
    instructions=[
        "使用表格展示数据",
        "只输出报告，不输出其他文字",
    ],
    markdown=True,
)
reasoning_agent.print_response(
    "撰写一份关于 TSLA 的报告",
    stream=True,
    show_full_reasoning=True,
    stream_intermediate_steps=True,
)
```

## 用法

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

  <Step title="设置你的 API 密钥">
    ```bash theme={null}
    export XAI_API_KEY=xxx
    ```
  </Step>

  <Step title="安装库">
    ```bash theme={null}
    pip install -U openai yfinance agno
    ```
  </Step>

  <Step title="运行代理">
    ```bash theme={null}
    python cookbook/models/xai/reasoning_agent.py
    ```
  </Step>
</Steps>
