Kernel Builder Integration
The UseCopilotChatCompletion() extension method is the primary way to integrate
the Copilot connector with Semantic Kernel.
Note
Kernel builder extensions require net8.0 or later. On netstandard2.0, use the
CopilotHttpClientFactory directly.
Basic usage
var kernel = Kernel.CreateBuilder()
.UseCopilotChatCompletion()
.Build();
With model selection
var kernel = Kernel.CreateBuilder()
.UseCopilotChatCompletion(CopilotModels.ClaudeSonnet4)
.Build();
With custom options
var kernel = Kernel.CreateBuilder()
.UseCopilotChatCompletion(
modelId: CopilotModels.ClaudeSonnet46,
configure: options =>
{
options.EditorVersion = "vscode/1.104.1";
options.DangerouslyDisableSslValidation = true;
})
.Build();
Service Collection integration
For DI-heavy applications:
services.AddCopilotSessionProvider(options =>
{
options.DefaultModel = CopilotModels.ClaudeSonnet4;
});
This registers CopilotSessionProvider as a singleton in the container.
How it works
Under the hood, UseCopilotChatCompletion():
- Creates a
CopilotSessionProviderwith the specified options - Creates an
HttpClientviaCopilotHttpClientFactory.Create()with the auth handler - Registers SK's built-in
AddOpenAIChatCompletion()with the customHttpClient - Sets the
BaseAddressto the Copilot API endpoint
Since the Copilot API is OpenAI-compatible, no custom IChatCompletionService is needed.