<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/bring-your-own-model-to-the-github-copilot-sdk-with-c--7ni61fvty" -->

---
title: Bring Your Own Model to the GitHub Copilot SDK with C#
description: A walkthrough shows how to use the GitHub Copilot SDK's Bring Your Own Key (BYOK) feature in C# to route model inference to a custom Microsoft Foundry or Azure...
canonical: https://daily.dev/posts/bring-your-own-model-to-the-github-copilot-sdk-with-c--7ni61fvty
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Bring Your Own Model to the GitHub Copilot SDK with C# | daily.dev
og:description: A walkthrough shows how to use the GitHub Copilot SDK's Bring Your Own Key (BYOK) feature in C# to route model inference to a custom Microsoft Foundry or Azure...
og:url: https://daily.dev/posts/bring-your-own-model-to-the-github-copilot-sdk-with-c--7ni61fvty
og:image: https://api.daily.dev/og/posts/7nI61fVtY.png
og:image:alt: Bring Your Own Model to the GitHub Copilot SDK with C#
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

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

**[.NET Blog](https://daily.dev/sources/dotnet)** · 9 min read · 1 upvotes · 0 comments

## Summary

A walkthrough shows how to use the GitHub Copilot SDK's Bring Your Own Key (BYOK) feature in C# to route model inference to a custom Microsoft Foundry or Azure OpenAI deployment while keeping the Copilot agent runtime. The sample, part of Generative AI for Beginners .NET, is a .NET 10 console app that configures a ProviderConfig with OpenAI-compatible settings, authenticates via Microsoft Entra ID (AzureCliCredential) by default or an API key as fallback, starts the local Copilot CLI runtime via stdio, creates a minimal session with tools and skills disabled, and sends a single prompt to verify the custom model responds correctly.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://devblogs.microsoft.com/dotnet/bring-your-own-model-to-the-github-copilot-sdk-with-csharp>

## Questions this post answers

### How do I configure the GitHub Copilot SDK in C# to use my own Microsoft Foundry model deployment instead of the default provider?

Create a ProviderConfig with Type set to "openai", BaseUrl pointing to the Foundry endpoint normalized to end in /openai/v1/, WireApi set to "responses", and ModelId/WireModel set to the deployment name. Pass this provider into SessionConfig alongside the model name when calling CreateSessionAsync. The Copilot runtime still handles the client and session, only inference is routed to Foundry.

_daily.dev surfaces more walkthroughs like this for developers wiring custom model providers into agent SDKs._

### How do I authenticate to Microsoft Foundry from a GitHub Copilot SDK app without hardcoding an API key?

Use AzureCliCredential from the Azure.Identity package to reuse the session created by running az login, requesting the scope "https://cognitiveservices.azure.com/.default". Assign an async callback to provider.BearerTokenProvider that fetches and returns the token. The identity needs the Cognitive Services OpenAI User role on the resource; an API key header can be used instead if required.

_developers avoiding leaked secrets in AI agent configs can track BYOK auth patterns on daily.dev._

## Similar posts on daily.dev

- [Using GitHub Copilot CLI with Azure AI Foundry \(BYOK Models\) – Part 2](https://daily.dev/posts/using-github-copilot-cli-with-azure-ai-foundry-byok-models-part-2-lhzu8fgjp) · We Are .NET · 0 upvotes · 0 comments
- [Enterprise bring your own key \(BYOK\) for GitHub Copilot is now in public preview](https://daily.dev/posts/enterprise-bring-your-own-key-byok-for-github-copilot-is-now-in-public-preview-9ghqwnxsf) · GitHub Changelog · 0 upvotes · 0 comments
- [Getting started with the GitHub Copilot SDK in .NET](https://daily.dev/posts/getting-started-with-the-github-copilot-sdk-in-net-pbloribh7) · The Art of Simplicity · 3 upvotes · 0 comments
- [Use your own language model key in VS Code](https://daily.dev/posts/use-your-own-language-model-key-in-vs-code-lqkfvwxlq) · Visual Studio Code · 0 upvotes · 0 comments

---

Tags: [#c#](https://daily.dev/tags/c#), [#azure-openai](https://daily.dev/tags/azure-openai)

[View this post on daily.dev](https://daily.dev/posts/bring-your-own-model-to-the-github-copilot-sdk-with-c--7ni61fvty)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Bring Your Own Model to the GitHub Copilot SDK with C#","url":"https://daily.dev/posts/bring-your-own-model-to-the-github-copilot-sdk-with-c--7ni61fvty","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/bring-your-own-model-to-the-github-copilot-sdk-with-c--7ni61fvty"},"datePublished":"2026-10-19T16:01:10.185Z","dateModified":"2026-10-19T16:02:09.368Z","description":"A walkthrough shows how to use the GitHub Copilot SDK's Bring Your Own Key (BYOK) feature in C# to route model inference to a custom Microsoft Foundry or Azure...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/7e6935de1d7f9fa0624344c3e24c7ec1?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/7e6935de1d7f9fa0624344c3e24c7ec1?_a=AQAEuop","isAccessibleForFree":true,"articleSection":".NET Blog","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":".NET Blog","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/f23eb59371bd4f07aeef64c4eef73266","url":"https://daily.dev/sources/dotnet"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/bring-your-own-model-to-the-github-copilot-sdk-with-c--7ni61fvty","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":1},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"c#,azure-openai","timeRequired":"PT9M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":".NET Blog","item":"https://daily.dev/sources/dotnet"},{"@type":"ListItem","position":3,"name":"Bring Your Own Model to the GitHub Copilot SDK with C#"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/bring-your-own-model-to-the-github-copilot-sdk-with-c--7ni61fvty#faq","mainEntity":[{"@type":"Question","name":"How do I configure the GitHub Copilot SDK in C# to use my own Microsoft Foundry model deployment instead of the default provider?","acceptedAnswer":{"@type":"Answer","text":"Create a ProviderConfig with Type set to \"openai\", BaseUrl pointing to the Foundry endpoint normalized to end in /openai/v1/, WireApi set to \"responses\", and ModelId/WireModel set to the deployment name. Pass this provider into SessionConfig alongside the model name when calling CreateSessionAsync. The Copilot runtime still handles the client and session, only inference is routed to Foundry. daily.dev surfaces more walkthroughs like this for developers wiring custom model providers into agent SDKs."}},{"@type":"Question","name":"How do I authenticate to Microsoft Foundry from a GitHub Copilot SDK app without hardcoding an API key?","acceptedAnswer":{"@type":"Answer","text":"Use AzureCliCredential from the Azure.Identity package to reuse the session created by running az login, requesting the scope \"https://cognitiveservices.azure.com/.default\". Assign an async callback to provider.BearerTokenProvider that fetches and returns the token. The identity needs the Cognitive Services OpenAI User role on the resource; an API key header can be used instead if required. developers avoiding leaked secrets in AI agent configs can track BYOK auth patterns on daily.dev."}}]}
```

