> ## 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/agent_concepts/other/input_as_messages_list.py theme={null}
from agno.agent import Agent, Message

Agent().print_response(
    messages=[
        Message(
            role="user",
            content=[
                {"type": "text", "text": "你好！我叫约翰。"},
            ],
        ),
        Message(
            role="user",
            content=[
                {"type": "text", "text": "你能做什么？"},
            ],
        ),
    ],
    stream=True,
    markdown=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 openai agno
    ```
  </Step>

  <Step title="运行代理">
    <CodeGroup>
      ```bash Mac theme={null}
      python cookbook/agent_concepts/other/input_as_messages_list.py
      ```

      ```bash Windows theme={null}
      python cookbook/agent_concepts/other/input_as_messages_list.py
      ```
    </CodeGroup>
  </Step>
</Steps>
