DevTools 2 March 2026 8 min read

Claude Code with Opus & Sonnet 4.6 via GitHub Copilot

Unlock Claude Code with Anthropic's latest Opus 4.6 and Sonnet 4.6 models by routing through GitHub Copilot's API — a practical guide to leveraging enterprise Copilot licenses for cutting-edge AI coding assistance.

Claude CodeGitHub CopilotOpus 4.6Sonnet 4.6AI ToolsEnterpriseConfiguration

Value Proposition

Access Anthropic’s latest Claude Opus 4.6 and Sonnet 4.6 models through Claude Code by routing requests via GitHub Copilot’s API infrastructure. This approach leverages your existing GitHub Copilot enterprise license to use the most advanced Claude models for coding assistance.


Prerequisites

Before setting up Claude Code with GitHub Copilot models, ensure you have:

  1. Claude Code Setup: Complete the comprehensive Claude Code setup guide (Enterprise LLM Setup)
  2. GitHub Copilot License: Active GitHub Copilot enterprise license
  3. Copilot Refresh Token: Captured authentication token from your GitHub Copilot session

Understanding the Integration

Similar to using other CLI tools with GPT models against GitHub Copilot, Claude Code can communicate with Anthropic models (Opus 4.6, Sonnet 4.6, and Haiku 4.5) through GitHub Copilot’s API endpoint at api.business.githubcopilot.com.

The key to making this work is passing specific custom headers that authenticate Claude Code as a valid GitHub Copilot client.


Configuration

Shell Function Setup

Add the following function to your shell configuration file:

macOS/Linux (~/.zshrc or ~/.bashrc):

claude_ghcopilot() { # Opus 4.6, Sonnet 4.6 and Haiku 4.5
    if [[ $# -gt 0 ]]; then command claude "$@"; return; fi
    export ANTHROPIC_AUTH_TOKEN="$GITHUB_TOKEN"
    export ANTHROPIC_BASE_URL="https://api.business.githubcopilot.com"
    export ANTHROPIC_DEFAULT_HAIKU_MODEL='claude-haiku-4.5'
    export ANTHROPIC_DEFAULT_SONNET_MODEL='claude-sonnet-4.6'
    export ANTHROPIC_DEFAULT_OPUS_MODEL="claude-opus-4.6"
    export CLAUDE_CODE_SUBAGENT_MODEL="$ANTHROPIC_DEFAULT_HAIKU_MODEL"
    export ANTHROPIC_MODEL="$ANTHROPIC_DEFAULT_SONNET_MODEL"
    export ANTHROPIC_CUSTOM_HEADERS=$'user-agent: GitHubCopilotChat/0.37.6\nEditor-Plugin-Name: copilot.vscode\nEditor-Plugin-Version: copilot-chat/0.37.6\nEditor-Version: vscode/1.109.3\ncopilot-integration-id: vscode-chat\nopenai-intent: conversation-agent\noriginator: \nx-github-api-version: 2025-10-01\nx-initiator: user\nx-interaction-type: conversation-agent\nx-vscode-user-agent-library-version: electron-fetch'
    echo "✓ Claude switched to Github Copilot models..."
    command claude --dangerously-skip-permissions
}
alias claude=claude_ghcopilot

Windows (PowerShell):

function claude_ghcopilot {
    if ($args.Count -gt 0) {
        & claude $args
        return
    }
    $env:ANTHROPIC_AUTH_TOKEN = $env:GITHUB_TOKEN
    $env:ANTHROPIC_BASE_URL = "https://api.business.githubcopilot.com"
    $env:ANTHROPIC_DEFAULT_HAIKU_MODEL = 'claude-haiku-4.5'
    $env:ANTHROPIC_DEFAULT_SONNET_MODEL = 'claude-sonnet-4.6'
    $env:ANTHROPIC_DEFAULT_OPUS_MODEL = "claude-opus-4.6"
    $env:CLAUDE_CODE_SUBAGENT_MODEL = $env:ANTHROPIC_DEFAULT_HAIKU_MODEL
    $env:ANTHROPIC_MODEL = $env:ANTHROPIC_DEFAULT_SONNET_MODEL
    $env:ANTHROPIC_CUSTOM_HEADERS = "user-agent: GitHubCopilotChat/0.37.6`nEditor-Plugin-Name: copilot.vscode`nEditor-Plugin-Version: copilot-chat/0.37.6`nEditor-Version: vscode/1.109.3`ncopilot-integration-id: vscode-chat`nopenai-intent: conversation-agent`noriginator: `nx-github-api-version: 2025-10-01`nx-initiator: user`nx-interaction-type: conversation-agent`nx-vscode-user-agent-library-version: electron-fetch"
    Write-Host "✓ Claude switched to Github Copilot models..." -ForegroundColor Green
    & claude --dangerously-skip-permissions
}
Set-Alias -Name claude -Value claude_ghcopilot

How It Works

Authentication

The configuration sets ANTHROPIC_AUTH_TOKEN to your GitHub token, which authenticates you with GitHub Copilot’s API infrastructure.

Custom Headers

The critical component is ANTHROPIC_CUSTOM_HEADERS, which includes:

  • User-Agent headers: Identifies the client as VS Code with GitHub Copilot extension
  • Editor metadata: Version information for VS Code and Copilot plugin
  • Integration identifiers: Marks the request as coming from a legitimate Copilot integration
  • API version: Specifies the GitHub Copilot API version

These headers convince GitHub Copilot’s API that Claude Code is a valid client, allowing it to proxy requests to Anthropic’s models.

Model Selection

The configuration provides access to:

  • Claude Opus 4.6: The most capable model (claude-opus-4.6)
  • Claude Sonnet 4.6: Balanced performance and speed (claude-sonnet-4.6)
  • Claude Haiku 4.5: Fast responses for simple tasks (claude-haiku-4.5)

Usage

After adding the configuration to your shell profile and reloading it (source ~/.zshrc or restarting your terminal), simply run:

claude

You’ll see the confirmation message:

✓ Claude switched to Github Copilot models...

Claude Code will now use:

  • Sonnet 4.6 as the default model for chat
  • Haiku 4.5 for subagent tasks (faster background operations)
  • Opus 4.6 available when you need maximum capability

Cost Optimization

Optional: Copilot Session Token

For additional cost optimization, you can add a copilot_session_token header to get a 10% discount on Haiku 4.5 or Sonnet 4.5 usage. However, note that:

  • Sonnet 4.6 and Opus 4.6 are not eligible for this discount
  • The token must be refreshed periodically
  • Implementation requires capturing the session token from an active Copilot session

This optimization is similar to techniques used with other Copilot-proxied tools.


Considerations

Credit Usage

Using Opus 4.6 and Sonnet 4.6 can consume GitHub Copilot credits rapidly. These are premium models with significantly higher token costs compared to standard Copilot models.

Monitor your usage carefully, especially when:

  • Processing large codebases
  • Using Opus 4.6 for complex reasoning tasks
  • Running multiple concurrent sessions

Enterprise Policies

Before implementing this configuration, verify that:

  • Your organization’s GitHub Copilot policy allows API access
  • Using alternative models via Copilot is within acceptable use guidelines
  • Your team’s Copilot allocation can accommodate the increased usage

Security

The configuration uses --dangerously-skip-permissions to bypass Claude Code’s permission prompts. In enterprise environments:

  • Consider the security implications of auto-accepting permissions
  • Review what Claude Code will access in your workspace
  • Implement appropriate access controls at the organizational level

Troubleshooting

Authentication Failures

If you encounter authentication errors:

  1. Verify your GITHUB_TOKEN is valid and current
  2. Check that your Copilot license is active
  3. Ensure the token has appropriate scopes for Copilot API access

Connection Issues

If Claude Code can’t reach the API:

  1. Verify the base URL is correct: https://api.business.githubcopilot.com
  2. Check corporate proxy settings aren’t interfering
  3. Ensure custom CA certificates are configured if required (see Enterprise LLM Setup)

Model Not Available

If specific models return errors:

  1. Confirm your Copilot license tier supports these models
  2. Check GitHub’s Copilot model availability updates
  3. Verify the model names match the current API specifications

Conclusion

Routing Claude Code through GitHub Copilot’s API provides access to Anthropic’s latest and most capable models while leveraging your existing enterprise infrastructure. This approach combines the power of Opus 4.6 and Sonnet 4.6 with the convenience of GitHub Copilot’s enterprise authentication and billing.

Just remember: with great power comes great credit consumption. Use wisely, monitor your usage, and enjoy the cutting edge of AI-assisted development.