Create Evaluation Rule
(v2)POST
Creates a standing rule that runs a metric collection against matching production traces, spans or threads as they arrive, and returns its id. Running metrics consumes LLM usage. The metric collection's turn type must match the rule: THREAD rules require a multi-turn collection, TRACE and SPAN rules a single-turn one, and only one enabled THREAD rule may target a given collection. Requires the Starter plan or above.
curl -X POST "https://api.confident-ai.com/v2/evaluation-rules" \
-H "CONFIDENT_API_KEY: <PROJECT-API-KEY>" \
-H "Content-Type: application/json" \
-d '{
"name": "Score production answers",
"enabled": true,
"dataModel": "TRACE",
"metricCollectionId": "<METRIC-COLLECTION-ID>",
"description": "Scores answers we serve to end users.",
"sampleRate": 0.2,
"spanType": "SPAN",
"filters": {
"operator": "AND",
"groups": [
{
"operator": "AND",
"filters": [
{
"category": "Name",
"condition": "Is",
"value": "capital-lookup"
}
]
}
]
},
"threadTimelimit": 300,
"overwriteEvals": false
}'{
"success": true,
"data": {
"id": "<EVALUATION-RULE-ID>"
},
"link": "https://app.confident-ai.com/project/<PROJECT-ID>/workflows",
"deprecated": false
}Headers
CONFIDENT_API_KEYstringRequiredThe API key of your Confident AI project.
Request body
namestringRequiredA name for the rule, unique within the project.
enabledbooleanWhether the rule evaluates matching items as they arrive. Defaults to true.
dataModelenumRequiredWhat kind of production item a rule evaluates:
TRACEfor a whole trace,SPANfor a single step within one,THREADfor a finished conversation.Show 3 enum valuesHide 3 enum values
TRACESPANTHREAD
metricCollectionIdstringRequiredThe id of the metric collection to run. It must be multi-turn for
THREADrules and single-turn forTRACEandSPANrules.descriptionstring | nullA note about what the rule checks. Send null to clear it.
sampleRatenumberThe fraction of matching items to evaluate, between 0 and 1. Defaults to 1, all of them.
spanTypeenum | nullThe kind of work a span records:
SPANfor a plain step,LLMfor a model call,RETRIEVERfor a knowledge-base lookup,TOOLfor a tool call, andAGENTfor an agent step.Show 5 enum valuesHide 5 enum values
SPANAGENTTOOLRETRIEVERLLM
filtersobject | nullA set of filter groups combined by a top-level operator. Each group combines its filter rows by its own operator, and each row matches one property, such as
NameorUser Id, against a value with a condition such asIsorContains.Show 2 propertiesHide 2 properties
operatorenumRequiredShow 2 enum valuesHide 2 enum values
ANDOR
groupslist of objectsRequiredShow 2 propertiesHide 2 properties
operatorenumRequiredShow 2 enum valuesHide 2 enum values
ANDOR
filterslist of objectsRequiredShow 4 propertiesHide 4 properties
categoryenumRequiredShow 80 enum valuesHide 80 enum values
User IdThread IdTrace UUIDTrace NameTrace VersionTrace StatusTrace TagsTraceSpan UUIDNameSpan NameSpan TypeSpan StatusMetrics StatusError StatusNameModelProviderIntegrationEmbedderChunk SizeTop-KHyperparameterDatasetDataset NameTest Run IDIdentifierTest FileStatusOfficialEvals ModeTests PassedTests FailedPass RateFail RateStar RatingThumbs RatingExplanationExpected OutputExpected OutcomeAnnotatorEnd UserAnnotation TypeAnnotation NameCriteriaAnnotation DateMetric ScoreMetric StatusNameMetadataClassifierMetricMetric NameTrace CountTest Case IDRequested review fromAssigned toTagsLabelsTools CalledFinalizedGolden IDIngestion TaskLatencyEnvironmentReview flagVulnerabilityVulnerability TypeAttack MethodRisk CategoryFrameworkAssessment IDPrompt AliasPrompt VersionPrompt LabelPrompt Commit HashPromptAnnotationsStatus CodeActor Type
conditionenum | enum | enum | enum | enum | enum | enum | enum | enum | enumRequiredShow 10 variantsHide 10 variants
enum
Show 6 enum valuesHide 6 enum values
Is less thanIs equal or less thanIs greater thanIs equal or greater thanIs equal toDoes not equal
- OR
enum
Show 2 enum valuesHide 2 enum values
HasHas not
- OR
enum
Show 2 enum valuesHide 2 enum values
IsIs not
- OR
enum
Show 2 enum valuesHide 2 enum values
Is one ofIs not one of
- OR
enum
Show 4 enum valuesHide 4 enum values
IsIs notIs emptyIs not empty
- OR
enum
Show 2 enum valuesHide 2 enum values
ContainsDoes not contain
- OR
enum
Show 3 enum valuesHide 3 enum values
ContainsContains onlyDoes not contain
- OR
enum
Show 4 enum valuesHide 4 enum values
Has decreased by more thanHas decreased by less thanHas increased by more thanHas increased by less than
- OR
enum
Show 1 enum valueHide 1 enum value
Has changed from
- OR
enum
Show 1 enum valueHide 1 enum value
Is between
valuestring | number | list of stringsRequiredShow 3 variantsHide 3 variants
string
- OR
number
- OR
list of strings
keystring
threadTimelimitinteger | nullFor
THREADrules, the seconds of inactivity to wait before evaluating a thread, so an in-progress conversation is not scored halfway. The minimum is 120, which leaves time for the last traces to be stored. Send null to use the project's thread timelimit, which defaults to 300.overwriteEvalsbooleanRe-evaluate items that already have results for this metric collection instead of skipping them. Defaults to false.
Response
Create Evaluation Rule succeeded.
successbooleanIndicates if the request was successful.
dataobjectA reference to an evaluation rule by its id.
Show 1 propertyHide 1 property
idstringThe id of the rule, generated by Confident AI.
linkstringThis is the URL of the resource on the Confident AI platform.
deprecatedbooleanIndicates if this endpoint is deprecated.