POST
/
projects
/
{projectId}
/
metrics
import Scorecard from 'scorecard-ai';

const client = new Scorecard({
  apiKey: process.env['SCORECARD_API_KEY'], // This is the default and can be omitted
});

const metric = await client.metrics.create('314', {
  evalType: 'ai',
  name: 'Response Accuracy',
  outputType: 'boolean',
  promptTemplate: 'Please evaluate if the following response is factually accurate: {{outputs.response}}',
  description: 'Evaluates if the response is factually accurate',
  evalModelName: 'gpt-4o',
  guidelines: 'Check if the response contains factually correct information',
  temperature: 0.1,
});

console.log(metric);
{
  "id": "456",
  "name": "Response Accuracy",
  "description": "Evaluates if the response is factually accurate",
  "outputType": "boolean",
  "evalType": "ai",
  "guidelines": "Check if the response contains factually correct information",
  "promptTemplate": "Please evaluate if the following response is factually accurate: {{response}}",
  "evalModelName": "gpt-4o",
  "temperature": 0.1
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Path Parameters

projectId
string
required

The ID of the Project to create the Metric in.

Example:

"314"

Body

application/json

A Metric with AI evaluation and integer output.

Response

201
application/json

Metric created successfully

A Metric defines how to evaluate system outputs against expected results. A Metric with AI evaluation and integer output.