Create Evaluation Rule
POSThttps://api.confident-ai.com/v1/evaluation-rules
Creates a standing rule that runs a metric collection against matching production traces, spans, or threads as they arrive. Running metrics consumes LLM usage.
The metric collection's turn type must match: THREAD rules require a multi-turn collection, TRACE and SPAN rules require a single-turn one. Only one enabled THREAD rule may target a given metric collection. Requires the Starter plan or above.
curl -X POST "https://api.confident-ai.com/v1/evaluation-rules" \
-H "CONFIDENT_API_KEY: <PROJECT-API-KEY>" \
-H "Content-Type: application/json" \
-d '{
"name": "Score production answers",
"dataModel": "TRACE",
"metricCollection": "Answer Quality",
"sampleRate": 0.2
}'{
"success": true,
"data": {
"id": "EVALUATION-RULE-ID"
},
"link": "https://app.confident-ai.com/project/<PROJECT-ID>/workflows"
}Headers
CONFIDENT_API_KEYstringRequiredThe API key of your Confident AI project.
Request body
descriptionstringA note about what the rule checks.
enabledbooleanWhether the rule runs. Defaults to true on create.
sampleRatenumberThe fraction of matching items to evaluate. Defaults to 1 (all of them).
spanTypeenumOnly evaluate spans of this type. Allowed only when
dataModelisSPAN, and cleared automatically if the rule moves offSPAN.Show 5 enum valuesHide 5 enum values
SPANAGENTTOOLRETRIEVERLLM
filtersobjectA set of filter groups combined by a top-level operator.
Show 2 propertiesHide 2 properties
operatorenumRequiredHow filters or groups are combined.
Show 2 enum valuesHide 2 enum values
ANDOR
groupslist of objectsRequiredThe filter groups.
Show 2 propertiesHide 2 properties
operatorenumRequiredHow filters or groups are combined.
Show 2 enum valuesHide 2 enum values
ANDOR
filterslist of objectsRequiredThe filter rows in this group.
Show 4 propertiesHide 4 properties
categorystringRequiredThe property a filter row matches on (e.g. "Name", "User Id", "Model", "Metadata"). The set of valid values depends on the line's dataModel.
conditionenumRequiredThe comparison a filter row applies. Valid conditions depend on the category.
Show 18 enum valuesHide 18 enum values
IsIs notIs equal toDoes not equalIs less thanIs equal or less thanIs greater thanIs equal or greater thanHasHas notContainsContains onlyDoes not containHas increased by more thanHas increased by less thanHas decreased by more thanHas decreased by less thanHas changed from
valuestring | number | list of stringsRequiredThe value to match against.
Show 3 variantsHide 3 variants
string
- OR
number
- OR
list of strings
keystringThe property key. Auto-populated from category when omitted; required for Metadata, Metric, and Classifier filters.
threadTimelimitintegerFor
THREADrules, the seconds of inactivity to wait before evaluating a thread, so an in-progress conversation is not scored halfway. Defaults to 300.overwriteEvalsbooleanRe-evaluate items that already have results for this metric collection instead of skipping them. Defaults to false.
namestringRequiredA name for the rule, unique within the project.
dataModelenumRequiredWhat kind of item to evaluate.
Show 3 enum valuesHide 3 enum values
TRACESPANTHREAD
metricCollectionstringRequiredThe name of the metric collection to run. Must be multi-turn for
THREADrules and single-turn forTRACEandSPANrules.
Response
successbooleanIndicates if the evaluation rule was successfully created.
dataobjectShow 1 propertyHide 1 property
idstringThe unique identifier of the created evaluation rule.
linkstringA link to the workflows page.