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

# 基础版

> 将您的 Agno Agent 作为 FastAPI 应用公开

## 代码

```python cookbook/apps/fastapi/basic.py theme={null}
from agno.agent import Agent
from agno.app.fastapi.app import FastAPIApp
from agno.models.openai import OpenAIChat

basic_agent = Agent(
    name="基础代理",
    model=OpenAIChat(id="gpt-4o"),
    add_history_to_messages=True,
    num_history_responses=3,
    add_datetime_to_instructions=True,
    markdown=True,
)

fastapi_app = FastAPIApp(
    agent=basic_agent,
    name="基础代理",
    app_id="basic_agent",
    description="一个基础代理，可以回答问题并协助完成任务。",
)

app = fastapi_app.get_app()

if __name__ == "__main__":
    fastapi_app.serve(app="basic:app", port=8001, reload=True)

```

## 用法

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

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

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

  <Step title="运行代理">
    <CodeGroup>
      ```bash Mac theme={null}
      python cookbook/apps/fastapi/basic.py
      ```

      ```bash Windows theme={null}
      python cookbook/apps/fastapi/basic.py
      ```
    </CodeGroup>
  </Step>
</Steps>
