Opik - LLM Observability and Evaluation

1.11.1 · active · verified Thu Apr 09

Opik, built by Comet, is an open-source platform designed to streamline the entire lifecycle of LLM applications. It provides comprehensive tracing, evaluation, monitoring, and optimization capabilities for large language models and agentic systems, from prototype to production. The current version is 1.11.1 and it is under active development with frequent updates and a community-driven roadmap.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to instrument a Python function with the `@opik.track` decorator to automatically log LLM calls and associated metadata to the Opik platform. It includes configuration for both Comet.com Cloud and an example of setting environment variables for authentication.

import opik
import os

# Configure Opik - for Comet.com Cloud
# Replace with your actual API key and workspace, or run `opik configure` in your terminal
opik.configure(
    api_key=os.environ.get('OPIK_API_KEY', 'YOUR_OPIK_API_KEY'),
    workspace=os.environ.get('OPIK_WORKSPACE', 'YOUR_OPIK_WORKSPACE'),
    project_name="my-llm-project"
)

@opik.track
def my_llm_function(user_question: str) -> str:
    # Simulate an LLM call or business logic
    response = f"Echoing your question: {user_question}"
    # Log metadata or tags if needed
    opik.set_tags(["example", "basic-tracing"])
    opik.log_metadata({"question_length": len(user_question)})
    return response

# Run the traced function
result = my_llm_function("What is the capital of France?")
print(f"LLM Function Result: {result}")

# To view traces, run `opik dashboard` or visit your Comet.com Opik dashboard.

view raw JSON →