Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 69 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,17 @@ A proxy server that enables **Claude Code** and **Cursor IDE** to use GitHub Cop

## 🔧 Installation

### Option A: Quick Install (Recommended)

```bash
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:
```bash
git clone https://github.com/shyamsridhar123/ClaudeCode-Copilot-Proxy.git
Expand All @@ -39,17 +50,12 @@ A proxy server that enables **Claude Code** and **Cursor IDE** to use GitHub Cop
npm install
```

3. Create a `.env` file:
```bash
cp .env.example .env
```

4. Build the project:
3. Build the project:
```bash
npm run build
```

5. Start the proxy server:
4. Start the proxy server:
```bash
npm start
```
Expand All @@ -64,16 +70,37 @@ A proxy server that enables **Claude Code** and **Cursor IDE** to use GitHub Cop

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

3. Enter `claude` in your terminal to start Claude Code

4. Configure Claude Code to use the proxy:
```bash
claude config set api_base_url http://localhost:3000
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:
```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"
}
}
```

5. Press `Ctrl+C` twice to quit Claude
**Option B: Global configuration**

Add to `~/.claude/settings.json`:
```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"
}
}
```

6. Enter `claude` again to restart with the new configuration
4. Enter `claude` in your terminal to start Claude Code with the proxy

### How to Verify It's Working

Expand All @@ -87,13 +114,35 @@ A proxy server that enables **Claude Code** and **Cursor IDE** to use GitHub Cop

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

### Supported Claude Models
### 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:

```json
{
"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 | Copilot Model |
|-------|---------------|
| `claude-opus-4-5-20250514` | Claude Opus 4.5 |
| `claude-sonnet-4-5-20250514` | Claude Sonnet 4.5 |
| `claude-haiku-4-5-20250514` | Claude Haiku 4.5 |
| Model | Description |
|-------|-------------|
| `gpt-5.2` | GPT 5.2 |
| `gemini-3-pro-preview` | Gemini 3 Pro Preview |

## 🔌 Configuration with Cursor IDE

Expand Down
59 changes: 59 additions & 0 deletions bin/claudecode-copilot-proxy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/usr/bin/env node

/**
* CLI entry point for claudecode-copilot-proxy
* Usage: claudecode-copilot-proxy [start|--help|--version]
*/

import { fileURLToPath } from 'url';
import { dirname, join } from 'path';
import { readFileSync } from 'fs';

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);

const args = process.argv.slice(2);
const command = args[0] || 'start';

// Read package.json for version
const packageJsonPath = join(__dirname, '..', 'package.json');
const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8'));

if (command === '--version' || command === '-v') {
console.log(`claudecode-copilot-proxy v${packageJson.version}`);
process.exit(0);
}

if (command === '--help' || command === '-h') {
console.log(`
claudecode-copilot-proxy v${packageJson.version}

A proxy server that enables Claude Code and Cursor IDE to use GitHub Copilot's AI models.

Usage:
claudecode-copilot-proxy [command]

Commands:
start Start the proxy server (default)
--version Show version number
--help Show this help message

Configuration:
PORT Server port (default: 3000)

Example:
claudecode-copilot-proxy start
PORT=8080 claudecode-copilot-proxy

After starting, visit http://localhost:3000 to authenticate with GitHub.

Documentation: ${packageJson.homepage}
`);
process.exit(0);
}

if (command === 'start' || !command.startsWith('-')) {
// Import and start the server
const serverPath = join(__dirname, '..', 'dist', 'index.js');
await import(serverPath);
}
10 changes: 10 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 10 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
{
"name": "github-copilot-proxy",
"name": "claudecode-copilot-proxy",
"version": "0.1.0",
"description": "Proxy server that lets Cursor IDE use GitHub Copilot APIs",
"description": "Proxy server that lets Claude Code and Cursor IDE use GitHub Copilot APIs",
"main": "dist/index.js",
"bin": {
"claudecode-copilot-proxy": "./bin/claudecode-copilot-proxy.js"
},
"files": [
"dist",
"bin"
],
"scripts": {
"build": "tsc && npm run copy-assets",
"copy-assets": "node -e \"require('fs').cpSync('src/public', 'dist/public', {recursive: true})\"",
Expand Down Expand Up @@ -66,4 +73,4 @@
"engines": {
"node": ">=18.0.0"
}
}
}
37 changes: 21 additions & 16 deletions src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,44 +41,49 @@ const ANTHROPIC_API_ENDPOINTS = {
};

// Claude model mappings: Claude Code model names -> Copilot model names
// Uses prefix matching, so 'claude-opus-4-5' matches 'claude-opus-4-5-20251001' etc.
export const CLAUDE_MODEL_MAPPINGS: Record<string, string> = {
// Claude Opus 4.5 (default - latest flagship)
'claude-opus-4-5-20250514': 'claude-opus-4.5',
'claude-opus-4.5': 'claude-opus-4.5',
// Claude Opus 4.5
'claude-opus-4-5': 'claude-opus-4.5',
'opus': 'claude-opus-4.5',

// Claude Sonnet 4.5
'claude-sonnet-4-5-20250514': 'claude-sonnet-4.5',
'claude-sonnet-4.5': 'claude-sonnet-4.5',
'claude-sonnet-4-20250514': 'claude-sonnet-4.5',
'claude-sonnet-4': 'claude-sonnet-4.5',
'claude-sonnet-4-5': 'claude-sonnet-4.5',
'sonnet': 'claude-sonnet-4.5',

// Claude Haiku 4.5
'claude-haiku-4-5-20250514': 'claude-haiku-4.5',
'claude-haiku-4.5': 'claude-haiku-4.5',
'claude-3-5-haiku-20241022': 'claude-haiku-4.5',
'claude-3.5-haiku': 'claude-haiku-4.5',
'claude-haiku-4-5': 'claude-haiku-4.5',
'haiku': 'claude-haiku-4.5',
};

// Available Claude models via Copilot (Opus 4.5 is default)
export const AVAILABLE_CLAUDE_MODELS = [
{
id: 'claude-opus-4-5-20250514',
id: 'claude-opus-4-5',
display_name: 'Claude Opus 4.5 (Default)',
copilot_model: 'claude-opus-4.5',
},
{
id: 'claude-sonnet-4-5-20250514',
id: 'claude-sonnet-4-5',
display_name: 'Claude Sonnet 4.5',
copilot_model: 'claude-sonnet-4.5',
},
{
id: 'claude-haiku-4-5-20250514',
id: 'claude-haiku-4-5',
display_name: 'Claude Haiku 4.5',
copilot_model: 'claude-haiku-4.5',
},
// Optional: GPT and Gemini models (pass-through, user must specify in settings)
{
id: 'gpt-5.2',
display_name: 'GPT 5.2 (Optional)',
copilot_model: 'gpt-5.2',
},
{
id: 'gemini-3-pro-preview',
display_name: 'Gemini 3 Pro Preview (Optional)',
copilot_model: 'gemini-3-pro-preview',
},
];

// Configuration object
Expand Down
Loading
Loading