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

# Structured output

````md theme={null}
---
title: Agent with Structured Outputs
---

## Code

```python cookbook/models/cohere/structured_output.py
from typing import List

from agno.agent import Agent, RunResponse  # noqa
from agno.models.cohere import Cohere
from pydantic import BaseModel, Field
from rich.pretty import pprint  # noqa


class MovieScript(BaseModel):
    setting: str = Field(
        ..., description="提供一个适合大片的场景。"
    )
    ending: str = Field(
        ...,
        description="电影的结局。如果不可用，请提供一个快乐的结局。",
    )
    genre: str = Field(
        ...,
        description="电影的类型。如果不可用，请选择动作、惊悚或浪漫喜剧。",
    )
    name: str = Field(..., description="给这部电影起个名字")
    characters: List[str] = Field(..., description="这部电影的角色名字。")
    storyline: str = Field(
        ..., description="电影的剧情梗概，三句话。要激动人心！"
    )


json_mode_agent = Agent(
    model=Cohere(id="command-r-08-2024"),
    description="你帮助人们撰写电影剧本。",
    response_model=MovieScript,
    # debug_mode=True,
)

# Get the response in a variable
# json_mode_response: RunResponse = json_mode_agent.run("New York")
# pprint(json_mode_response.content)

json_mode_agent.print_response("New York")
````

## Usage

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

  <Step title="Set your API key">
    ```bash theme={null}
    export CO_API_KEY=xxx
    ```
  </Step>

  <Step title="Install libraries">
    ```bash theme={null}
    pip install -U cohere agno
    ```
  </Step>

  <Step title="Run Agent">
    <CodeGroup>
      ```bash Mac theme={null}
      python cookbook/models/cohere/structured_output.py
      ```

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

```
```
