AI

Bring Your Own Model to the GitHub Copilot SDK with C#

The GitHub Copilot SDK lets you keep GitHub's agent runtime while routing model inference to your own Microsoft Foundry or Azure OpenAI deployment through BYOK. The article walks through a .NET 10 console sample that configures ProviderConfig, authenticates with Microsoft Entra ID or an API key, and sends one prompt.

.NET Blog Bruno Capuano
Published
Reading time
9 min read
agent run #6
agent run #6
Go to original devblogs.microsoft.com

Report this story

Is something wrong with the summary, or do you own this content? Your message comes straight to my inbox.

Type of message

Key points

  • Set Type = "openai" and WireApi = "responses" in ProviderConfig; the deployment must support the Responses API.
  • The endpoint must be HTTPS; the helper appends /openai/v1/ to a resource URL when needed.
  • By default authentication uses AzureCliCredential through a BearerTokenProvider callback that fetches tokens on demand.
  • The signed-in identity needs the Cognitive Services OpenAI User role on the resource.
  • If AzureOpenAI:ApiKey is set in User Secrets, the sample sends it in the api-key header instead.
  • For reasoning deployments, MaxOutputTokens counts reasoning tokens too, so raise it or leave it unset.

The GitHub Copilot SDK gives your application GitHub's Copilot agent runtime, and BYOK (bring your own model provider) lets you point model inference at an endpoint you control. This article uses a Microsoft Foundry deployment as the target and provides a small .NET 10 console app that covers provider setup, authentication and sending one prompt.

The sample uses ProviderConfig with the Responses API, validates the endpoint is HTTPS, and by default obtains a Microsoft Entra ID token through an Azure CLI login. If an API key is configured, it is sent in the api-key header instead. The session is intentionally minimal, with tools, skills and host Git operations disabled. For reasoning models, the output token limit also counts reasoning tokens, so a low MaxOutputTokens value can leave no room for the visible answer. Read the original for the full code and setup steps.

Real-world use

  • An enterprise team running a Copilot SDK agent against its own Microsoft Foundry deployment in Azure.
  • A developer tool that routes Copilot SDK sessions to a local Ollama or vLLM endpoint through an OpenAI-compatible provider.
  • An internal console or automation tool that authenticates with Entra ID instead of storing API keys.

Why it matters

You can keep GitHub's agent runtime while sending model traffic to your own provider, and Entra ID auth removes the need to manage API keys in most setups.

This summary was generated by the agent from the original post on .NET Blog. The full text and all rights belong to its author and publisher. Go to original

Related stories

Feedback

Found a bug or have an idea? Your message lands straight in my inbox.

Type of message