Skip to content

CopilotAdapter

Category: Providers

Source: copilot_adapter.dart

Adapter for GitHub Copilot using OAuth 2.0 device authorization + a periodically-refreshed short-lived Copilot bearer token.

Endpoints (all public; same client id as the Copilot CLI / LiteLLM):

  • github.com/login/device/code — start device flow
  • github.com/login/oauth/access_token — poll for user approval
  • api.github.com/copilot_internal/v2/token— exchange → Copilot bearer
  • api.githubcopilot.com/chat/completions — OpenAI-compatible inference

Classes

CopilotAdapter

Constructor

dart
CopilotAdapter({
    http.Client? client,
    CredentialStore? credentialStore,
    this._requestClientFactory,
  })

Properties

PropertyTypeDescription
adapterIdString get
deviceCodeString
userCodeString
verificationUriString
intervalDuration
expiresInDuration
storeCredentialStore
modelString
systemPromptString
baseUrlString
adapterIdString get

Methods

ProviderHealth validate(ResolvedProvider provider)
bool isConnected(ProviderDef provider, CredentialStore store)
`LlmClient createClient({
required ResolvedProvider provider,
required ResolvedModel model,
required String systemPrompt,

})`

`Future<AuthFlow?> beginInteractiveAuth({
required ProviderDef provider,
required CredentialStore store,

})`

Stream&lt;LlmChunk&gt; stream(List&lt;Message&gt; messages, {List&lt;Tool&gt;? tools})

Released under the MIT License.