Webwright
Webwright copied to clipboard
feat: add LiteLLM as model backend for 100+ LLM providers
Summary
- Add LiteLLM as a model backend (
litellm) using the litellm Python SDK, enabling access to 100+ LLM providers (Anthropic, Bedrock, Vertex, Gemini, Cohere, Mistral, etc.) without needing a separate proxy - Overrides
_post_with_retriesto calllitellm.acompletion()directly instead of httpx, while inheriting the base class retry logic - Uses
drop_params=Truefor cross-provider compatibility
Changes
src/webwright/models/litellm_model.py- newLiteLLMModelbackend using litellm SDK withacompletion()src/webwright/models/__init__.py- registered"litellm"in_MODEL_MAPPING
Tests
from webwright.models import get_model
model = get_model({
"model_class": "litellm",
"model_name": "anthropic/claude-sonnet-4-6",
})
response = model([{"role": "user", "content": "What is 2+2? Answer in one word."}])
SDK Response: 'Four'
SDK E2E PASSED
Example usage
from webwright.models import get_model
# Anthropic via litellm SDK (reads ANTHROPIC_API_KEY from env)
model = get_model({"model_class": "litellm", "model_name": "anthropic/claude-sonnet-4-6"})
# OpenAI via litellm SDK (reads OPENAI_API_KEY from env)
model = get_model({"model_class": "litellm", "model_name": "gpt-4o"})
# Bedrock via litellm SDK (reads AWS creds from env)
model = get_model({"model_class": "litellm", "model_name": "bedrock/claude-3.5-sonnet"})
Risk / Compatibility
- Additive only. Existing OpenAI/Anthropic/OpenRouter backends untouched.
litellmis an optional dependency, imported at model init time.
@microsoft-github-policy-service agree