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

# OpenRouter

> 了解如何将 OpenRouter 与 Agno 结合使用。

OpenRouter 是一个提供大型语言模型端点的平台。

## 身份验证

设置您的 `OPENROUTER_API_KEY`环境变量。在此处获取您的密钥：[https://openrouter.ai/settings/keys](https://openrouter.ai/settings/keys)。

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

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

## 示例

将 `OpenRouter` 与您的 `Agent` 一起使用：

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

  agent = Agent(
      model=OpenRouter(id="gpt-4o"),
      markdown=True
  )

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

  ```
</CodeGroup>

## 参数

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

`OpenRouter` 还支持 [OpenAI](/reference/models/openai) 的参数。

## 提示缓存

当使用的提供商支持时，提示缓存将通过我们的 `OpenRouter` 模型自动进行。在其他情况下，您可以通过 `cache_control` 标头激活它。
您可以在 [他们的文档](https://openrouter.ai/docs/features/prompt-caching) 中了解有关与 OpenRouter 一起进行提示缓存的更多信息。
