Skip to content

shyamsridhar123/ClaudeCode-Copilot-Proxy

Repository files navigation

GitHub Copilot Proxy for Claude Code & Cursor IDE

License: MIT TypeScript Node.js Conventional Commits

⚠️ Disclaimer: This project is for educational purposes only. It is intended to demonstrate API proxy patterns and OAuth device flow authentication. Use at your own risk and ensure compliance with GitHub Copilot's Terms of Service.

A proxy server that enables Claude Code and Cursor IDE to use GitHub Copilot's AI models instead of direct API access. Use your GitHub Copilot subscription to access Claude models (Opus 4.5, Sonnet 4.5, Haiku 4.5) in Claude Code, or GPT models in Cursor IDE.

πŸš€ Features

  • Anthropic API Compatibility: Implements the Anthropic Messages API for Claude Code
  • OpenAI API Compatibility: Implements the OpenAI API format for Cursor IDE
  • Claude Model Support: Access Claude Opus 4.5, Sonnet 4.5, and Haiku 4.5 via Copilot
  • GitHub Copilot Integration: Connects to GitHub Copilot's backend services
  • Seamless Authentication: Handles GitHub OAuth device flow authentication
  • Token Management: Automatically refreshes Copilot tokens
  • Streaming Support: Supports both streaming and non-streaming completions
  • Easy Configuration: Simple setup with Claude Code or Cursor IDE

πŸ“‹ Prerequisites

  • Node.js 18.0 or higher
  • GitHub Copilot subscription (with access to Claude models)
  • Claude Code or Cursor IDE

πŸ”§ Installation

Option A: Quick Install (Recommended)

npm install -g claudecode-copilot-proxy
claudecode-copilot-proxy

That's it! The server will start at http://localhost:3000

Option B: From Source

  1. Clone the repository:

    git clone https://github.com/shyamsridhar123/ClaudeCode-Copilot-Proxy.git
    cd ClaudeCode-Copilot-Proxy
  2. Install dependencies:

    npm install
  3. Build the project:

    npm run build
  4. Start the proxy server:

    npm start

πŸ€– Configuration with Claude Code

  1. Start the proxy server:

    npm start

    You should see the authentication portal at http://localhost:3000

  2. Complete GitHub authentication by pasting your auth code in the browser

  3. Configure Claude Code to use the proxy by adding environment variables to your settings file:

    Option A: Project-specific configuration (recommended)

    Add to .claude/settings.local.json in your project:

    {
      "env": {
        "ANTHROPIC_BASE_URL": "http://localhost:3000",
        "ANTHROPIC_AUTH_TOKEN": "sk-dummy",
        "DISABLE_NON_ESSENTIAL_MODEL_CALLS": "1",
        "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1"
      }
    }

    Option B: Global configuration

    Add to ~/.claude/settings.json:

    {
      "env": {
        "ANTHROPIC_BASE_URL": "http://localhost:3000",
        "ANTHROPIC_AUTH_TOKEN": "sk-dummy",
        "DISABLE_NON_ESSENTIAL_MODEL_CALLS": "1",
        "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1"
      }
    }
  4. Enter claude in your terminal to start Claude Code with the proxy

How to Verify It's Working

βœ… Server logs show 200 responses: Look for POST /v1/messages - 200 in the server output

βœ… Token usage is tracked: You'll see Tracked request for session ... +XX tokens

βœ… Model being used: Shows "model": "claude-opus-4.5" or "claude-sonnet-4.5"

βœ… Claude Code gets responses: Your commands should complete without errors

βœ… Usage stats: Check http://localhost:3000/usage.html in your browser to see how many tokens you've used

Supported Models

Model Description
claude-opus-4.5 Claude Opus 4.5 (Default)
claude-sonnet-4.5 Claude Sonnet 4.5
claude-haiku-4.5 Claude Haiku 4.5

Optional: Use Other Models

The proxy also supports GPT and Gemini models available in GitHub Copilot. To use them, add ANTHROPIC_MODEL to your settings:

{
  "env": {
    "ANTHROPIC_BASE_URL": "http://localhost:3000",
    "ANTHROPIC_AUTH_TOKEN": "sk-dummy",
    "ANTHROPIC_MODEL": "gpt-5.2",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "gemini-3-pro-preview",
    "DISABLE_NON_ESSENTIAL_MODEL_CALLS": "1",
    "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1"
  }
}
Model Description
gpt-5.2 GPT 5.2
gemini-3-pro-preview Gemini 3 Pro Preview

πŸ”Œ Configuration with Cursor IDE

  1. Open Cursor IDE
  2. Go to Settings > API Keys
  3. In the "Override OpenAI Base URL" section, enter:
    http://localhost:3000
    
  4. Go to http://localhost:3000 in your browser
  5. Follow the authentication steps to connect to GitHub

πŸ’‘ Usage

Once configured, you can use Cursor IDE as normal. All AI-powered features will now use your GitHub Copilot subscription instead of Cursor's API.

To switch back to Cursor's API:

  1. Go to Settings > API Keys
  2. Remove the Override OpenAI Base URL

πŸ€” How It Works

For Claude Code (Anthropic API)

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Claude Code   │────▢│   Copilot Proxy Server   │────▢│  GitHub Copilot API β”‚
β”‚  (Anthropic API β”‚     β”‚                          β”‚     β”‚  (Anthropic Models) β”‚
β”‚     format)     β”‚     β”‚  - Auth (OAuth device)   β”‚     β”‚  - claude-opus-4.5   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β”‚  - Request translation   β”‚     β”‚  - claude-sonnet-4.5 β”‚
                        β”‚  - Response translation  β”‚     β”‚  - claude-haiku-4.5  β”‚
                        β”‚  - Streaming support     β”‚     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
  1. The proxy authenticates with GitHub using the OAuth device flow
  2. GitHub provides a token that the proxy uses to obtain a Copilot token
  3. Claude Code sends requests to the proxy in Anthropic format (/v1/messages)
  4. The proxy forwards requests to GitHub Copilot's Anthropic model endpoints
  5. Responses are returned in Anthropic format with streaming support

For Cursor IDE (OpenAI API)

  1. The proxy authenticates with GitHub using the OAuth device flow
  2. GitHub provides a token that the proxy uses to obtain a Copilot token
  3. Cursor sends requests to the proxy in OpenAI format
  4. The proxy converts these requests to GitHub Copilot's format
  5. The proxy forwards responses back to Cursor in OpenAI format

πŸ› οΈ Development

Running in development mode:

npm run dev

Testing:

npm test

Linting:

npm run lint

πŸ“„ License

MIT License

Copyright (c) 2025

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

See the LICENSE file for details.

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes using conventional commits (git commit -m 'feat: add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

About

Proxy server enabling Claude Code to work seamlessly with GitHub Copilot. Bridges AI coding assistants for enhanced developer experience.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors