A module used for interacting with the GitHub Copilot API.
npm install @vscode/copilot-apiA module used for interacting with the GitHub Copilot API.
With npm:
``bash`
npm install @vscode/copilot-api
With yarn:
`bash`
yarn add @vscode/copilot-api
`javascript
import { CAPIClient, RequestType } from '@vscode/copilot-api';
// Create a new client instance
const client = new CAPIClient(editorDetails, license, optionalFetcherService);
// Update domains (if needed)
const domainChanges = client.updateDomains(copilotToken, enterpriseUrlConfig);
// Make requests
const response = await client.makeRequest(fetchOptions, RequestType.ChatCompletions);
`
- RequestType.CopilotToken - Get Copilot tokenRequestType.ChatCompletions
- - Chat completionsRequestType.RemoteAgent
- - Remote agent requestsRequestType.Embeddings
- - EmbeddingsRequestType.Models
- - Available modelsRequestType.CCAModelsList
- - Get available models for Copilot coding agentRequestType.Chunks
- - Code chunksRequestType.EmbeddingsCodeSearch
- - Embeddings code searchRequestType.ListSkills
- - List available skillsRequestType.SearchSkill
- - Search skillsRequestType.ContentExclusion
- - Content exclusionRequestType.Telemetry
- - TelemetryRequestType.CopilotUserInfo
- - User infoRequestType.OriginTracker
- - Origin tracking
The package is built using esbuild to create a single platform-neutral ESM module that works in both Node.js and web environments:
`bashBuild for production (minified)
npm run build
$3
-
dist/index.js - Platform-neutral ESM build
- dist/index.d.ts - TypeScript declarations$3
The package is configured with a simplified ESM export structure:
`json
{
"exports": {
"import": "./dist/index.js",
"types": "./dist/index.d.ts"
}
}
`Testing
This project uses Vitest for testing. Run tests with:
`bash
Run tests once
npm testRun tests in watch mode
npm run test:watch
``