githubcopilot

package
v0.1.108 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 25, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package githubcopilot routes requests to the GitHub Copilot API, billed against a GitHub Copilot subscription instead of a model vendor's API key.

The upstream is OpenAI-compatible but splits its models across endpoints: GPT-5 and later answer only on /responses, while Claude, Gemini, and older GPT models answer on /chat/completions. The provider learns each model's endpoints from GET /models and serves both APIs on every model, translating when the model lacks the endpoint the client called.

Index

Constants

This section is empty.

Variables

View Source
var Registration = providers.Registration{
	Type: providerType,
	New:  New,
	Discovery: providers.DiscoveryConfig{
		DefaultBaseURL: defaultBaseURL,
	},
}

Registration provides factory registration for the GitHub Copilot provider. The "github-copilot" type derives GITHUB_COPILOT_API_KEY, GITHUB_COPILOT_BASE_URL, and GITHUB_COPILOT_MODELS by convention.

Functions

func New

New creates a new GitHub Copilot provider. The API key is a GitHub OAuth token for an account with Copilot access; it is sent as-is, with no exchange for a short-lived Copilot token.

Types

type Provider

type Provider struct {
	*openai.ChatCompatible
	// contains filtered or unexported fields
}

Provider implements the core.Provider interface for GitHub Copilot. Chat completions, embeddings, and passthrough go through the shared chat-centric adapter; ChatCompletion and Responses pick the upstream endpoint per model (see endpoints.go), and normalize.go smooths over Copilot's departures from the OpenAI wire format.

func (*Provider) ChatCompletion

func (p *Provider) ChatCompletion(ctx context.Context, req *core.ChatRequest) (*core.ChatResponse, error)

ChatCompletion sends the request to /chat/completions, or through the Responses API for a model Copilot serves only there.

func (*Provider) Embeddings

Embeddings sends the request to /embeddings. Copilot rejects a bare string input with a 400, so it is wrapped into the one-element list OpenAI treats it as, and the reply gets the list object type Copilot omits.

func (*Provider) ListModels

func (p *Provider) ListModels(ctx context.Context) (*core.ModelsResponse, error)

ListModels returns the models the account may call. A model whose policy is "disabled" is listed by Copilot but rejected on use until the account (or its organization) enables it in the Copilot settings, so it is left out. The listing also refreshes the per-model endpoint routes.

func (*Provider) Responses

Responses forwards the request to /responses for a model Copilot serves there, and translates it to chat completions otherwise.

func (*Provider) StreamChatCompletion

func (p *Provider) StreamChatCompletion(ctx context.Context, req *core.ChatRequest) (io.ReadCloser, error)

StreamChatCompletion is ChatCompletion for streaming requests.

func (*Provider) StreamResponses

func (p *Provider) StreamResponses(ctx context.Context, req *core.ResponsesRequest) (io.ReadCloser, error)

StreamResponses is Responses for streaming requests.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL