A module used for interacting with the GitHub Copilot API.
Installation
With npm:
npm install @vscode/copilot-api
With yarn:
yarn add @vscode/copilot-api
Usage
Basic Setup
import { CAPIClient, RequestType } from '@vscode/copilot-api';
const client = new CAPIClient(editorDetails, license, optionalFetcherService);
const domainChanges = client.updateDomains(copilotToken, enterpriseUrlConfig);
const response = await client.makeRequest(fetchOptions, RequestType.ChatCompletions);
Available Request Types
RequestType.CopilotToken - Get Copilot token
RequestType.ChatCompletions - Chat completions
RequestType.RemoteAgent - Remote agent requests
RequestType.Embeddings - Embeddings
RequestType.Models - Available models
RequestType.Chunks - Code chunks
RequestType.EmbeddingsCodeSearch - Embeddings code search
RequestType.ListSkills - List available skills
RequestType.SearchSkill - Search skills
RequestType.ContentExclusion - Content exclusion
RequestType.Telemetry - Telemetry
RequestType.CopilotUserInfo - User info
RequestType.OriginTracker - Origin tracking
Development
Building
The package is built using esbuild to create a single platform-neutral ESM module that works in both Node.js and web environments:
npm run build
npm run build:dev
npm run clean
Build Output
dist/index.js - Platform-neutral ESM build
dist/index.d.ts - TypeScript declarations
Package Exports
The package is configured with a simplified ESM export structure:
{
"exports": {
"import": "./dist/index.js",
"types": "./dist/index.d.ts"
}
}
Testing
This project uses Vitest for testing. Run tests with:
npm test
npm run test:watch