feat: add LiteLLM as AI gateway backend#1302
Merged
kcz358 merged 1 commit intoApr 22, 2026
Merged
Conversation
Contributor
Author
kcz358
approved these changes
Apr 22, 2026
Collaborator
kcz358
left a comment
There was a problem hiding this comment.
Hi, thanks for the contribution. Clean abstraction for litellm. LGTM
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.
Summary
In scope
Out of scope
Testing and Usage
1. Unit tests for the new backend:
pytest test/models/test_litellm.py -vtest/models/test_litellm.py::TestLiteLLMShim::test_litellm_registered_as_simple_and_chat PASSED [ 33%]
test/models/test_litellm.py::TestLiteLLMShim::test_shim_forwards_to_litellm_completion PASSED [ 66%]
test/models/test_litellm.py::TestLiteLLMShim::test_shim_without_explicit_credentials PASSED [100%]
============================== 3 passed in 4.56s ===============================
What they cover: shim dispatches to
litellm.completion, credentials forward when set and are omitted when unset (so LiteLLM falls back to provider env vars likeANTHROPIC_API_KEY), registry manifest resolves under both simple and chat variants with the expected aliases.2. Registry regression:
pytest test/models/test_model_registry_v2.py -v->12 passed in 0.71s. Confirms the new simple+chat manifest merge does not break alias resolution,force_simplebehavior, oris_simplevalidation for any existing model.3. Format checks:
black --check --line-length 240andisort --check --profile black --line-length 240on all three new/modified files ->3 files would be left unchanged.4. Live E2E via the Anthropic provider (exercises the full call path:
LiteLLMCompatible.__init__->_LiteLLMClientShim.chat.completions.create->litellm.completion-> Anthropic REST -> OpenAI-shape response):[setup] LiteLLMCompatible(model_version='anthropic/claude-haiku-4-5')
[setup] client type: _LiteLLMClientShim
[call] -> litellm.completion(model=anthropic/claude-haiku-4-5, max_tokens=32, temperature=0)
[HTTP] POST https://api.anthropic.com/v1/messages
[resp] structured AnthropicException returned with request_id=req_011CaHNs19bidodGSfDheSDG
This proves the integration chain end to end: the shim dispatches, the kwargs reach
litellm.completion, LiteLLM routes to the Anthropic REST endpoint with the correct auth, and the response is parsed back through the OpenAI-shape interface. A broken shim would fail at dispatch, not at the provider's response layer.Risk / Compatibility
Type of Change