curl --request PATCH \
--url https://api.promptlayer.com/reports/{report_id}/score-card \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: <api-key>' \
--data '
{
"column_names": [
"Accuracy Check",
"Style Check"
],
"code": "weights = {\"Accuracy Check\": 0.7, \"Style Check\": 0.3}\ntotal_weight = weighted_sum = 0\nfor row in data:\n for col_name, weight in weights.items():\n if col_name in row and isinstance(row[col_name], bool):\n total_weight += weight\n if row[col_name]:\n weighted_sum += weight\nscore = (weighted_sum / total_weight * 100) if total_weight > 0 else 0\nreturn {\"score\": score}",
"code_language": "PYTHON"
}
'{
"success": true,
"report": {
"id": 456,
"name": "My Evaluation Pipeline",
"score_configuration": {
"code": "return {\"score\": 85.5}",
"code_language": "PYTHON"
}
}
}{
"success": false,
"message": "<string>",
"error": "<string>"
}{
"success": false,
"message": "<string>",
"error": "<string>"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Evaluations & Reports API
Configure Custom Scoring
PATCH
/
reports
/
{report_id}
/
score-card
curl --request PATCH \
--url https://api.promptlayer.com/reports/{report_id}/score-card \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: <api-key>' \
--data '
{
"column_names": [
"Accuracy Check",
"Style Check"
],
"code": "weights = {\"Accuracy Check\": 0.7, \"Style Check\": 0.3}\ntotal_weight = weighted_sum = 0\nfor row in data:\n for col_name, weight in weights.items():\n if col_name in row and isinstance(row[col_name], bool):\n total_weight += weight\n if row[col_name]:\n weighted_sum += weight\nscore = (weighted_sum / total_weight * 100) if total_weight > 0 else 0\nreturn {\"score\": score}",
"code_language": "PYTHON"
}
'{
"success": true,
"report": {
"id": 456,
"name": "My Evaluation Pipeline",
"score_configuration": {
"code": "return {\"score\": 85.5}",
"code_language": "PYTHON"
}
}
}{
"success": false,
"message": "<string>",
"error": "<string>"
}{
"success": false,
"message": "<string>",
"error": "<string>"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Legacy Dataset, Evaluation, and Report endpoints are deprecated for new workflows. Use the Tables API for new dataset import, evaluation, scoring, recalculation, and reporting workflows.
Behavior Notes
- Custom code receives a
datavariable containing evaluation rows and must return an object with at least ascorekey from 0 to 100. - If no custom code is provided, PromptLayer uses default scoring over the selected columns.
- Updating a blueprint affects future runs; completed runs recalculate their score after the score card changes.
Related
Authorizations
Path Parameters
ID of the evaluation pipeline to update.
Body
application/json
Score-card configuration payload.
Column names to include in the score calculation.
Optional custom Python or JavaScript scoring code. The code receives data and must return an object with a score key.
Language used by the custom scoring code.
Available options:
PYTHON, JAVASCRIPT Was this page helpful?

