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

# Anthropic Claude

> 了解如何在 Agno 中使用 Anthropic Claude 模型。

Claude 是 Anthropic 的一系列基础 AI 模型，可用于各种应用程序。
在此处查看他们的模型对比：[here](https://docs.anthropic.com/en/docs/about-claude/models#model-comparison-table)。

我们建议进行试验，以找到最适合您用例的模型。以下是一些通用建议：

* `claude-3-5-sonnet-20241022` 模型适用于大多数用例，并支持图像输入。
* `claude-3-5-haiku-20241022` 模型是他们最快的模型。

Anthropic 对其 API 有速率限制。有关更多信息，请参阅[文档](https://docs.anthropic.com/en/api/rate-limits#response-headers)。

## 身份验证

设置您的 `ANTHROPIC_API_KEY` 环境变量。您可以在[此处](https://console.anthropic.com/settings/keys)从 Anthropic 获取。

<CodeGroup>
  ```bash Mac theme={null}
  export ANTHROPIC_API_KEY=***
  ```

  ```bash Windows theme={null}
  setx ANTHROPIC_API_KEY ***
  ```
</CodeGroup>

## 示例

在您的 `Agent` 中使用 `Claude`：

<CodeGroup>
  ```python agent.py theme={null}
  from agno.agent import Agent, RunResponse
  from agno.models.anthropic import Claude

  agent = Agent(
      model=Claude(id="claude-3-5-sonnet-20240620"),
      markdown=True
  )

  # 在终端打印响应
  agent.print_response("写一个两句话的恐怖故事。")
  ```

  ## Prompt 缓存

  您可以通过将 `cache_system_prompt` 设置为 `True` 来启用我们 `Claude` 模型中的系统提示缓存：

  ```python theme={null}
  from agno.agent import Agent
  from agno.models.anthropic import Claude

  agent = Agent(
      model=Claude(
          id="claude-3-5-sonnet-20241022",
          cache_system_prompt=True,
      ),
  )
  ```

  在此处阅读有关 Agno 的 `Claude` 模型提示缓存的更多信息：[here](https://docs.agno.com/examples/models/anthropic/prompt_caching)。
</CodeGroup>

<Note>在此处查看更多示例：[here](../examples/models/anthropic)。</Note>

## 参数

<Snippet file="model-claude-params.mdx" />

`Claude` 是 [Model](/reference/models/model) 类的子类，可以访问相同的参数。
