GitHub Copilot app BYOK lets agent sessions use OpenAI, Azure OpenAI, Anthropic, Ollama, LM Studio, and compatible endpoints. Read the guide.

What BYOK Changes for Agent Sessions

Bring-your-own-key (BYOK) support in the GitHub Copilot app lets agent sessions call models through credentials and endpoints you control, instead of relying only on the default hosted path. You can route work through OpenAI, Azure OpenAI, Anthropic, Ollama, LM Studio, and other compatible endpoints. That matters when you need a specific model family, want traffic to stay on infrastructure you already trust, or need to separate cost and rate limits from a shared default plan.

Agent sessions differ from single-shot completions: they plan, call tools, read context, and iterate. The model you attach becomes the reasoning engine for that whole loop. Choosing the provider is therefore not only a preference about style or speed—it is a decision about latency, context limits, tool-calling reliability, and where prompts and code snippets are processed.

Supported Providers and When to Use Each

Cloud providers such as OpenAI, Azure OpenAI, and Anthropic are usually the right fit when you want strong general coding ability, stable uptime, and managed scaling. Azure OpenAI is especially useful when your organization already standardizes on Azure for identity, networking, and data residency. Anthropic and OpenAI options let you pick different model behaviors for planning-heavy tasks versus fast, narrow edits.

Local and self-hosted options such as Ollama, LM Studio, and compatible OpenAI-style endpoints help when code must not leave your machine or network, when you are iterating offline, or when you want to experiment without per-request cloud billing. The tradeoff is capacity: local models may handle shorter contexts or simpler tool flows better than long multi-step agent runs. Compatible endpoints are useful when you already run a gateway or proxy that speaks a familiar API shape—point BYOK at that gateway and keep Copilot’s agent UI as the front end.

Setup Patterns That Avoid Common Failures

  • Create a dedicated key or local server config for Copilot agent use, not a shared key mixed with unrelated scripts.
  • Confirm base URL, model id, and auth header format match what the provider or local server expects before starting a long session.
  • Start with a short agent task (read a file, summarize a module, propose a small change) to validate tool use and streaming.
  • Keep separate profiles for cloud vs local so you can switch without rewriting every field.
  • Document which models you allow for agent sessions versus chat-only use, especially if local models struggle with multi-step tool calls.

Most session failures come from mismatched endpoints, expired keys, or model names that the target server does not expose. Treat configuration as part of the environment checklist—alongside editor login and repository access—rather than a one-time toggle.

Practical Guidance for Day-to-Day Agent Work

Use cloud BYOK when the agent must reason across a large repository, chain several tool steps, or produce careful refactors where stronger models reduce back-and-forth. Use local BYOK for sensitive paths, exploratory prompts, or when you are shaping prompts and want fast, private iteration. For teams, standardize a small set of approved endpoints so agents behave predictably across machines.

Remember that BYOK shifts operational ownership: key rotation, quota monitoring, local process uptime, and model upgrades become your responsibility. Keep keys out of source control, prefer org-managed secrets where possible, and re-test agent sessions after any provider or local-server change. Done well, BYOK turns Copilot agent sessions into a flexible layer over the models and endpoints you already trust—without changing the core workflow of planning, editing, and verifying in the app.

Automate Your Content with AI Video Generator

Try it Free →