Skip to main content
The Metrics Service in the Galtea SDK allows you to manage metrics for evaluating your products. This Service is exposed by the galtea.metrics object.
Remember that we will be using the galtea object. More information here.

Quick Example

from galtea import Galtea

galtea = Galtea(api_key="YOUR_API_KEY")

# Create a custom metric (LLM-as-a-Judge)
metric = galtea.metrics.create(
    name="custom-accuracy",
    test_type="QUALITY",
    evaluator_model_name="GPT-4.1",
    source="full_prompt",
    judge_prompt='Determine if output equals expected. Output: "{actual_output}". Expected: "{expected_output}".',
    description="Custom accuracy metric"
)

print(f"Created metric: {metric.name} (ID: {metric.id})")

# List all metrics
metrics = galtea.metrics.list()
print(f"Total metrics: {len(metrics)}")

# Retrieve a built-in metric by name
role_adherence = galtea.metrics.get_by_name(name="Role Adherence")
print(f"Found metric: {role_adherence.name}")

Service Methods

Metric

Ways to evaluate and score product performance