DeepEval 5-min Quickstart
This quickstart takes you from installing DeepEval to your first passing eval in a few
minutes. You'll create a small test case, choose a metric, and run it with
deepeval test run.
By the end of this quickstart, you should be able to:
- Run your first local eval with a test case, metric, and
deepeval test run. - Evaluate an AI agent's complete trajectory and diagnose its internal components with tracing.
- Know where to go next for datasets, integrations, and the Confident AI platform.
New to DeepEval? Checkout the introduction to learn more about this framework.
Installation
In a newly created virtual environment, run:
pip install -U deepevaldeepeval plugs into Pytest, so deepeval test run collects and runs your eval files the same way pytest would.
deepeval runs evaluations locally on your environment. To keep your testing reports in a centralized place on the cloud, use Confident AI, an AI quality platform with observability, evals, and monitoring that DeepEval integrates with natively:
deepeval loginYour browser handles authentication only. After you sign in or create an
account, return to the terminal to enter your name and organization, confirm
the prefilled first-project name, or select one of your existing projects.
DeepEval creates and saves a dedicated project API key automatically. For CI
or other non-interactive environments, pass an existing key with
deepeval login --api-key ....
Configure Environment Variables
DeepEval autoloads environment files (at import time)
- Precedence: existing process env ->
.env.local->.env - Opt-out: set
DEEPEVAL_DISABLE_DOTENV=1
More information on env settings can be found here.
# quickstart
cp .env.example .env.local
# then edit .env.local (ignored by git)Create Your First Test Run
Create a test file to run your first end-to-end evaluation.
An LLM test case in deepeval represents a single unit of LLM app interaction, and contains mandatory fields such as the input and actual_output (LLM generated output), and optional ones like expected_output.

Run touch test_example.py in your terminal and paste in the following code:
from deepeval import assert_test
from deepeval.test_case import LLMTestCase, SingleTurnParams
from deepeval.metrics import GEval
def test_correctness():
correctness_metric = GEval(
name="Correctness",
criteria="Determine if the 'actual output' is correct based on the 'expected output'.",
evaluation_params=[SingleTurnParams.ACTUAL_OUTPUT, SingleTurnParams.EXPECTED_OUTPUT],
threshold=0.5
)
test_case = LLMTestCase(
input="I have a persistent cough and fever. Should I be worried?",
# Replace this with the actual output from your LLM application
actual_output="A persistent cough and fever could be a viral infection or something more serious. See a doctor if symptoms worsen or don't improve in a few days.",
expected_output="A persistent cough and fever could indicate a range of illnesses, from a mild viral infection to more serious conditions like pneumonia or COVID-19. You should seek medical attention if your symptoms worsen, persist for more than a few days, or are accompanied by difficulty breathing, chest pain, or other concerning signs."
)
assert_test(test_case, [correctness_metric])Then, run deepeval test run from the root directory of your project to evaluate your LLM app end-to-end:
deepeval test run test_example.pyCongratulations! Your test case should have passed ✅ Let's breakdown what happened.
- The variable
inputmimics a user input, andactual_outputis a placeholder for what your application's supposed to output based on this input. - The variable
expected_outputrepresents the ideal answer for a giveninput, andGEvalis a research-backed metric provided bydeepevalfor you to evaluate your LLM output's on any custom metric with human-like accuracy. - In this example, the metric
criteriais correctness of theactual_outputbased on the providedexpected_output, but not all metrics require anexpected_output. - All metric scores range from 0 - 1, which the
threshold=0.5threshold ultimately determines if your test have passed or not.
If you run more than one test run, you will be able to catch regressions by comparing test cases side-by-side. This is also made easier if you're using deepeval alongside Confident AI (see below for video demo).
A conversational test case in deepeval represents a multi-turn interaction with your LLM app, and contains information such as the actual conversation that took place in the format of turns, and optionally the scenario of which a conversation happened.

Run touch test_example.py in your terminal and paste in the following code:
from deepeval import assert_test
from deepeval.test_case import Turn, ConversationalTestCase
from deepeval.metrics import ConversationalGEval
def test_professionalism():
professionalism_metric = ConversationalGEval(
name="Professionalism",
criteria="Determine whether the assistant has acted professionally based on the content.",
threshold=0.5
)
test_case = ConversationalTestCase(
turns=[
Turn(role="user", content="What is DeepEval?"),
Turn(role="assistant", content="DeepEval is an open-source LLM eval package.")
]
)
assert_test(test_case, [professionalism_metric])Then, run deepeval test run from the root directory of your project to evaluate your LLM app end-to-end:
deepeval test run test_example.py🎉 Congratulations! Your test case should have passed ✅ Let's breakdown what happened.
- The variable
roledistinguishes between the end user and your LLM application, andcontentcontains either the user’s input or the LLM’s output. - In this example, the
criteriametric evaluates the professionalism of the sequence ofcontent. - All metric scores range from 0 - 1, which the
threshold=0.5threshold ultimately determines if your test have passed or not.
If you run more than one test run, you will be able to catch regressions by comparing test cases side-by-side. This is also made easier if you're using deepeval alongside Confident AI (see below for video demo).
Save Results
It is recommended that you push your test runs to Confident AI — an AI quality platform deepeval integrates with natively for observability, evals, and monitoring.
Confident AI is an AI quality platform with observability, evals, and monitoring that deepeval integrates with natively, and helps you build the best LLM evals pipeline.
Run deepeval view to view your newly ran test run on the platform:
deepeval viewThe deepeval view command requires that the test run that you ran above has been successfully cached locally. If something errors, simply run a new test run after logging in with deepeval login:
deepeval loginOnce that's set up, Confident AI will generate testing reports and automate regression testing whenever you run a test run to evaluate your LLM application inside any environment, at any scale, anywhere.
Once you've run more than one test run, you'll be able to use the regression testing page shown near the end of the video. Green rows indicate that your LLM has shown improvement on specific test cases, whereas red rows highlight areas of regression.
Simply set the DEEPEVAL_RESULTS_FOLDER environment variable to your relative path of choice. Everything deepeval stores locally, including the SQLite alternative, is explained here.
# linux
export DEEPEVAL_RESULTS_FOLDER="./data"
# or windows
set DEEPEVAL_RESULTS_FOLDER=.\dataEvaluate an AI Agent
AI agents often take many steps before producing a result. To evaluate whether an agent completed its task and how it got there, first instrument it with LLM tracing, then score its complete trajectory.
Build Dataset
Create a small dataset of representative tasks for your agent:
from deepeval.dataset import EvaluationDataset, Golden
dataset = EvaluationDataset(goldens=[Golden(input="Plan a three-day trip to Paris")])Instrument and Evaluate Trajectory
Each example instruments the agent, captures one complete trace per golden, and applies TaskCompletionMetric to the full trajectory.
Pick your stack below, paste the snippet, and run it. Every integration ships an Async sample (the default — runs goldens concurrently) and a Sync sample (one golden at a time, useful for debugging or rate-limited providers):
Wrap the top-level function with @observe and call update_current_trace(...) to set the trace-level test case fields:
import asyncio
from deepeval.tracing import observe, update_current_trace
from deepeval.metrics import TaskCompletionMetric
...
@observe()
async def my_ai_agent(query: str) -> str:
answer = "..." # await your LLM call here
update_current_trace(input=query, output=answer)
return answer
for golden in dataset.evals_iterator(metrics=[TaskCompletionMetric()]):
task = asyncio.create_task(my_ai_agent(golden.input))
dataset.evaluate(task)from deepeval.evaluate import AsyncConfig
from deepeval.tracing import observe, update_current_trace
from deepeval.metrics import TaskCompletionMetric
...
@observe()
def my_ai_agent(query: str) -> str:
answer = "..." # call your LLM here
update_current_trace(input=query, output=answer)
return answer
for golden in dataset.evals_iterator(
metrics=[TaskCompletionMetric()],
async_config=AsyncConfig(run_async=False),
):
my_ai_agent(golden.input)See tracing for the full @observe and update_current_trace surface.
Build your agent with create_agent, then pass deepeval's CallbackHandler to its invoke / ainvoke method inside the loop:
import asyncio
from langchain.agents import create_agent
from deepeval.integrations.langchain import CallbackHandler
from deepeval.metrics import TaskCompletionMetric
...
def multiply(a: int, b: int) -> int:
"""Multiply two numbers."""
return a * b
agent = create_agent(
model="openai:gpt-4o-mini",
tools=[multiply],
system_prompt="Be concise.",
)
async def run_agent(prompt: str):
return await agent.ainvoke(
{"messages": [{"role": "user", "content": prompt}]},
config={"callbacks": [CallbackHandler()]},
)
for golden in dataset.evals_iterator(metrics=[TaskCompletionMetric()]):
task = asyncio.create_task(run_agent(golden.input))
dataset.evaluate(task)from langchain.agents import create_agent
from deepeval.evaluate import AsyncConfig
from deepeval.integrations.langchain import CallbackHandler
from deepeval.metrics import TaskCompletionMetric
...
def multiply(a: int, b: int) -> int:
"""Multiply two numbers."""
return a * b
agent = create_agent(
model="openai:gpt-4o-mini",
tools=[multiply],
system_prompt="Be concise.",
)
for golden in dataset.evals_iterator(
metrics=[TaskCompletionMetric()],
async_config=AsyncConfig(run_async=False),
):
agent.invoke(
{"messages": [{"role": "user", "content": golden.input}]},
config={"callbacks": [CallbackHandler()]},
)See the LangChain integration for the full surface.
Wire your StateGraph, then pass deepeval's CallbackHandler to its invoke / ainvoke method inside the loop:
import asyncio
from langchain.chat_models import init_chat_model
from langgraph.graph import StateGraph, MessagesState, START, END
from deepeval.integrations.langchain import CallbackHandler
from deepeval.metrics import TaskCompletionMetric
...
llm = init_chat_model("openai:gpt-4o-mini")
async def chatbot(state: MessagesState):
return {"messages": [await llm.ainvoke(state["messages"])]}
graph = (
StateGraph(MessagesState)
.add_node(chatbot)
.add_edge(START, "chatbot")
.add_edge("chatbot", END)
.compile()
)
async def run_graph(prompt: str):
return await graph.ainvoke(
{"messages": [{"role": "user", "content": prompt}]},
config={"callbacks": [CallbackHandler()]},
)
for golden in dataset.evals_iterator(metrics=[TaskCompletionMetric()]):
task = asyncio.create_task(run_graph(golden.input))
dataset.evaluate(task)