RAGASragas 0.4.3 · Python 3.9+
0%
1
Curious builder0 XP earned · 300 to level 2
0 daysFinish a lesson to begin
Badge collection0 of 6 unlocked
21 small wins to finish your pathNext lesson

Installation and setup

RAGAS installs from PyPI with a pinned LangChain version. Its metrics ask a judge model, and the judge can be a free Groq or Gemini model.

ragas 0.4.3 with langchain-community below 0.4

The pin matters. RAGAS 0.4.3 imports a class that langchain-community removed in its 0.4 release, so the newest of both together will not import at all. Lesson 17 says more about the version churn in this library.

RAGAS sends anonymous usage data, which RAGAS_DO_NOT_TRACK=true turns off.

pip install "ragas==0.4.3" "langchain-community<0.4"
Example
from importlib.metadata import version

print(version("ragas"))

A hosted judge for lesson 18Optional

The course judges with PretendJudge, a stand-in from lesson 5, and lesson 18 swaps in a hosted judge built with llm_factory. It takes a client: the Gemini one from google-genai, or an OpenAI client pointed at any OpenAI-compatible URL.

python
import os

from google import genai
from ragas.llms import llm_factory

client = genai.Client(api_key=os.environ["GOOGLE_API_KEY"])
judge = llm_factory("gemini-2.5-flash", provider="google", client=client)
ProviderKeyVariableClient for llm_factory
GeminiFree, aistudio.google.com/apikeyGOOGLE_API_KEYgenai.Client(...) with provider="google"
GroqFree, console.groq.com/keysGROQ_API_KEYOpenAI(base_url="https://api.groq.com/openai/v1")
OpenRouterFree models end in :free, openrouter.ai/keysOPENROUTER_API_KEYOpenAI(base_url="https://openrouter.ai/api/v1")
OpenAIPaid, platform.openai.com/api-keysOPENAI_API_KEYOpenAI() with no base_url
pip install google-genai "instructor[google-genai]"
export GOOGLE_API_KEY=AIza...
Try it yourself
  • Run pip show ragas langchain-community and check both versions.

Little by little, you're building something great.