Skip to content

Add capability to override default GitHub Copilot authentication endp…#25915

Merged
krrish-berri-2 merged 8 commits intoBerriAI:litellm_internal_stagingfrom
steromano87:feature/configurable-github-copilot-endpoints
Apr 17, 2026
Merged

Add capability to override default GitHub Copilot authentication endp…#25915
krrish-berri-2 merged 8 commits intoBerriAI:litellm_internal_stagingfrom
steromano87:feature/configurable-github-copilot-endpoints

Conversation

@steromano87
Copy link
Copy Markdown
Contributor

@steromano87 steromano87 commented Apr 16, 2026

Relevant issues

Fixes #25914

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have Added testing in the tests/test_litellm/ directory, Adding at least 1 test is a hard requirement - see details
  • My PR passes all unit tests on make test-unit
  • My PR's scope is as isolated as possible, it only solves 1 specific problem
  • I have requested a Greptile review by commenting @greptileai and received a Confidence Score of at least 4/5 before requesting a maintainer review

Delays in PR merge?

If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).

CI (LiteLLM team)

CI status guideline:

  • 50-55 passing tests: main is stable with minor issues.
  • 45-49 passing tests: acceptable but needs attention
  • <= 40 passing tests: unstable; be careful with your merges and assess the risk.
  • Branch creation CI run
    Link:

  • CI run for the last commit
    Link:

  • Merge / cherry-pick CI run
    Links:

Screenshots / Proof of Fix

Type

🆕 New Feature

Changes

  • Add support for configurable GitHub Copilot endpoints (via environment variables) to allow usage with GitHub Enterprise subscriptions with custom host (e.g. mycompany.ghe.com) or with self-hosted GitHub instances

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 16, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
litellm Ready Ready Preview, Comment Apr 16, 2026 11:23pm

Request Review

@steromano87
Copy link
Copy Markdown
Contributor Author

@greptileai

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 16, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 16, 2026

Greptile Summary

This PR adds support for configurable GitHub Copilot endpoints via environment variables (GITHUB_COPILOT_DEVICE_CODE_URL, GITHUB_COPILOT_ACCESS_TOKEN_URL, GITHUB_COPILOT_API_KEY_URL, GITHUB_COPILOT_CLIENT_ID, GITHUB_COPILOT_API_BASE), enabling use with GitHub Enterprise subscriptions and self-hosted GitHub instances. It also fixes the previously-inverted api_base priority in embedding/transformation.py and corrects the stale IndentationError in authenticator.py, making all three transformation paths consistent.

Confidence Score: 5/5

Safe to merge — all remaining findings are minor documentation polish with no impact on runtime behaviour.

The three previously-critical issues (IndentationError at import time, inverted api_base priority in embedding, os.getenv inside the polling loop) are all resolved. The new env-var fallback chains are consistent across all three transformation files, env-var lookups are correctly hoisted above retry loops in the authenticator, and the five new authenticator tests are mock-only and well-structured. The only remaining findings are P2 style issues in the provider documentation.

docs/my-website/docs/providers/github_copilot.md — unclosed parenthesis in comment and missing GITHUB_COPILOT_CLIENT_ID from the example block

Important Files Changed

Filename Overview
litellm/llms/github_copilot/authenticator.py Renames module-level constants to DEFAULT_* prefix and adds os.getenv() calls to support overriding URLs and client ID at call time; env var lookups are correctly hoisted above retry loops
litellm/llms/github_copilot/common_utils.py Renames GITHUB_COPILOT_API_BASE constant to DEFAULT_GITHUB_COPILOT_API_BASE for consistency; no logic changes
litellm/llms/github_copilot/chat/transformation.py Updates api_base fallback chain to: caller-supplied api_base → authenticator cache → GITHUB_COPILOT_API_BASE env var → hardcoded default; now consistent with embedding and responses paths
litellm/llms/github_copilot/embedding/transformation.py Fixes previously-inverted api_base priority (was: authenticator → caller → default) to the correct order: caller → authenticator → env var → default; also adds env var layer
litellm/llms/github_copilot/responses/transformation.py Adds GITHUB_COPILOT_API_BASE env var layer to the existing correct fallback chain; removes stale docstring that previously limited support to individual accounts only
tests/test_litellm/llms/github_copilot/test_github_copilot_authenticator.py Adds 5 new mock-only tests covering all 4 new authenticator env vars (DEVICE_CODE_URL, ACCESS_TOKEN_URL, API_KEY_URL, CLIENT_ID); tests correctly use patch.dict and assert exact call arguments
docs/my-website/docs/providers/github_copilot.md Documents 4 of the 5 new env vars; missing GITHUB_COPILOT_CLIENT_ID and has an unclosed parenthesis in the comment block
docs/my-website/docs/proxy/config_settings.md Adds all 5 new env vars including GITHUB_COPILOT_CLIENT_ID with correct default value matching the code

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Request to github_copilot provider] --> B{api_base supplied?}
    B -- Yes --> E[Use supplied api_base]
    B -- No --> C{authenticator.get_api_base from api-key.json?}
    C -- Yes --> E
    C -- No --> D{GITHUB_COPILOT_API_BASE env var set?}
    D -- Yes --> E
    D -- No --> F[Use DEFAULT_GITHUB_COPILOT_API_BASE]
    E --> G[Append /chat, /embeddings, or /responses]

    H[Device code auth flow] --> I{GITHUB_COPILOT_DEVICE_CODE_URL set?}
    I -- Yes --> J[POST to custom URL]
    I -- No --> K[POST to github.com/login/device/code]

    L[Poll for access token] --> M{GITHUB_COPILOT_ACCESS_TOKEN_URL set?}
    M -- Yes --> N[POST to custom URL]
    M -- No --> O[POST to github.com/login/oauth/access_token]

    P[Refresh API key] --> Q{GITHUB_COPILOT_API_KEY_URL set?}
    Q -- Yes --> R[GET from custom URL]
    Q -- No --> S[GET from api.github.com/copilot_internal/v2/token]
Loading

Reviews (8): Last reviewed commit: "Fix default value for Copilot client ID ..." | Re-trigger Greptile

Comment thread litellm/llms/github_copilot/authenticator.py Outdated
Comment thread litellm/llms/github_copilot/chat/transformation.py Outdated
Comment thread litellm/llms/github_copilot/authenticator.py Outdated
Comment thread litellm/llms/github_copilot/embedding/transformation.py
steromano87 and others added 5 commits April 17, 2026 01:04
…oints

This feature adds support for GitHub Enterprise subsriptions with custom domain/data ownership (which use a different URL compared to standard accounts)
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
@steromano87 steromano87 force-pushed the feature/configurable-github-copilot-endpoints branch from 1c46260 to 259dfdf Compare April 16, 2026 23:04
Comment thread docs/my-website/docs/proxy/config_settings.md Outdated
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
@steromano87 steromano87 marked this pull request as draft April 16, 2026 23:27
@steromano87 steromano87 marked this pull request as ready for review April 16, 2026 23:34
@krrish-berri-2 krrish-berri-2 merged commit f69b9d6 into BerriAI:litellm_internal_staging Apr 17, 2026
43 of 44 checks passed
@steromano87 steromano87 deleted the feature/configurable-github-copilot-endpoints branch April 17, 2026 07:30
shiva-manu pushed a commit to shiva-manu/litellm that referenced this pull request Apr 18, 2026
BerriAI#25915)

* Add capability to override default GitHub Copilot authentication endpoints

This feature adds support for GitHub Enterprise subsriptions with custom domain/data ownership (which use a different URL compared to standard accounts)

* Update documentation with new parameters

* Move access token URL and Client ID retrieval outside for loop

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>

* Fix spurious comment from Greptile review

* Align api_base retrieval behavior across chat and embedding transformations

* Add missing GitHub Copilot client ID parameter in docs

* Update website documentation with newer options for GitHub Enterprise Copilot

* Fix default value for Copilot client ID in docs

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>

---------

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Add support for configurable GitHub Copilot endpoints

2 participants