ollie/cmd/olliesrv/internal/backend/copilot.go

23 lines
616 B
Go

package backend
import (
"net/url"
)
// NewCopilot returns an OpenAI-compatible backend configured for the GitHub
// Copilot chat completions API. token is a short-lived Copilot bearer token.
func NewCopilot(token string) (*OpenAIBackend, error) {
u, _ := url.Parse("https://api.githubcopilot.com")
return &OpenAIBackend{
baseBackend: baseBackend{name: "copilot"},
baseURL: u,
apiKey: token,
client: sharedClient("copilot:" + u.String()),
pathPrefix: "/",
extraHeaders: map[string]string{
"Openai-Intent": "conversation-edits",
"User-Agent": "opencode/local",
},
}, nil
}