{"meta":{"title":"在企业中为 GitHub Copilot 启用自定义模型","intro":"使用自己的 LLM API 密钥将首选自定义模型与 GitHub Copilot 集成，并将其提供给企业帐户中的组织。","product":"GitHub Copilot","breadcrumbs":[{"href":"/zh/copilot","title":"GitHub Copilot"},{"href":"/zh/copilot/how-tos","title":"操作方法"},{"href":"/zh/copilot/how-tos/administer-copilot","title":"管理 Copilot"},{"href":"/zh/copilot/how-tos/administer-copilot/manage-for-enterprise","title":"为企业管理"},{"href":"/zh/copilot/how-tos/administer-copilot/manage-for-enterprise/enable-custom-models","title":"启用自定义模型"}],"documentType":"article"},"body":"# 在企业中为 GitHub Copilot 启用自定义模型\n\n使用自己的 LLM API 密钥将首选自定义模型与 GitHub Copilot 集成，并将其提供给企业帐户中的组织。\n\n> \\[!NOTE]\n> 此功能目前处于公开预览，可能会发生更改。\n\n可以通过提供自己的 API 密钥，将自定义模型添加到企业或组织。 这使团队能够使用你首选的大型语言模型（LLM）提供商配合 Copilot Chat, Copilot CLI, and IDEs。\n\n支持来自以下提供程序的 API 密钥：\n\n* Anthropic\n* AWS Bedrock\n* Google AI Studio\n* Microsoft Foundry\n* OpenAI\n* OpenAI 兼容的提供程序\n* xAI\n\n还支持微调模型，但根据微调设置的不同，结果的功能和质量可能会有所不同。 在生产环境中使用模型之前，应仔细测试模型并仔细查看其输出。\n\n> \\[!NOTE] 单独的功能允许用户在各种客户端本地配置自己的 LLM 密钥。 请参阅“[GitHub Copilot 使用您自己的密钥](/zh/copilot/concepts/models/bring-your-own-key)”。\n\n## 为什么使用自己的 API 密钥？\n\n作为企业所有者，你可能对治理、数据安全性和合规性有特定要求。 设置自己的 API 密钥可以解决：\n\n* **治理和合规性：** 选择符合组织策略和法规要求的 LLM 提供商。\n* **成本管理：** 与现有的付款方式、合同、信用额度或协商费率保持一致，避免使用超额。\n* **可见性和控制：** 管理团队可以使用的模型，还可以通过提供商的现有仪表板和计费来监视用量。\n* **灵活性：** 支持组织已使用的自定义或专用模型。\n\n## 将密钥添加到企业帐户\n\n> \\[!IMPORTANT] 强烈建议仅向 API 密钥分配必要的最小范围，以遵守最低特权原则。\n\n添加密钥并选择一个或多个模型后，你和你所在组织的成员都将能够通过 Copilot Chat, Copilot CLI, and IDEs 使用这些模型。 您的模型将显示在模型选取器底部，在企业名称下方。\n\n1. 导航到您的企业。 例如，从 GitHub.com 上的 [公司](https://github.com/settings/enterprises?ref_product=ghec\\&ref_type=engagement\\&ref_style=text) 页面。\n\n2. 在页面顶部，单击 **<svg version=\"1.1\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" class=\"octicon octicon-copilot\" aria-label=\"copilot\" role=\"img\"><path d=\"M7.998 15.035c-4.562 0-7.873-2.914-7.998-3.749V9.338c.085-.628.677-1.686 1.588-2.065.013-.07.024-.143.036-.218.029-.183.06-.384.126-.612-.201-.508-.254-1.084-.254-1.656 0-.87.128-1.769.693-2.484.579-.733 1.494-1.124 2.724-1.261 1.206-.134 2.262.034 2.944.765.05.053.096.108.139.165.044-.057.094-.112.143-.165.682-.731 1.738-.899 2.944-.765 1.23.137 2.145.528 2.724 1.261.566.715.693 1.614.693 2.484 0 .572-.053 1.148-.254 1.656.066.228.098.429.126.612.012.076.024.148.037.218.924.385 1.522 1.471 1.591 2.095v1.872c0 .766-3.351 3.795-8.002 3.795Zm0-1.485c2.28 0 4.584-1.11 5.002-1.433V7.862l-.023-.116c-.49.21-1.075.291-1.727.291-1.146 0-2.059-.327-2.71-.991A3.222 3.222 0 0 1 8 6.303a3.24 3.24 0 0 1-.544.743c-.65.664-1.563.991-2.71.991-.652 0-1.236-.081-1.727-.291l-.023.116v4.255c.419.323 2.722 1.433 5.002 1.433ZM6.762 2.83c-.193-.206-.637-.413-1.682-.297-1.019.113-1.479.404-1.713.7-.247.312-.369.789-.369 1.554 0 .793.129 1.171.308 1.371.162.181.519.379 1.442.379.853 0 1.339-.235 1.638-.54.315-.322.527-.827.617-1.553.117-.935-.037-1.395-.241-1.614Zm4.155-.297c-1.044-.116-1.488.091-1.681.297-.204.219-.359.679-.242 1.614.091.726.303 1.231.618 1.553.299.305.784.54 1.638.54.922 0 1.28-.198 1.442-.379.179-.2.308-.578.308-1.371 0-.765-.123-1.242-.37-1.554-.233-.296-.693-.587-1.713-.7Z\"></path><path d=\"M6.25 9.037a.75.75 0 0 1 .75.75v1.501a.75.75 0 0 1-1.5 0V9.787a.75.75 0 0 1 .75-.75Zm4.25.75v1.501a.75.75 0 0 1-1.5 0V9.787a.75.75 0 0 1 1.5 0Z\"></path></svg> AI 控件**。\n\n3. 在边栏中，单击 **<svg version=\"1.1\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" class=\"octicon octicon-copilot\" aria-label=\"copilot\" role=\"img\"><path d=\"M7.998 15.035c-4.562 0-7.873-2.914-7.998-3.749V9.338c.085-.628.677-1.686 1.588-2.065.013-.07.024-.143.036-.218.029-.183.06-.384.126-.612-.201-.508-.254-1.084-.254-1.656 0-.87.128-1.769.693-2.484.579-.733 1.494-1.124 2.724-1.261 1.206-.134 2.262.034 2.944.765.05.053.096.108.139.165.044-.057.094-.112.143-.165.682-.731 1.738-.899 2.944-.765 1.23.137 2.145.528 2.724 1.261.566.715.693 1.614.693 2.484 0 .572-.053 1.148-.254 1.656.066.228.098.429.126.612.012.076.024.148.037.218.924.385 1.522 1.471 1.591 2.095v1.872c0 .766-3.351 3.795-8.002 3.795Zm0-1.485c2.28 0 4.584-1.11 5.002-1.433V7.862l-.023-.116c-.49.21-1.075.291-1.727.291-1.146 0-2.059-.327-2.71-.991A3.222 3.222 0 0 1 8 6.303a3.24 3.24 0 0 1-.544.743c-.65.664-1.563.991-2.71.991-.652 0-1.236-.081-1.727-.291l-.023.116v4.255c.419.323 2.722 1.433 5.002 1.433ZM6.762 2.83c-.193-.206-.637-.413-1.682-.297-1.019.113-1.479.404-1.713.7-.247.312-.369.789-.369 1.554 0 .793.129 1.171.308 1.371.162.181.519.379 1.442.379.853 0 1.339-.235 1.638-.54.315-.322.527-.827.617-1.553.117-.935-.037-1.395-.241-1.614Zm4.155-.297c-1.044-.116-1.488.091-1.681.297-.204.219-.359.679-.242 1.614.091.726.303 1.231.618 1.553.299.305.784.54 1.638.54.922 0 1.28-.198 1.442-.379.179-.2.308-.578.308-1.371 0-.765-.123-1.242-.37-1.554-.233-.296-.693-.587-1.713-.7Z\"></path><path d=\"M6.25 9.037a.75.75 0 0 1 .75.75v1.501a.75.75 0 0 1-1.5 0V9.787a.75.75 0 0 1 .75-.75Zm4.25.75v1.501a.75.75 0 0 1-1.5 0V9.787a.75.75 0 0 1 1.5 0Z\"></path></svg>Copilot**。\n\n4. 单击“ **配置自定义模型**”。\n\n5. 在 API 密钥列表上方，单击“ **添加 API 密钥**”。\n\n6. 在“提供程序”下，选择要使用的 LLM 提供程序。\n\n7. 在“名称”下，键入此密钥的名称。 这将显示在模型选取器中。\n\n8. 在“API 密钥”下，键入或粘贴密钥。\n\n9. 根据所使用的提供程序，选择或添加模型。\n   * 如果使用 OpenAI、Anthropic 或 xAI，请单击 <svg version=\"1.1\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" class=\"octicon octicon-sync\" aria-label=\"Fetch new models\" role=\"img\"><path d=\"M1.705 8.005a.75.75 0 0 1 .834.656 5.5 5.5 0 0 0 9.592 2.97l-1.204-1.204a.25.25 0 0 1 .177-.427h3.646a.25.25 0 0 1 .25.25v3.646a.25.25 0 0 1-.427.177l-1.38-1.38A7.002 7.002 0 0 1 1.05 8.84a.75.75 0 0 1 .656-.834ZM8 2.5a5.487 5.487 0 0 0-4.131 1.869l1.204 1.204A.25.25 0 0 1 4.896 6H1.25A.25.25 0 0 1 1 5.75V2.104a.25.25 0 0 1 .427-.177l1.38 1.38A7.002 7.002 0 0 1 14.95 7.16a.75.75 0 0 1-1.49.178A5.5 5.5 0 0 0 8 2.5Z\"></path></svg> API 密钥文本字段以提取与密钥关联的模型。 接下来，在“可用模型”下，选择要使用的模型。\n\n     ![“添加 API 密钥”窗体的屏幕截图。 “获取新模型”按钮用橙色轮廓突出了。](/assets/images/help/copilot/byok-add.png)\n\n   * 如果使用 Microsoft Foundry，请在“部署 URL”下的字段中键入部署 URL。 接下来，在“可用模型”下的字段中，键入模型 ID 并单击 <svg version=\"1.1\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" class=\"octicon octicon-check\" aria-label=\"Add model\" role=\"img\"><path d=\"M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0Z\"></path></svg> 以添加它。\n\n     如果模型具有不同的部署 URL，则无法将其添加到同一 API 密钥。 为每个部署 URL 创建单独的 API 密钥。\n\n     ![“添加 API 密钥”窗体的屏幕截图。 模型文本字段和“添加模型”按钮以橙色轮廓突出显示。](/assets/images/help/copilot/byok-add-foundry.png)\n\n10. 选择或添加要提供的模型后，单击“ **保存**”。\n\n## 管理组织中自定义模型的可用性\n\n可以选择已添加的模型是否可用于企业帐户中的组织。\n\n1. 导航到您的企业。 例如，从 GitHub.com 上的 [公司](https://github.com/settings/enterprises?ref_product=ghec\\&ref_type=engagement\\&ref_style=text) 页面。\n2. 在页面顶部，单击 **<svg version=\"1.1\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" class=\"octicon octicon-copilot\" aria-label=\"copilot\" role=\"img\"><path d=\"M7.998 15.035c-4.562 0-7.873-2.914-7.998-3.749V9.338c.085-.628.677-1.686 1.588-2.065.013-.07.024-.143.036-.218.029-.183.06-.384.126-.612-.201-.508-.254-1.084-.254-1.656 0-.87.128-1.769.693-2.484.579-.733 1.494-1.124 2.724-1.261 1.206-.134 2.262.034 2.944.765.05.053.096.108.139.165.044-.057.094-.112.143-.165.682-.731 1.738-.899 2.944-.765 1.23.137 2.145.528 2.724 1.261.566.715.693 1.614.693 2.484 0 .572-.053 1.148-.254 1.656.066.228.098.429.126.612.012.076.024.148.037.218.924.385 1.522 1.471 1.591 2.095v1.872c0 .766-3.351 3.795-8.002 3.795Zm0-1.485c2.28 0 4.584-1.11 5.002-1.433V7.862l-.023-.116c-.49.21-1.075.291-1.727.291-1.146 0-2.059-.327-2.71-.991A3.222 3.222 0 0 1 8 6.303a3.24 3.24 0 0 1-.544.743c-.65.664-1.563.991-2.71.991-.652 0-1.236-.081-1.727-.291l-.023.116v4.255c.419.323 2.722 1.433 5.002 1.433ZM6.762 2.83c-.193-.206-.637-.413-1.682-.297-1.019.113-1.479.404-1.713.7-.247.312-.369.789-.369 1.554 0 .793.129 1.171.308 1.371.162.181.519.379 1.442.379.853 0 1.339-.235 1.638-.54.315-.322.527-.827.617-1.553.117-.935-.037-1.395-.241-1.614Zm4.155-.297c-1.044-.116-1.488.091-1.681.297-.204.219-.359.679-.242 1.614.091.726.303 1.231.618 1.553.299.305.784.54 1.638.54.922 0 1.28-.198 1.442-.379.179-.2.308-.578.308-1.371 0-.765-.123-1.242-.37-1.554-.233-.296-.693-.587-1.713-.7Z\"></path><path d=\"M6.25 9.037a.75.75 0 0 1 .75.75v1.501a.75.75 0 0 1-1.5 0V9.787a.75.75 0 0 1 .75-.75Zm4.25.75v1.501a.75.75 0 0 1-1.5 0V9.787a.75.75 0 0 1 1.5 0Z\"></path></svg> AI 控件**。\n3. 在边栏中，单击 **<svg version=\"1.1\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" class=\"octicon octicon-copilot\" aria-label=\"copilot\" role=\"img\"><path d=\"M7.998 15.035c-4.562 0-7.873-2.914-7.998-3.749V9.338c.085-.628.677-1.686 1.588-2.065.013-.07.024-.143.036-.218.029-.183.06-.384.126-.612-.201-.508-.254-1.084-.254-1.656 0-.87.128-1.769.693-2.484.579-.733 1.494-1.124 2.724-1.261 1.206-.134 2.262.034 2.944.765.05.053.096.108.139.165.044-.057.094-.112.143-.165.682-.731 1.738-.899 2.944-.765 1.23.137 2.145.528 2.724 1.261.566.715.693 1.614.693 2.484 0 .572-.053 1.148-.254 1.656.066.228.098.429.126.612.012.076.024.148.037.218.924.385 1.522 1.471 1.591 2.095v1.872c0 .766-3.351 3.795-8.002 3.795Zm0-1.485c2.28 0 4.584-1.11 5.002-1.433V7.862l-.023-.116c-.49.21-1.075.291-1.727.291-1.146 0-2.059-.327-2.71-.991A3.222 3.222 0 0 1 8 6.303a3.24 3.24 0 0 1-.544.743c-.65.664-1.563.991-2.71.991-.652 0-1.236-.081-1.727-.291l-.023.116v4.255c.419.323 2.722 1.433 5.002 1.433ZM6.762 2.83c-.193-.206-.637-.413-1.682-.297-1.019.113-1.479.404-1.713.7-.247.312-.369.789-.369 1.554 0 .793.129 1.171.308 1.371.162.181.519.379 1.442.379.853 0 1.339-.235 1.638-.54.315-.322.527-.827.617-1.553.117-.935-.037-1.395-.241-1.614Zm4.155-.297c-1.044-.116-1.488.091-1.681.297-.204.219-.359.679-.242 1.614.091.726.303 1.231.618 1.553.299.305.784.54 1.638.54.922 0 1.28-.198 1.442-.379.179-.2.308-.578.308-1.371 0-.765-.123-1.242-.37-1.554-.233-.296-.693-.587-1.713-.7Z\"></path><path d=\"M6.25 9.037a.75.75 0 0 1 .75.75v1.501a.75.75 0 0 1-1.5 0V9.787a.75.75 0 0 1 .75-.75Zm4.25.75v1.501a.75.75 0 0 1-1.5 0V9.787a.75.75 0 0 1 1.5 0Z\"></path></svg>Copilot**。\n4. 单击“ **配置自定义模型**”。\n5. 在 API 密钥列表上方，单击“ **添加的模型** ”选项卡。\n6. 在模型旁边，单击“ **配置**”。 如果任何组织已获得访问模型的权限，则需要点击**所有组织** 或 **X 组织**，而不是“配置”。\n7. 在打开的模式中，单击 **“访问** ”选项卡。\n   > \\[!NOTE] 在“访问”选项卡可用之前，必须将模型设置为“已启用”。\n8. 选择应如何向组织提供模型：\n   * 若要使模型可供企业帐户中的所有组织使用，请选择 **“允许所有组织**”。\n   * 若要使模型仅适用于特定组织，请选择“ **选择每个组织**”，然后选中或取消选中下面列出的组织。\n9. 单击“ **保存**”。\n\n## 延伸阅读\n\n* 适用于组织的文档中的 [在你的组织中为 GitHub Copilot 启用自定义模型](/zh/copilot/how-tos/administer-copilot/manage-for-organization/enable-custom-models)。\n* [关于 GitHub Copilot 聊天功能](/zh/copilot/concepts/chat)\n* [支持 GitHub Copilot 策略的界面](/zh/copilot/reference/supported-surfaces-for-policies)"}