{"id":46664,"library":"trulens-providers-litellm","title":"TruLens LiteLLM Provider","description":"A provider integration for TruLens that uses LiteLLM to evaluate LLM-based applications. It enables feedback functions using models served via LiteLLM (e.g., OpenAI, Anthropic, Cohere, etc.). Version 2.8.1 requires Python >=3.9, <4.0 and is actively maintained.","status":"active","version":"2.8.1","language":"python","source_language":"en","source_url":"https://github.com/truera/trulens","tags":["truera","llm","evaluation","feedback","litellm"],"install":[{"cmd":"pip install trulens-providers-litellm","lang":"bash","label":"install from PyPI"}],"dependencies":[{"reason":"Core TruLens library required for feedback functions and app tracking.","package":"trulens-core","optional":false},{"reason":"LiteLLM is used to call various LLM providers.","package":"litellm","optional":false}],"imports":[{"note":"The package name uses hyphens in PyPI, but import is dot-based.","wrong":"from trulens_providers_litellm import LiteLLM","symbol":"LiteLLM","correct":"from trulens.providers.litellm import LiteLLM"},{"note":"Callback class is part of the same provider module.","wrong":"from trulens.providers.litellm_callback import LiteLLMCallback","symbol":"LiteLLMCallback","correct":"from trulens.providers.litellm import LiteLLMCallback"}],"quickstart":{"code":"import os\nfrom trulens.core import TruSession\nfrom trulens.providers.litellm import LiteLLM\n\nsession = TruSession()\n\nprovider = LiteLLM(\n    model_engine=\"gpt-4o\",\n    api_key=os.environ.get(\"OPENAI_API_KEY\", \"your-key-here\")\n)\n\n# Define a feedback function\nfrom trulens.core.feedback import Feedback\nfrom trulens.providers.litellm import LiteLLM\n\nf_qa = Feedback(provider.qs_relevance).on_input_output()\n\n# Record and evaluate an app (pseudo-code, app definition omitted)\n# session.record(app, feedback_functions=[f_qa]).start()\n# session.evaluate(app_id=\"my-app\")","lang":"python","description":"Minimal setup: initialize session, create LiteLLM provider with model and API key, define a feedback function, and record/evaluate an app."},"warnings":[{"fix":"Update imports: from trulens.providers.litellm import LiteLLM (instead of from trulens_eval.feedback.provider.litellm import LiteLLM).","message":"TruLens 2.x has a significantly different API compared to 1.x. The provider classes have been moved from 'trulens_eval.feedback.provider' to 'trulens.providers.litellm'.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Set model_engine to a known LiteLLM-supported model (e.g., 'gpt-4o', 'claude-3-haiku-20240307').","message":"The LiteLLM provider requires that the underlying model (e.g., gpt-4o) is available via LiteLLM. If the model is not supported, you'll get an error. Always test with a supported model first.","severity":"gotcha","affected_versions":"all"},{"fix":"Refer to the new documentation for creating feedback functions and recording apps.","message":"In TruLens 2.x, 'FeedbackMode' and 'App' classes are deprecated; use 'feedback.Feedback' and app-specific wrappers.","severity":"deprecated","affected_versions":">=2.0.0"}],"env_vars":null,"search_vec":"'2.8.1':33 '3.9':36 '4.0':37 'activ':40 'anthrop':29 'applic':17 'base':16 'coher':30 'e.g':27 'enabl':19 'etc':31 'evalu':13,44 'feedback':20,45 'function':21 'integr':6 'litellm':2,11,26,46 'llm':15,43 'llm-base':14 'maintain':41 'model':23 'openai':28 'provid':3,5 'python':35 'requir':34 'serv':24 'truera':42 'trulen':1,8 'use':10,22 'version':32 'via':25","created_at":"2026-06-07T13:01:01.660834+00:00","updated_at":"2026-06-07T13:01:01.660834+00:00","problems":[{"fix":"pip install trulens-core trulens-providers-litellm","cause":"TruLens core not installed or wrong Python environment.","error":"ModuleNotFoundError: No module named 'trulens'"},{"fix":"Ensure you have trulens-providers-litellm>=2.0.0 and import as 'from trulens.providers.litellm import LiteLLM'.","cause":"The provider package might be installed but the imports have changed; or using an older version.","error":"ImportError: cannot import name 'LiteLLM' from 'trulens.providers.litellm'"},{"fix":"Check model spelling and ensure the corresponding API key (e.g., OPENAI_API_KEY) is set.","cause":"The model engine string is not recognized by LiteLLM or the API key is missing.","error":"Error: The model `gpt-4o-mini` does not exist."}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://trulens.org/","github":"https://github.com/truera/trulens","docs":null,"changelog":null,"pypi":null,"npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["ai-ml","testing"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-29","last_verified":"2026-06-29","next_check":"2026-07-29","install_tag":null}}