Registry / llm-agents / copilot-api

copilot-api

JSON →
library1.0.0jsnpmunverified

copilot-api transforms GitHub Copilot into an API-compatible server that mimics OpenAI and Anthropic interfaces, making Copilot's capabilities accessible to applications designed for these popular LLM APIs. This allows tools like Claude Code to leverage GitHub Copilot directly. The package is currently at version 0.7.0 and receives frequent updates, often with minor feature additions and bug fixes, as seen in recent patch and minor releases. Its key differentiator is bridging GitHub Copilot's proprietary access with standard API formats, offering flexibility for developers who want to integrate Copilot into existing LLM toolchains without vendor lock-in to GitHub's specific integration methods. It runs as a standalone server, typically invoked via `npx`.

npm install copilot-api
INSTALL
IMPORT
SIG · COPILOT-API
C
copilot-api
llm-agentsjavascriptv1.0.0
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

startServer
✓ import { startServer } from 'copilot-api'
✗ const { startServer } = require('copilot-api')
This package is primarily a CLI tool. Programmatic usage via 'startServer' is for embedding the server within another application. It is an ESM-only package.
CopilotApiConfig
✓ import type { CopilotApiConfig } from 'copilot-api'
✗ import { CopilotApiConfig } from 'copilot-api'
Type import for configuring the Copilot API server programmatically. While 'import { ... }' also works, 'import type' is preferred for clarity and bundle optimization.
default
✓ (No default export)
✗ import CopilotApi from 'copilot-api'
The 'copilot-api' package does not provide a default export. Use named imports for specific programmatic components or rely on the 'npx copilot-api' CLI for standard operation.

Demonstrates how to programmatically start the Copilot API server within a Node.js application, allowing for custom configuration beyond CLI arguments and illustrating basic setup.

import { startServer } from 'copilot-api'; import { fileURLToPath } from 'url'; import path from 'path'; // ESM equivalent of __dirname const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); async function runCopilotApiServer() { const config = { port: 3000, host: '0.0.0.0', // Example: Pass a custom path to a session token file if needed // copilotTokenPath: path.join(__dirname, 'copilot_session.json'), // As of v0.7.0, proxy environment variables require explicit enabling: // useProxyEnv: true, // Corresponds to --proxy-env CLI flag // Enable Claude Code specific environment variables: // enableClaudeCode: true, // Corresponds to --claude-code CLI flag }; console.log('Starting Copilot API server programmatically...'); try { await startServer(config); console.log(`Copilot API server listening on http://${config.host}:${config.port}`); console.log('Use Ctrl+C to stop the server.'); } catch (error) { console.error('Failed to start Copilot API server:', error); process.exit(1); } } runCopilotApiServer();
Debug
Known issues
breakingProxy environment variables (e.g., HTTP_PROXY, HTTPS_PROXY) are no longer automatically initialized or detected by the server by default.
fix
To enable proxy support from environment variables, you must explicitly use the `--proxy-env` flag when starting the server via CLI (e.g., `npx copilot-api start --proxy-env`) or set `useProxyEnv: true` in programmatic configurations.
affects: >=0.7.0
gotchaThis package is an ECMAScript Module (ESM) and does not support direct `require()` calls from CommonJS environments.
fix
Ensure your project is configured for ESM (e.g., by setting `"type": "module"` in `package.json` or using `.mjs` file extensions) and use `import` statements for programmatic access.
affects: >=0.1.0
gotchaThe `copilot-api` server relies on a locally authenticated GitHub Copilot session to function. It does not handle Copilot authentication itself.
fix
Verify that GitHub Copilot is installed and logged in on the machine running the `copilot-api` server. This typically involves having VS Code with the Copilot extension or the GitHub CLI with Copilot features enabled and authenticated.
affects: All versions
Errors
Common errors & fixes
ReferenceError: require is not defined in ES module scope
Attempting to import `copilot-api` using CommonJS `require()` syntax in an ESM project or a JavaScript file without `"type": "module"`.
fix
Switch to ES module `import` syntax (e.g., `import { startServer } from 'copilot-api'`) and ensure your Node.js project or file is configured for ESM.
Proxy settings are not working/applied when running copilot-api.
Since v0.7.0, proxy environment variables (`HTTP_PROXY`, `HTTPS_PROXY`) are no longer automatically enabled.
fix
Restart the `copilot-api` server with the `--proxy-env` flag (e.g., `npx copilot-api@latest start --proxy-env`) or ensure `useProxyEnv: true` is passed in programmatic configurations.
Error: Could not get Copilot token. Please make sure Copilot is running and logged in.
The `copilot-api` server failed to establish communication with or retrieve an authentication token from a valid GitHub Copilot instance.
fix
Ensure that GitHub Copilot is actively running and authenticated on your system (e.g., via VS Code or GitHub CLI) before starting the `copilot-api` server.
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
23 hits · last 30 days
node
20
OpenAI (training)
1
Resources
copilot-api — npm install copilot-api · libregistry