How to get an answer and a score in one call (client.chat)

Call client.chat({ message }). ClearRun writes an answer, scores it, and returns responseText with the verdict.

Last updated

Steps

  1. Ask a question

    const { responseText, verdict, sessionId } = await client.chat({
      message: 'Is it safe to store API keys in a .env file?',
    });
    console.log(responseText);
    console.log(verdict.score);
  2. Continue the conversation

    await client.chat({ message: 'And in CI?', sessionId });

    Pass the sessionId from the first reply. It must belong to your account, or you get 404 Session not found.

Limits

A message can be 10 to 100,000 characters, the same limits as score and evaluate. Outside that range returns 400. An empty message returns 400 Message required.

Credits

Each chat turn costs at most 4 credits.