RheagalFire opened a new pull request, #803:
URL: https://github.com/apache/burr/pull/803
Adds LiteLLM AI gateway integration, giving Burr users access to 100+ LLM
providers (OpenAI, Anthropic, Google, Azure, AWS Bedrock, Ollama, Groq,
Mistral, and more) through a single Action class.
## Changes
- `burr/integrations/litellm.py` - New `LiteLLMAction` (non-streaming) and
`LiteLLMStreamingAction` (streaming) following the same `_Core` + `_Base` +
Action pattern as `burr/integrations/bedrock.py`. Uses `litellm.completion()`
with `drop_params=True` for cross-provider compatibility.
- `pyproject.toml` - Added `[litellm]` optional dependency group
(`burr[litellm]`)
The codebase already references LiteLLM in TODO comments
(`core/parallelism.py`, `docs/concepts/parallelism.rst`) and uses LiteLLM
pricing data for cost tracking (`telemetry/ui/scripts/token_costs.py`). This PR
ships the actual integration.
## How I tested this
**Live E2E via Anthropic Claude:**
```python
from burr.core.state import State
from burr.integrations.litellm import LiteLLMAction
def prompt_mapper(state):
return {'messages': [
{'role': 'system', 'content': 'Answer concisely.'},
{'role': 'user', 'content': state['user_input']},
]}
action = LiteLLMAction(
model='anthropic/claude-sonnet-4-6',
input_mapper=prompt_mapper,
reads=['user_input'],
writes=['response'],
)
state = State({'user_input': 'What is 2+2? Just the number.'})
result, new_state = action.run_and_update(state)
# Response: "4"
# State updated: True
```
**Pin resolution verified:** `pip install -e '.[litellm]'` resolves cleanly.
## Notes
- Follows the exact same architecture as the Bedrock integration
(`_BedrockCore` / `_BedrockBase` / `BedrockAction` / `BedrockStreamingAction`)
- `litellm` is an optional extra, base install unaffected
- `drop_params=True` silently drops provider-unsupported kwargs so the same
action works across OpenAI, Anthropic, Gemini, etc.
## Checklist
- [x] PR has an informative and human-readable title (this will be pulled
into the release notes)
- [x] Changes are limited to a single goal (no scope creep)
- [x] Code passed the pre-commit check & code is left cleaner/nicer than
when first encountered.
- [x] Any _change_ in functionality is tested
- [x] New functions are documented (with a description, list of inputs, and
expected output)
- [ ] Placeholder code is flagged / future TODOs are captured in comments
- [ ] Project documentation has been updated if adding/changing
functionality.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]