In Opik 2.0, datasets and experiments are project-scoped. Make sure to specify a project_name when creating datasets and running experiments so they are associated with the correct project.
The Opik SDK provides a simple way to integrate with Ragas, a framework for evaluating RAG systems.
There are two main ways to use Ragas with Opik:
Comet provides a hosted version of the Opik platform, simply create an account and grab your API Key.
You can also run the Opik platform locally, see the installation guide for more information.
You will first need to install the opik and ragas packages:
Configure the Opik Python SDK for your deployment type. See the Python SDK Configuration guide for detailed instructions on:
opik configureopik.configure()In order to use Ragas, you will need to configure your LLM provider API keys. For this example, we’ll use OpenAI. You can find or create your API keys in these pages:
You can set them as environment variables:
Or set them programmatically:
Ragas provides a set of metrics that can be used to evaluate the quality of a RAG pipeline, a full list of the supported metrics can be found in the Ragas documentation.
You can use the RagasMetricWrapper to easily integrate Ragas metrics with Opik tracking:
Once the metric wrapper is set up, you can use it to score traces or spans:
In the Opik UI, you will be able to see the full trace including the score calculation:

For more advanced use cases, you can evaluate entire datasets using Ragas metrics with the Opik evaluation platform:
You can also use Ragas’ native evaluation function with Opik tracing:
The RagasMetricWrapper can also be used directly within the Opik evaluation platform. This approach is much simpler than creating custom wrappers:
We will start by defining the Ragas metric, in this example we will use AnswerRelevancy:
Simply wrap the Ragas metric with RagasMetricWrapper:
If you are running within a Jupyter notebook, you will need to add the following line to the top of your notebook:
You can now use the metric wrapper directly within the Opik evaluation platform:
The RagasMetricWrapper automatically handles:
input → user_input, output → response)track=True