npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@dianshuv/copilot-api

v0.4.1

Published

Turn GitHub Copilot into OpenAI/Anthropic API compatible server. Usable with Claude Code!

Readme

Copilot API Proxy (Fork)

[!NOTE] This is a fork of @hsupu/copilot-api, which itself is a fork of ericc-ch/copilot-api, with additional improvements and bug fixes.

[!WARNING] This is a reverse-engineered proxy of GitHub Copilot API. It is not supported by GitHub, and may break unexpectedly. Use at your own risk.

New Features (over @hsupu/copilot-api)

  • Responses API endpoint: /v1/responses passthrough for codex models (e.g., gpt-5.2-codex, gpt-5.3-codex) used by tools like OpenCode. Includes stream ID synchronization for @ai-sdk/openai compatibility.
  • SubagentStart marker support: Detects __SUBAGENT_MARKER__ injected by Claude Code hooks to override X-Initiator header to "agent" for subagent requests, ensuring correct credit tier usage. Includes a ready-to-use Claude plugin (claude-plugin/).
  • Token analytics tab: The /history page includes a Tokens tab with per-model token usage summary table and cumulative ECharts line chart for visualizing API consumption over time.
  • Real-time history updates: The /history UI uses WebSocket for live updates instead of polling, with automatic fallback to polling and exponential backoff reconnection.
  • Graceful shutdown: 4-phase shutdown sequence — stops accepting requests, waits for in-flight requests to complete, sends abort signal, then force-closes. Configurable via --shutdown-graceful-wait and --shutdown-abort-wait.
  • Stream repetition detection: Detects when models get stuck in repetitive output loops using KMP-based pattern matching and logs a warning.
  • Stale request reaping: Automatically force-fails requests that exceed a configurable maximum age (default 600s) to prevent resource leaks.

Quick Start

Install from npm (Recommended)

# Run directly with npx
npx @dianshuv/copilot-api start

# Or install globally
npm install -g @dianshuv/copilot-api
copilot-api start

Command Reference

| Command | Description | |---------|-------------| | start | Start the API server (handles auth if needed) | | auth | Run GitHub authentication flow only | | logout | Remove stored GitHub token | | check-usage | Show Copilot usage and quota | | debug | Display diagnostic information | | patch-claude | Patch Claude Code's context window limit |

Start Command Options

| Option | Description | Default | |--------|-------------|---------| | --port, -p | Port to listen on | 4141 | | --host, -H | Host/interface to bind to | (all interfaces) | | --verbose, -v | Enable verbose logging | false | | --account-type, -a | Account type (individual, business, enterprise) | individual | | --manual | Manual request approval mode | false | | --no-rate-limit | Disable adaptive rate limiting | false | | --retry-interval | Seconds to wait before retrying after rate limit | 10 | | --request-interval | Seconds between requests in rate-limited mode | 10 | | --recovery-timeout | Minutes before attempting recovery | 10 | | --consecutive-successes | Successes needed to exit rate-limited mode | 5 | | --github-token, -g | Provide GitHub token directly | none | | --claude-code, -c | Generate Claude Code launch command | false | | --show-token | Show tokens on fetch/refresh | false | | --proxy-env | Use proxy from environment | false | | --no-history | Disable request history UI at /history | false | | --history-limit | Max history entries in memory | 1000 | | --no-auto-truncate | Disable auto-truncate when exceeding limits | false | | --compress-tool-results | Compress old tool results before truncating | false | | --redirect-anthropic | Force Anthropic through OpenAI translation | false | | --no-rewrite-anthropic-tools | Don't rewrite server-side tools | false |

Patch-Claude Command Options

| Option | Description | Default | |--------|-------------|---------| | --limit, -l | Context window limit in tokens | 128000 | | --restore, -r | Restore original 200k limit | false | | --path, -p | Path to Claude Code cli.js | auto-detect | | --status, -s | Show current patch status | false |

API Endpoints

OpenAI Compatible

| Endpoint | Method | Description | |----------|--------|-------------| | /v1/chat/completions | POST | Chat completions | | /v1/models | GET | List available models | | /v1/embeddings | POST | Text embeddings | | /v1/responses | POST | Responses API (for codex models) |

Anthropic Compatible

| Endpoint | Method | Description | |----------|--------|-------------| | /v1/messages | POST | Messages API | | /v1/messages/count_tokens | POST | Token counting | | /v1/event_logging/batch | POST | Event logging (no-op) |

Utility

| Endpoint | Method | Description | |----------|--------|-------------| | / | GET | Server status | | /usage | GET | Copilot usage stats | | /token | GET | Current Copilot token | | /health | GET | Health check | | /history | GET | Request history Web UI with token analytics (enabled by default) | | /history/api/* | GET/DELETE | History API endpoints |

Using with Claude Code

Create .claude/settings.json in your project:

{
  "env": {
    "ANTHROPIC_BASE_URL": "http://localhost:4141",
    "ANTHROPIC_AUTH_TOKEN": "dummy",
    "ANTHROPIC_MODEL": "gpt-4.1",
    "ANTHROPIC_SMALL_FAST_MODEL": "gpt-4.1",
    "DISABLE_NON_ESSENTIAL_MODEL_CALLS": "1",
    "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1"
  },
  "permissions": {
    "deny": ["WebSearch"]
  }
}

Or use the interactive setup:

bun run start --claude-code

Upstream Project

For the original project documentation, features, and updates, see: ericc-ch/copilot-api