注意
The ability to bring your own API keys to GitHub Copilot is in 公共预览版 and subject to change.
Some models require the Responses API which is not currently supported.
You can bring your own API keys to GitHub Copilot, and enable teams to use your preferred large language model (LLM) providers with GitHub Copilot 聊天.
API keys from the following providers are supported:
- Anthropic
- Microsoft Foundry
- OpenAI
- xAI
Fine-tuned models are also supported, but functionality and quality of results can vary depending on the fine-tuning setup. You should test your model and review its outputs carefully before using it in production.
Why bring your own API keys?
As an organization owner, you may have specific requirements for governance, data security, and compliance. Setting up your own API keys allows you to address:
- Governance and compliance: Choose LLM providers that comply with your organization's policies and regulatory requirements.
- Cost management: Align with your existing payment methods, contracts, credits, or negotiated rates, and avoid usage overages.
- Visibility and control: Manage which models your team can access, and monitor usage through your provider's existing dashboards and billing.
- Flexibility: Support custom or specialized models that your organization already uses.
Adding your key to an organization account
重要
We highly recommend adhering to the principle of least privilege by assigning only the minimum necessary scopes to your API keys.
After you've added your key and selected one or more models, you and your organization members will be able to use them with GitHub Copilot 聊天. Your models will appear at the bottom of the model picker, under the organization name.
-
在 GitHub 的右上角,单击个人资料图片,然后单击“ Your organizations”****。
-
在组织旁边,单击“设置”。
-
In the sidebar, under "Code, planning, and automation", click Copilot.
-
Under "Copilot", click Models.
-
Click the Custom models tab.
-
Above the list of API keys, click Add API key.
-
Under "Provider", select the LLM provider you want to use.
-
Under "Name", type a name for this key. This will be shown in the model picker.
-
Under "API key", type or paste your key.
-
Depending on which provider you are using, select or add models.
-
If you're using OpenAI, Anthropic, or xAI, click in the API key text field to fetch the models associated with your key. Next, under "Available models", select the models you want to use.

-
If you're using Microsoft Foundry, type your deployment URL in the field under "Deployment URL". Next, in the field under "Available models", type a Model ID and click to add it.
If your models have different deployment URLs, they cannot be added to the same API key. Create a separate API key for each deployment URL.

-
-
After you select or add the models you want to make available, click Save.
Further reading
- Using your LLM provider API keys with Copilot in our documentation for enterprise accounts.
- 关于 GitHub Copilot Chat