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

# Async structured output

## 代码

```python cookbook/models/meta/async_structured_output.py theme={null}
import asyncio
from typing import List
from pydantic import BaseModel, Field

from agno.agent import Agent
from agno.models.meta import Llama

class MovieScript(BaseModel):
    name: str = Field(..., description="电影名称。")
    setting: str = Field(..., description="提供电影的背景设定。")
    ending: str = Field(..., description="描述电影结局。")
    genre: str = Field(..., description="电影的类型。")
    characters: List[str] = Field(..., description="角色列表。")
    storyline: str = Field(..., description="一个三句话的故事梗概。")

agent = Agent(
    model=Llama(id="Llama-3.3-70B"),
    response_model=MovieScript,
    markdown=True,
)

asyncio.run(
    agent.aprint_response(
        "为科幻冒险片生成一个电影剧本大纲。"
    )
)
```

## 用法

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

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

  <Step title="安装库">
    ```bash theme={null}
    pip install llama-api-client agno
    ```
  </Step>

  <Step title="运行代理">
    <CodeGroup>
      ```bash Mac theme={null}
      python cookbook/models/meta/async_structured_output.py
      ```

      ```bash Windows theme={null}
      python cookbook/models/meta/async_structured_output.py
      ```
    </CodeGroup>
  </Step>
</Steps>
