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

# 将 IntelliJ Translation Plugin 与 CometAPI 搭配使用

> 按照本指南，通过设置 base URL、API key 以及 model 或 provider 选项，将 IntelliJ Translation Plugin 配置为使用 CometAPI。

[IntelliJ Translation Plugin](https://plugins.jetbrains.com/plugin/8579-translation) 可将 AI 翻译能力直接集成到 JetBrains IDE 中。将其连接到 CometAPI，即可在不离开编辑器的情况下翻译代码和文本。

## 前提条件

* [IntelliJ IDEA](https://www.jetbrains.com/idea/) 或其他 JetBrains IDE

* 已安装 Translation Plugin——在 JetBrains Marketplace 中搜索 **Translation**

  <Frame>
    <img src="https://mintcdn.com/cometapi/mA1ovj6s0e3RM42l/images/integrations/810968_352994.png?fit=max&auto=format&n=mA1ovj6s0e3RM42l&q=85&s=3ea7331394d52a903c9b550830689eef" alt="显示 Translation 插件的 JetBrains Marketplace" width="972" height="806" data-path="images/integrations/810968_352994.png" />
  </Frame>

* 拥有一个已启用 API key 的 [CometAPI](https://www.cometapi.com) 账户

## 设置

<Steps>
  <Step title="获取你的 CometAPI API key">
    登录 [CometAPI 控制台](https://www.cometapi.com/console)。点击 **Add API Key** 并复制你的 key。

    <Frame>
      <img src="https://mintcdn.com/cometapi/E4FFvyMYmaOZoldp/images/integrations/810968_360264.png?fit=max&auto=format&n=E4FFvyMYmaOZoldp&q=85&s=686b18e5eda53581cd92f39b18683c01" alt="CometAPI 控制台 — API key 部分" width="1920" height="1005" data-path="images/integrations/810968_360264.png" />
    </Frame>

    <Frame>
      <img src="https://mintcdn.com/cometapi/E4FFvyMYmaOZoldp/images/integrations/810968_360265.png?fit=max&auto=format&n=E4FFvyMYmaOZoldp&q=85&s=4a5a528f1fbbeb3da7ace18066b73bd1" alt="CometAPI 控制台中的 Add API Key 对话框" width="1914" height="999" data-path="images/integrations/810968_360265.png" />
    </Frame>

    <Frame>
      <img src="https://mintcdn.com/cometapi/E4FFvyMYmaOZoldp/images/integrations/810968_360266.png?fit=max&auto=format&n=E4FFvyMYmaOZoldp&q=85&s=8462dfff1cf0a880c44effc7dccbc131" alt="CometAPI API key 和基础 URL" width="1920" height="975" data-path="images/integrations/810968_360266.png" />
    </Frame>
  </Step>

  <Step title="配置翻译引擎">
    点击 IDE 工具栏中的 Translation Plugin 图标 → **Settings** → **Translation**。选择 **OpenAI Translation** 作为引擎。在右侧的设置面板中，在 **API Endpoint** 字段输入 `https://api.cometapi.com`（第二个字段默认是 `/v1/chat/completions`）。将你的 CometAPI key 粘贴到 **API Key** 中，然后点击 **Confirm**。

    <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 按钮和 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 详情" width="2434" height="1232" data-path="images/overview/810968_364193.png" />
    </Frame>
  </Step>

  <Step title="测试集成">
    在插件设置中点击 **Test Service**。验证成功即表示设置正常工作。

    <Frame>
      <img src="https://mintcdn.com/cometapi/mA1ovj6s0e3RM42l/images/integrations/810968_352997.png?fit=max&auto=format&n=mA1ovj6s0e3RM42l&q=85&s=2acec03c1fcd4584cf8448d588cf5d68" alt="IntelliJ Translation Plugin 测试 — 成功结果" width="1092" height="944" data-path="images/integrations/810968_352997.png" />
    </Frame>
  </Step>
</Steps>

<Tip>
  如需添加自定义模型，请在插件的模型配置字段中输入当前 model ID。

  <Frame>
    <img src="https://mintcdn.com/cometapi/mA1ovj6s0e3RM42l/images/integrations/810968_352998.png?fit=max&auto=format&n=mA1ovj6s0e3RM42l&q=85&s=1138ce4ff04851f6db1ff996ea91f667" alt="IntelliJ Translation Plugin 模型设置，显示已添加自定义模型" width="1215" height="874" data-path="images/integrations/810968_352998.png" />
  </Frame>
</Tip>

<script type="application/ld+json">
  {`
    {
    "@context": "https://schema.org",
    "@graph": [
      {
        "@type": "HowTo",
        "@id": "https://apidoc.cometapi.com/integrations/intellij-translation-plugin#howto",
        "name": "使用 CometAPI 搭配 IntelliJ Translation Plugin",
        "description": "使用本指南可通过设置基础 URL、API key 以及模型或提供商选项，为 IntelliJ Translation Plugin 配置 CometAPI。",
        "step": [
          {
            "@type": "HowToStep",
            "@id": "https://apidoc.cometapi.com/integrations/intellij-translation-plugin#step-1",
            "position": 1,
            "name": "获取你的 CometAPI API key",
            "text": "创建或打开你的 CometAPI 账户，然后从控制台复制一个可用的 API key。"
          },
          {
            "@type": "HowToStep",
            "@id": "https://apidoc.cometapi.com/integrations/intellij-translation-plugin#step-2",
            "position": 2,
            "name": "配置翻译引擎",
            "text": "完成“使用 CometAPI 搭配 IntelliJ Translation Plugin”指南中的“配置翻译引擎”步骤。"
          },
          {
            "@type": "HowToStep",
            "@id": "https://apidoc.cometapi.com/integrations/intellij-translation-plugin#step-3",
            "position": 3,
            "name": "测试集成",
            "text": "完成“使用 CometAPI 搭配 IntelliJ Translation Plugin”指南中的“测试集成”步骤。"
          }
        ]
      },
      {
        "@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": "使用 CometAPI 搭配 IntelliJ Translation Plugin",
            "item": "https://apidoc.cometapi.com/integrations/intellij-translation-plugin"
          }
        ]
      }
    ]
    }
    `}
</script>
