#54

Add GitHub token support for semantic search

Openqbradleywants to merge intofrom

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 tokens
  • gho_ — OAuth tokens (returned by gh auth token)
  • github_pat_ — fine-grained personal access tokens

Other changes:

  • Add errorHint field to EmbeddingProvider type, appended to API error messages to give provider-specific troubleshooting guidance
  • Update lat init to accept GitHub tokens with models:read scope guidance and a gh auth token helper 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 errorHint integration tests (mock fetch, verify hint appended on error / absent when unset)
  • All 159 tests pass; tsc --noEmit and lat check clean
  • Manually verified with my github subscription using Github Copilot CLI

Activity

5
vercel[bot]7mo ago

@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.

lars20070reviewed6mo ago
lars20070reviewed6mo ago
lars200706mo ago

@qbradley Great solution for avoiding additional OpenAI or Vercel API keys. Thanks!