C# Language

Configuring Bring Your Own Model in the GitHub Copilot SDK with Csharp

This technical guide explains how to use custom model providers with the GitHub Copilot SDK in a .NET 10 console application. By leveraging ProviderConfig, developers can route model inference to endpoints like Microsoft Foundry while retaining the Copilot agent runtime orchestration.

What changed From the source

A new .NET 10 sample project demonstrates how to use the GitHub Copilot SDK with custom model deployments, referred to as Bring Your Own Key or BYOK. The implementation utilizes a ProviderConfig object to reroute inference traffic while maintaining the standard Copilot agent runtime framework for client management, session handling, system messages, and agent configuration.

The sample application is a minimal console project that reads configuration, creates a BYOK provider configuration, starts the Copilot runtime, initiates a session, and sends a prompt. It relies on packages including GitHub.Copilot.SDK version 1.0.11, Azure.Identity version 1.21.0, and Microsoft.Extensions.Configuration packages at version 10.0.3.

  • ProviderConfig routes inference to supported endpoints such as OpenAI, Anthropic, Ollama, Microsoft Foundry Local, or OpenAI-compatible endpoints like vLLM and LiteLLM.
  • Authentication defaults to Microsoft Entra ID using AzureCliCredential via an experimental BearerTokenProvider callback, with an optional API key fallback header.
  • The sample session disables tools, skills, configuration discovery, and host Git operations to isolate the model request.

At a glance · C# Language

What changedWhy it mattersWho should careUpgrade and migration considerations

Why it matters Analysis

Separating the Copilot runtime orchestration from the underlying model provider gives developers flexibility in choosing where model inference executes. By abstracting the endpoint and authentication details through configuration properties, applications can switch between hosted services like Microsoft Foundry and other compatible endpoints without altering the core agent loop.

Utilizing Microsoft Entra ID by default reduces operational overhead by eliminating manual API key rotation for local developer workflows. However, developers must ensure their identity is assigned the correct Cognitive Services OpenAI User role and that prerequisites such as the Azure CLI and GitHub Copilot CLI are installed.

  • Enables integration with custom or enterprise-hosted model deployments while retaining structured session control.
  • Facilitates secure configuration management during local development through .NET User Secrets.

Who should care Analysis

Csharp developers building AI agent harnesses with .NET 10 who want to use specific model deployments rather than default cloud configurations will find this integration approach useful. It is particularly relevant for engineering teams leveraging Microsoft Foundry or other OpenAI-compatible services alongside the GitHub Copilot ecosystem.

  • .NET developers working with generative AI applications and agent architectures.
  • Teams needing flexible provider routing for compliance, performance, or cost optimization reasons.

Upgrade and migration considerations Analysis

The source material does not specify migration steps from older SDK versions. Developers adopting the GitHub.Copilot.SDK version 1.0.11 must ensure their target framework is set to net10.0 and that the local environment has the GitHub Copilot CLI installed.

Special attention should be given to token limits when utilizing reasoning models, as MaxOutputTokens includes both reasoning tokens and visible answers. The source notes that experimental attributes such as BYOK authentication callbacks require appropriate preprocessor directives.

  • Verify that the model deployment supports the Responses API when configuring WireApi as responses.
  • Adjust MaxOutputTokens limits if working with reasoning models to prevent premature truncation.

Sources and further reading

Original: “Bring Your Own Model to the GitHub Copilot SDK with C#”, .NET Blog, published 19 Oct 2026, retrieved 19 Oct 2026. This article was drafted with AI assistance from the official source and passed automated fact and quality checks. Spotted a mistake? See our corrections policy.