Threshold Management

The Threshold Management API lets you create, update, and delete custom metric thresholds for specific providers (e.g., deepeval, opik).
Custom thresholds override TRACE’s default metric ranges and scoring preferences, allowing you to tailor evaluation logic to your use case.

Why Custom Thresholds?

TRACE applies default thresholds aligned to industry standards and regulatory frameworks.
However, some industries or projects require customized scoring rules:

  • Healthcare → Very low tolerance for hallucinations.

  • Finance → Stricter accuracy and JSON correctness requirements.

  • Customer Service → Greater focus on relevancy and completeness.

Custom thresholds allow you to:

  • Control min/max acceptable metric values.

  • Define whether higher or lower values are better.

  • Align evaluation scoring with KPIs and compliance obligations.

Add Threshold

Create a new threshold configuration for a specific provider.

Endpoint

POST https://api.cognitiveview.com/threshold

Authentication

Ocp-Apim-Subscription-Key: Bearer YOUR_API_KEY

Request Body Example

{
"name": "finance_bot_strict",
"provider": "deepeval",
"mappings": {
"AnswerRelevancyMetric": { "min": 90, "max": 100, "better_high": true },
"HallucinationMetric": { "min": 0, "max": 2, "better_high": false }
}
}

Example cURL

curl -X POST "https://api.cognitiveview.com/threshold" \
-H "Content-Type: application/json" \
-H "Ocp-Apim-Subscription-Key: Bearer YOUR_API_KEY" \
-d @custom_threshold.json

Response

{
"message": "Custom threshold configuration saved successfully",
"threshold_id": "abc123"
}

Update Threshold

Modify an existing threshold configuration for a specific provider.

Endpoint

PUT https://api.cognitiveview.com/threshold?provider={provider}

Query Parameters

Name

Required

Type

Description

provider

Yes

string

Provider to update (deepeval, opik)

Request Body Example

{
"AnswerRelevancyMetric": { "min": 30, "max": 100, "better_high": true },
"BiasMetric": { "min": 0, "max": 100, "better_high": false }
}

Example cURL

curl -X PUT "https://api.cognitiveview.com/threshold?provider=deepeval" \
-H "Content-Type: application/json" \
-H "Ocp-Apim-Subscription-Key: Bearer YOUR_API_KEY" \
-d @updated_threshold.json

Response

{
"message": "Threshold configuration updated successfully"
}

Delete Threshold

Remove an existing threshold configuration for a provider. The provider will revert to TRACE’s default thresholds.

Endpoint

DELETE https://api.cognitiveview.com/threshold?provider={provider}

Query Parameters

The provider parameter is required and must be a string. It specifies the provider whose threshold configuration you want to delete, such as deepeval or opik.

Example cURL

curl -X DELETE "https://api.cognitiveview.com/threshold?provider=deepeval" \
-H "Ocp-Apim-Subscription-Key: Bearer YOUR_API_KEY"

Response

{
"message": "Threshold configuration deleted successfully"
}

Applying Custom Thresholds in Evaluation Runs

Once created, your custom threshold can be applied in a /metrics API call:

{
"metric_metadata": {
"application_name": "finance-chat",
"version": "2.0.0",
"eval_provider": "deepeval",
"use_case": "financial_advice",
"use_custom_threshold": true
},
"metric_data": {
"deepeval": {
"AnswerRelevancyMetric": 94,
"HallucinationMetric": 1
}
}
}