Skip to content

[feat] add litellm#4384

Merged
sauravpanda merged 2 commits into
browser-use:mainfrom
shanyu-strix:feat/litellm-provider
Mar 17, 2026
Merged

[feat] add litellm#4384
sauravpanda merged 2 commits into
browser-use:mainfrom
shanyu-strix:feat/litellm-provider

Conversation

@shanyu-strix
Copy link
Copy Markdown
Contributor

@shanyu-strix shanyu-strix commented Mar 16, 2026

LiteLLM integration

Adds LiteLLM provider, allowing users to have drop-in compatibility with LiteLLM without any additional configuration.

Some clarifications

Why not wrap this around existing routers etc? If LiteLLM is used internally, not only:

  • Anthropic/OpenAI models will be defined under the same api, but parsed differently. Therefore this would require excessive amounts of if else for defining each provider.
  • OpenRouter models wold need to be handled independently
  • LiteLLM unlocks hundreds more models, i.e huggingface etc.

Example use

def _build_llm(metadata: dict[str, Any] | None = None) -> tuple[Any, bool]:
    import litellm

    from strix.config.config import resolve_llm_config
    from .litellm.chat import ChatLiteLLM    

    model, api_key, api_base = resolve_llm_config()
    if not model:
        raise ValueError("STRIX_LLM environment variable must be set")

    return ChatLiteLLM(
        model=model,
        api_key=api_key,
        api_base=api_base,
        metadata=metadata
    )

Summary by cubic

Added a new ChatLiteLLM provider for drop-in use of any litellm-supported chat model. Supports structured outputs, image/text message serialization, usage reporting, and robust error handling.

  • New Features

    • Added ChatLiteLLM with provider autodetection; supports model, api_key, api_base, temperature, max_tokens, max_retries, and metadata.
    • Structured output via response_format JSON Schema using SchemaOptimizer for Pydantic models.
    • Serializes user/system/assistant messages, including images and assistant tool_calls.
    • Returns token usage, stop_reason, and optional reasoning content; retries and maps LiteLLM errors to ModelRateLimitError/ModelProviderError.
    • Exported ChatLiteLLM in browser_use.__init__.
  • Dependencies

    • Added litellm>=1.82.2.

Written for commit 8976e59. Summary will update on new commits.

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Mar 16, 2026

CLA assistant check
All committers have signed the CLA.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 5 files


Since this is your first cubic review, here's how it works:

  • cubic automatically reviews your code and comments on bugs and improvements
  • Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
  • Add one-off context when rerunning by tagging @cubic-dev-ai with guidance or docs links (including llms.txt)
  • Ask questions if you need clarification on any suggestion

@sauravpanda sauravpanda merged commit 154e3f8 into browser-use:main Mar 17, 2026
76 checks passed
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.

3 participants