> ## Documentation Index
> Fetch the complete documentation index at: https://apidoc.cometapi.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 使用 AnythingLLM 与 CometAPI

> 使用本指南，通过设置 base URL、API key 以及 model 或 provider 选项来配置 AnythingLLM 与 CometAPI。

[AnythingLLM](https://anythingllm.com/) 是一款一体化 AI 桌面应用。通过选择 **Generic OpenAI** 作为 provider，你可以将其连接到 CometAPI 并访问 500+ 模型。

## 前提条件

* 已在你的设备上安装 [AnythingLLM](https://anythingllm.com/)
* 拥有一个带有效 API key 的 [CometAPI](https://www.cometapi.com) 账户

## 设置

<Steps>
  <Step title="获取你的 CometAPI API key">
    登录 [CometAPI 控制台](https://www.cometapi.com/console)。点击 **Add API Key**，然后复制你的 key 和基础 URL（`https://api.cometapi.com`）。

    <Frame>
      <img src="https://mintcdn.com/cometapi/SZhlxZhCnMLn__BW/images/overview/810968_364191.png?fit=max&auto=format&n=SZhlxZhCnMLn__BW&q=85&s=aef81a83f29f8eb16655ed4060425f50" alt="CometAPI 控制台 — Add API Key" width="3824" height="1892" data-path="images/overview/810968_364191.png" />
    </Frame>

    <Frame>
      <img src="https://mintcdn.com/cometapi/HhtmQffktazbxUvS/images/overview/810968_364193.png?fit=max&auto=format&n=HhtmQffktazbxUvS&q=85&s=d893f659267150d0faf45f99eb5dffc1" alt="CometAPI API key 和基础 URL" width="2434" height="1232" data-path="images/overview/810968_364193.png" />
    </Frame>
  </Step>

  <Step title="配置 LLM 提供商">
    打开 AnythingLLM 的 **Settings** → **AI Providers** → **LLM Preferences**。选择 **Generic OpenAI** 作为 model 提供商，并在 **URL** 字段中输入 `https://api.cometapi.com/v1`。
  </Step>

  <Step title="添加你的 API key 和 model">
    将你的 CometAPI key 粘贴到 **API Key** 字段中。将 **Token Context Window** 和 **Max Tokens** 设置为与你所选 model 匹配的值，然后输入你想使用的当前 model ID。

    <Frame>
      <img src="https://mintcdn.com/cometapi/E4FFvyMYmaOZoldp/images/integrations/810968_360336.png?fit=max&auto=format&n=E4FFvyMYmaOZoldp&q=85&s=499826a1508a3749bf0815fe3c7e03df" alt="AnythingLLM LLM Preferences，已选择 Generic OpenAI" width="2014" height="985" data-path="images/integrations/810968_360336.png" />
    </Frame>

    <Frame>
      <img src="https://mintcdn.com/cometapi/E4FFvyMYmaOZoldp/images/integrations/810968_360337.png?fit=max&auto=format&n=E4FFvyMYmaOZoldp&q=85&s=0e882f3675ff64c5c688e95b9629a2d9" alt="已填写基础 URL 和 API key 字段" width="1905" height="1024" data-path="images/integrations/810968_360337.png" />
    </Frame>

    <Frame>
      <img src="https://mintcdn.com/cometapi/E4FFvyMYmaOZoldp/images/integrations/810968_360338.png?fit=max&auto=format&n=E4FFvyMYmaOZoldp&q=85&s=7c1f49711b3c429b74c9934f69caa7d9" alt="已配置 model 名称和 token 设置" width="1944" height="971" data-path="images/integrations/810968_360338.png" />
    </Frame>
  </Step>

  <Step title="测试连接">
    打开一个工作区并发送一条测试消息。成功收到回复即表示集成工作正常。

    <Frame>
      <img src="https://mintcdn.com/cometapi/E4FFvyMYmaOZoldp/images/integrations/810968_360340.png?fit=max&auto=format&n=E4FFvyMYmaOZoldp&q=85&s=8d084b71b4df10e71d4ae9c40baf7766" alt="AnythingLLM 聊天界面显示成功响应" width="915" height="740" data-path="images/integrations/810968_360340.png" />
    </Frame>
  </Step>
</Steps>

<Tip>
  你可以在同一个配置页面上添加多个 model 名称。请查看 [CometAPI 模型列表](/zh-Hans/overview/models) 了解支持的标识符。
</Tip>

<script type="application/ld+json">
  {`
    {
    "@context": "https://schema.org",
    "@graph": [
      {
        "@type": "HowTo",
        "@id": "https://apidoc.cometapi.com/integrations/anythingllm#howto",
        "name": "将 AnythingLLM 与 CometAPI 一起使用",
        "description": "使用本指南通过设置基础 URL、API key 以及 model 或提供商选项来配置 AnythingLLM 与 CometAPI。",
        "step": [
          {
            "@type": "HowToStep",
            "@id": "https://apidoc.cometapi.com/integrations/anythingllm#step-1",
            "position": 1,
            "name": "获取你的 CometAPI API key",
            "text": "创建或打开你的 CometAPI 账户，然后从控制台复制一个有效的 API key。"
          },
          {
            "@type": "HowToStep",
            "@id": "https://apidoc.cometapi.com/integrations/anythingllm#step-2",
            "position": 2,
            "name": "配置 LLM 提供商",
            "text": "完成《将 AnythingLLM 与 CometAPI 一起使用》指南中的“配置 LLM 提供商”步骤。"
          },
          {
            "@type": "HowToStep",
            "@id": "https://apidoc.cometapi.com/integrations/anythingllm#step-3",
            "position": 3,
            "name": "添加你的 API key 和 model",
            "text": "完成《将 AnythingLLM 与 CometAPI 一起使用》指南中的“添加你的 API key 和 model”步骤。"
          },
          {
            "@type": "HowToStep",
            "@id": "https://apidoc.cometapi.com/integrations/anythingllm#step-4",
            "position": 4,
            "name": "测试连接",
            "text": "从 CometAPI Models 页面选择一个当前的 model ID，然后从该集成发送测试请求。"
          }
        ]
      },
      {
        "@type": "BreadcrumbList",
        "itemListElement": [
          {
            "@type": "ListItem",
            "position": 1,
            "name": "CometAPI 文档",
            "item": "https://apidoc.cometapi.com/"
          },
          {
            "@type": "ListItem",
            "position": 2,
            "name": "集成",
            "item": "https://apidoc.cometapi.com/integrations"
          },
          {
            "@type": "ListItem",
            "position": 3,
            "name": "将 AnythingLLM 与 CometAPI 一起使用",
            "item": "https://apidoc.cometapi.com/integrations/anythingllm"
          }
        ]
      }
    ]
    }
    `}
</script>
