feat(proxy): add xai upstream adapter for Grok via OAuth#28356
Merged
Conversation
Contributor
🔎 Lint report:
|
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Salvage of #28064 (@yannsunn).
Summary
Adds an
xaiupstream adapter tohermes proxy, backed by the existingxai-oauthcredential pool. External OpenAI-compatible clients can now route through Hermes's xAI OAuth credential without re-implementing PKCE refresh or token recovery.Changes
hermes_cli/proxy/adapters/xai.py(new): forwards/v1/responses,/v1/chat/completions,/v1/completions,/v1/embeddings,/v1/models. Usesload_pool('xai-oauth')somanual:xai_pkceentries fromhermes auth add xai-oauth --type oauthand singleton-seededloopback_pkceentries share the existing OAuth refresh behavior. 401 triggers one pool refresh/rotation attempt via the adapter retry hook.hermes_cli/proxy/adapters/__init__.py: registersxaialongsidenous_portal.hermes_cli/proxy/cli.py+hermes_cli/main.py:hermes proxy providersnow listsxai; auth hints updated.tests/hermes_cli/test_proxy.py: registry/metadata, pool-backed credential resolution, default base URL, 401 refresh retry behavior.Validation
scripts/run_tests.sh tests/hermes_cli/test_proxy.py -q→ 36/36 passing.Authorship preserved via cherry-pick. AUTHOR_MAP entry added in a follow-up commit.