#54
Add GitHub token support for semantic search
Copilot subscribers can now use their GitHub token for lat search embeddings instead of a separate OpenAI or Vercel API key.
Problem
Semantic search required an OpenAI (sk-...) or Vercel AI Gateway (vck_...) API key. Users with a GitHub Copilot subscription already have access to the same text-embedding-3-small model via the GitHub Models API, but couldn't use it.
Solution
Add a github embedding provider that targets the GitHub Models API at https://models.github.ai/inference/embeddings. The API is OpenAI-compatible, so the existing embed() function works unchanged.
Provider detection recognizes three GitHub token prefixes:
ghp_— classic personal access tokensgho_— OAuth tokens (returned bygh auth token)github_pat_— fine-grained personal access tokens
Other changes:
- Add
errorHintfield toEmbeddingProvidertype, appended to API error messages to give provider-specific troubleshooting guidance - Update
lat initto accept GitHub tokens withmodels:readscope guidance and agh auth tokenhelper tip - Update all error messages (Anthropic rejection, unrecognized prefix) to reference GitHub as an option
- Update README, lat.md/cli.md, and AGENTS.md documentation
Validation
- 15 provider detection tests (3 new GitHub prefix tests with full config assertions, updated Anthropic/unknown error tests, negative test for
ghs_App tokens) - 2 new
errorHintintegration tests (mock fetch, verify hint appended on error / absent when unset) - All 159 tests pass;
tsc --noEmitandlat checkclean - Manually verified with my github subscription using Github Copilot CLI
Activity
5lars20070reviewed6mo ago
lars20070reviewed6mo ago
@qbradley Great solution for avoiding additional OpenAI or Vercel API keys. Thanks!
@qbradley is attempting to deploy a commit to the Yury Selivanov's projects Team on Vercel.
A member of the Team first needs to authorize it.