How to score text with the ClearRun SDK (client.score)
Call client.score({ responseText }). It sends the text to POST /api/score and returns { verdict, receipt }. Use it when you have an answer but not the prompt.
Last updated
Steps
Create a client
import { createKernelClient } from '@clearrun/sdk'; const client = createKernelClient();Score the answer
const { verdict } = await client.score({ responseText: 'The Eiffel Tower is definitely in Berlin.', }); console.log(verdict.score, verdict.risk, verdict.summary);Keep the verdict id
save(verdict.verdictId);You can look it up later with no key.
Options
responseText(required): the answer.modelId(optional): a label for the model that wrote it.
Have the prompt too?
Use client.evaluate. See How to score an answer with its prompt (client.evaluate).
Errors
Failures throw HostedApiError with status, message and code. See How to handle ClearRun SDK errors (HostedApiError).