← Blog
explainx / blog

GitHub Copilot SDK: Build Agentic Workflows in Python, TypeScript, Go, .NET, Rust, and Java with Production-Tested Agent Runtime

GitHub releases Copilot SDK for Python, TypeScript, Go, .NET, Rust, and Java. Build agents with the same engine behind Copilot CLI—production-tested orchestration for planning, tool invocation, file edits, and autonomous workflows.

8 min readYash Thakker
github-copilotsdkai-agentspythontypescriptgodotnetrustjavabyok

MDX restores the committed source plus an HTML comment attribution; plain text bundles the rendered markdown body with the explainx.ai attribution footer.

GitHub Copilot SDK: Build Agentic Workflows in Python, TypeScript, Go, .NET, Rust, and Java with Production-Tested Agent Runtime

GitHub has released the Copilot SDK—a multi-platform toolkit for embedding Copilot's production-tested agentic workflows into applications across Python, TypeScript, Go, .NET, Rust, and Java. With 9.3K stars and 1.2K forks, the SDK exposes the same engine behind Copilot CLI, handling planning, tool invocation, file edits, and autonomous agent execution without requiring developers to build custom orchestration.

The SDK supports multiple authentication methods including GitHub OAuth, environment variables, and BYOK (Bring Your Own Key) for OpenAI, Azure AI Foundry, and Anthropic—enabling developers to use Copilot's agent runtime with their own API keys and no GitHub authentication required. Billing is based on the same model as Copilot CLI, with each prompt counted toward premium request quotas, and a free tier with limited usage.

This represents GitHub's strategic play in the Agent Economy—making it trivial for any application to add AI coding agents that plan, execute, debug, and deploy code autonomously. Rather than competing with frameworks like LangChain or LlamaIndex, GitHub is offering production-grade orchestration that millions of developers already trust through Copilot CLI and Copilot Workspace.

This guide explores the SDK architecture, available languages, authentication methods, BYOK configuration, custom agent development, and real-world integration patterns for embedding Copilot agents in your applications.


Part I: What is the GitHub Copilot SDK?

The Problem

Building AI agents requires solving hard orchestration problems:

Traditional approach:

  1. Planning - Break user requests into executable steps
  2. Tool selection - Choose appropriate tools (file operations, bash, API calls)
  3. Execution - Run tools and handle errors
  4. Iteration - Refine based on results, retry failures
  5. Context management - Track conversation state across long sessions

Developer pain points:

  • Frameworks like LangChain are powerful but complex (steep learning curve)
  • Production-grade error handling is non-trivial (retries, timeouts, fallbacks)
  • Multi-step workflows require custom state machines
  • Tool calling patterns vary across LLM providers (OpenAI vs Anthropic vs Azure)

The GitHub Copilot SDK Solution

GitHub's SDK provides:

Production-tested orchestration - Same engine as Copilot CLI (millions of users) ✅ Multi-language support - Python, TypeScript, Go, .NET, Rust, Java ✅ Built-in tools - File operations, bash execution, git, web search, MCP servers ✅ Zero boilerplate - Define agent behavior, Copilot handles execution ✅ Flexible auth - GitHub OAuth, API keys, BYOK for OpenAI/Azure/Anthropic ✅ Streaming responses - Real-time updates as agents work ✅ Permission handlers - Approve/deny tool calls programmatically

Architecture:

Your Application
       ↓
  SDK Client (Python/TS/Go/.NET/Rust/Java)
       ↓ JSON-RPC
  Copilot CLI (server mode)
       ↓
  LLM Provider (GitHub/OpenAI/Azure/Anthropic)

The SDK manages the CLI process lifecycle automatically. You can also connect to an external CLI server for distributed deployments.


Part II: Available SDKs and Installation

SDK Comparison

LanguagePackageInstallationCLI Bundled?Cookbook
TypeScript@github/copilot-sdknpm install @github/copilot-sdk✅ YesLink
Pythongithub-copilot-sdkpip install github-copilot-sdk✅ YesLink
.NETGitHub.Copilot.SDKdotnet add package GitHub.Copilot.SDK✅ YesLink
Gogithub.com/github/copilot-sdk/gogo get github.com/github/copilot-sdk/go❌ No (manual install)Link
Rustgithub-copilot-sdkcargo add github-copilot-sdk❌ No (optional bundling)Link
Javacom.github:copilot-sdk-javaMaven/Gradle❌ No (manual install)Link

Note: For Go, Rust, and Java, you need to install the Copilot CLI separately or ensure copilot is in your PATH. Go and Rust also offer application-level CLI bundling features.

Quick Start: Python

pip install github-copilot-sdk
from github_copilot_sdk import CopilotClient

# Create client (auto-manages CLI)
client = CopilotClient()

# Run agent
response = await client.chat(
    messages=[
        {"role": "user", "content": "Create a FastAPI app with user authentication"}
    ]
)

print(response.content)

Quick Start: TypeScript

npm install @github/copilot-sdk
import { CopilotClient } from '@github/copilot-sdk';

const client = new CopilotClient();

const response = await client.chat({
  messages: [
    { role: 'user', content: 'Add Stripe checkout to my Next.js app' }
  ]
});

console.log(response.content);

Quick Start: Go

# Install CLI first
brew install gh
gh extension install github/gh-copilot

# Install SDK
go get github.com/github/copilot-sdk/go
package main

import (
    "context"
    copilot "github.com/github/copilot-sdk/go"
)

func main() {
    client := copilot.NewClient()

    resp, _ := client.Chat(context.Background(), &copilot.ChatRequest{
        Messages: []copilot.Message{
            {Role: "user", Content: "Build a gRPC server with auth"},
        },
    })

    println(resp.Content)
}

Part III: Authentication Methods

1. GitHub Signed-In User (Default)

If you've run gh auth login or copilot login, the SDK uses stored OAuth credentials:

from github_copilot_sdk import CopilotClient

# Automatically uses ~/.config/gh/hosts.yml credentials
client = CopilotClient()

How it works:

  1. SDK checks for GitHub CLI credentials at ~/.config/gh/hosts.yml
  2. Retrieves OAuth token
  3. Uses token to authenticate with GitHub Copilot API

Billing: Counted against your GitHub Copilot subscription

2. OAuth GitHub App

Pass user tokens from your own GitHub OAuth app:

client = CopilotClient(
    auth_token="gho_abc123xyz"  # User's GitHub token
)

Use case: SaaS apps where each user has their own GitHub account

3. Environment Variables

Set COPILOT_GITHUB_TOKEN, GH_TOKEN, or GITHUB_TOKEN:

export GITHUB_TOKEN="gho_abc123xyz"
client = CopilotClient()  # Automatically reads from env

Use case: CI/CD pipelines, serverless functions

4. BYOK (Bring Your Own Key)

Use your own OpenAI, Azure AI Foundry, or Anthropic API keys:

client = CopilotClient(
    byok_config={
        "provider": "openai",
        "api_key": "sk-abc123xyz",
        "model": "gpt-4o"
    }
)

Supported providers:

  • OpenAI - gpt-4o, gpt-4-turbo, o1, o3
  • Azure AI Foundry - Azure OpenAI models
  • Anthropic - claude-3-5-sonnet, claude-3-opus

Benefits:

  • ✅ No GitHub authentication required
  • ✅ Use your own LLM budget
  • ✅ Deploy in air-gapped environments

Limitations:

  • ❌ Microsoft Entra ID (Azure AD) not supported
  • ❌ Managed identities not supported
  • ❌ Third-party identity providers not supported

BYOK Configuration Example:

# OpenAI
client = CopilotClient(byok_config={
    "provider": "openai",
    "api_key": "sk-abc123",
    "model": "gpt-4o"
})

# Azure AI Foundry
client = CopilotClient(byok_config={
    "provider": "azure",
    "api_key": "abc123",
    "endpoint": "https://myresource.openai.azure.com/",
    "deployment_name": "gpt-4o"
})

# Anthropic
client = CopilotClient(byok_config={
    "provider": "anthropic",
    "api_key": "sk-ant-abc123",
    "model": "claude-3-5-sonnet-20241022"
})

Part IV: Billing and Pricing

How Billing Works

The SDK uses the same billing model as Copilot CLI:

For GitHub Copilot Subscriptions:

Free Tier:

  • Limited usage per month
  • Exact quota varies by subscription type

For BYOK:

  • No GitHub charges
  • Pay your LLM provider directly (OpenAI, Azure, Anthropic)

Pricing (GitHub Copilot Individual, as of June 2026):

  • $10/month or $100/year
  • Premium request quota: ~500-1,000 requests/month (estimated)

Pricing (GitHub Copilot Business):

  • $19/user/month
  • Higher premium request quotas
  • Admin controls, audit logs

Cost Optimization Tips

1. Use BYOK for high-volume applications

If you're making 10K+ requests/month, BYOK with OpenAI API is cheaper:

UsageGitHub CopilotOpenAI BYOK (GPT-4o)
1K requests$10/mo$15
10K requests$190/mo (10 users)$150
100K requests$1,900/mo (100 users)$1,500

2. Cache common requests

Cache agent responses for repeated queries:

import hashlib
import json

cache = {}

def cached_agent(query):
    key = hashlib.sha256(query.encode()).hexdigest()
    if key in cache:
        return cache[key]

    response = client.chat(messages=[{"role": "user", "content": query}])
    cache[key] = response
    return response

3. Use cheaper models for simple tasks

BYOK allows switching models per request:

# Use GPT-4o-mini for simple queries
simple_response = client.chat(
    messages=[{"role": "user", "content": "Format this JSON"}],
    byok_config={"model": "gpt-4o-mini"}  # 10x cheaper
)

# Use GPT-4o for complex agents
complex_response = client.chat(
    messages=[{"role": "user", "content": "Refactor this architecture"}],
    byok_config={"model": "gpt-4o"}
)

Part V: Built-in Tools

The SDK exposes Copilot CLI's first-party tools by default (similar to --allow-all):

File Operations

  • Read - Read file contents
  • Write - Create/overwrite files
  • Edit - Precise string replacements
  • Glob - Find files by pattern
  • Grep - Search file contents

Command Execution

  • Bash - Run shell commands
  • Git - Git operations (status, diff, commit, etc.)

Web & Research

  • WebFetch - Fetch and parse URLs
  • WebSearch - Search the web

Advanced

  • Task - Spawn sub-agents for complex workflows
  • MCP Servers - Connect to Model Context Protocol servers

Permission Handler:

All tool execution is governed by permission handlers—you approve, deny, or customize tool calls:

def permission_handler(tool_call):
    # Approve all Read operations
    if tool_call.tool == "Read":
        return "approve"

    # Require confirmation for Bash
    if tool_call.tool == "Bash":
        print(f"Agent wants to run: {tool_call.command}")
        return input("Approve? (y/n): ") == "y"

    # Deny Write to sensitive directories
    if tool_call.tool == "Write" and "/etc/" in tool_call.path:
        return "deny"

    return "approve"

client = CopilotClient(permission_handler=permission_handler)

Part VI: Building Custom Agents

Basic Agent

from github_copilot_sdk import CopilotClient

client = CopilotClient()

async def build_feature(description):
    response = await client.chat(
        messages=[
            {
                "role": "system",
                "content": "You are an expert software engineer. Build features according to best practices."
            },
            {
                "role": "user",
                "content": f"Build this feature: {description}"
            }
        ]
    )

    return response.content

# Usage
result = await build_feature("Add user profile page with avatar upload")
print(result)

Agent with Streaming

Get real-time updates as the agent works:

async def build_feature_streaming(description):
    async for chunk in client.chat_stream(
        messages=[
            {"role": "user", "content": f"Build: {description}"}
        ]
    ):
        if chunk.type == "tool_call":
            print(f"🔧 Using tool: {chunk.tool} - {chunk.description}")
        elif chunk.type == "content":
            print(f"💬 {chunk.content}")
        elif chunk.type == "error":
            print(f"❌ Error: {chunk.error}")

await build_feature_streaming("Add Stripe subscription management")

Output:

🔧 Using tool: Read - Reading existing payment configuration
💬 I can see you have Stripe installed. Let me add subscription management.
🔧 Using tool: Write - Creating subscription service
🔧 Using tool: Edit - Updating API routes
🔧 Using tool: Bash - Running database migration
💬 Subscription management is now implemented with webhook handling.

Agent with Custom Tools

Add domain-specific tools:

from github_copilot_sdk import CopilotClient, Tool

# Define custom tool
def query_analytics_db(query: str) -> dict:
    """Query the analytics database"""
    # Your implementation
    return {"users": 1523, "conversions": 234}

analytics_tool = Tool(
    name="query_analytics",
    description="Query analytics database for metrics",
    parameters={
        "type": "object",
        "properties": {
            "query": {"type": "string", "description": "SQL query"}
        },
        "required": ["query"]
    },
    function=query_analytics_db
)

# Use in agent
client = CopilotClient(tools=[analytics_tool])

response = await client.chat(
    messages=[
        {"role": "user", "content": "What's our conversion rate this month?"}
    ]
)

# Agent automatically calls query_analytics tool

Multi-Step Agent Workflow

Build agents that plan → execute → verify:

async def autonomous_bug_fix(bug_description):
    conversation = [
        {"role": "system", "content": "You are a debugging expert. Follow this workflow: 1) Understand the bug 2) Read relevant code 3) Write a fix 4) Test the fix 5) Commit if tests pass"}
    ]

    conversation.append({
        "role": "user",
        "content": f"Fix this bug: {bug_description}"
    })

    # Agent runs multi-step workflow
    response = await client.chat(messages=conversation)

    return response.content

result = await autonomous_bug_fix("Login button returns 500 error on Safari")

Part VII: Real-World Integration Patterns

Pattern 1: SaaS Code Generation Platform

from fastapi import FastAPI, HTTPException
from github_copilot_sdk import CopilotClient

app = FastAPI()
copilot_clients = {}  # User ID -> CopilotClient

@app.post("/api/generate")
async def generate_code(user_id: str, prompt: str, github_token: str):
    # Create user-specific client
    if user_id not in copilot_clients:
        copilot_clients[user_id] = CopilotClient(auth_token=github_token)

    client = copilot_clients[user_id]

    try:
        response = await client.chat(
            messages=[{"role": "user", "content": prompt}]
        )
        return {"code": response.content}
    except Exception as e:
        raise HTTPException(status_code=500, detail=str(e))

Pattern 2: Internal Developer Platform

from github_copilot_sdk import CopilotClient

class DevPlatform:
    def __init__(self, byok_api_key):
        self.client = CopilotClient(byok_config={
            "provider": "anthropic",
            "api_key": byok_api_key,
            "model": "claude-3-5-sonnet-20241022"
        })

    async def scaffold_microservice(self, service_name, spec):
        return await self.client.chat(
            messages=[
                {"role": "system", "content": "Generate microservices following our internal standards"},
                {"role": "user", "content": f"Create {service_name}: {spec}"}
            ]
        )

    async def refactor_legacy_code(self, file_path):
        return await self.client.chat(
            messages=[
                {"role": "user", "content": f"Refactor {file_path} to TypeScript with tests"}
            ]
        )

# Usage
platform = DevPlatform(byok_api_key="sk-ant-...")
await platform.scaffold_microservice("payment-service", "Handles Stripe webhooks")

Pattern 3: CI/CD Integration

# .github/workflows/auto-fix.yml
name: Auto-fix failing tests

on:
  push:
    branches: [main]

jobs:
  auto-fix:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Run tests
        id: test
        run: npm test || echo "FAILED=true" >> $GITHUB_OUTPUT

      - name: Auto-fix with Copilot
        if: steps.test.outputs.FAILED == 'true'
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: |
          python scripts/auto_fix.py

scripts/auto_fix.py:

import os
from github_copilot_sdk import CopilotClient

client = CopilotClient(auth_token=os.getenv("GITHUB_TOKEN"))

async def fix_tests():
    response = await client.chat(
        messages=[
            {"role": "user", "content": "Tests are failing. Read test logs, identify failures, fix the code, and verify tests pass."}
        ]
    )

    print("Auto-fix result:", response.content)

if __name__ == "__main__":
    import asyncio
    asyncio.run(fix_tests())

Part VIII: FAQ

Do I need a GitHub Copilot subscription?

Standard usage: Yes, unless you use BYOK.

BYOK: No GitHub authentication required. Configure your own OpenAI/Azure/Anthropic keys.

Free tier: GitHub Copilot offers limited free usage. See pricing page.

How is billing calculated?

Each SDK chat request = 1 premium request, counted toward your GitHub Copilot quota.

BYOK: No GitHub charges. Pay your LLM provider directly.

What models are supported?

With GitHub Copilot subscription:

  • All models available via Copilot CLI

With BYOK:

  • OpenAI: gpt-4o, gpt-4-turbo, o1, o3-mini
  • Azure AI Foundry: Azure OpenAI models
  • Anthropic: claude-3-5-sonnet, claude-3-opus, claude-3-haiku

Call client.list_models() to see available models at runtime.

Is the SDK production-ready?

Yes. The SDK is generally available and follows semantic versioning. See CHANGELOG.md.

Can I use custom agents and tools?

Yes. Define custom tools and agents. See SDK documentation for your language.

Do I need to install Copilot CLI separately?

TypeScript, Python, .NET: No, CLI is bundled automatically.

Go, Rust, Java: Yes, install CLI manually or ensure copilot is in PATH. Go and Rust offer optional bundling.

How do I report issues?

Use the GitHub Issues page.


Conclusion: GitHub's Play for the Agent Economy

The Copilot SDK represents GitHub's strategic bet on the Agent Economy—a future where autonomous AI agents handle significant portions of software development workflows.

By open-sourcing production-grade orchestration, GitHub is:

  1. Democratizing agentic AI - Any app can add Copilot agents
  2. Creating ecosystem lock-in - Developers build on GitHub's platform
  3. Competing with frameworks - Alternative to LangChain, LlamaIndex, etc.
  4. Enabling BYOK - Reduces vendor lock-in, increases adoption

For developers, the value is clear:

  • Zero boilerplate - No custom orchestration needed
  • Production-tested - Millions of users trust Copilot CLI
  • Multi-language - Build in Python, TS, Go, .NET, Rust, Java
  • Flexible auth - GitHub OAuth or BYOK

Strategic implications:

If GitHub succeeds, the default way to build AI coding agents will be through the Copilot SDK—not by writing custom agent loops with LangChain or building from scratch.

This is GitHub's bid to own the agent infrastructure layer, just as they own the code hosting layer. For developers building AI-powered applications in 2026, the Copilot SDK is worth serious evaluation.


Resources

Official:

Cookbooks:

Community:

Related posts