This repository has been archived on 2026-08-16. You can view files and clone it, but cannot push or open issues or pull requests.
ollie-core/internal/backend/copilot.go

21 lines
629 B
Go

package backend
import "net/http"
// NewCopilot returns an OpenAI-compatible backend configured for the GitHub
// Copilot chat completions API. token is a short-lived Copilot bearer token.
//
// The required Copilot-specific headers (Openai-Intent, User-Agent) are
// injected on every request via the OpenAIBackend's extraHeaders mechanism.
func NewCopilot(token string) *OpenAIBackend {
return &OpenAIBackend{
baseURL: "https://api.githubcopilot.com",
apiKey: token,
client: &http.Client{},
extraHeaders: map[string]string{
"Openai-Intent": "conversation-edits",
"User-Agent": "opencode/local",
},
}
}