Skip to main content

module cleanlab_tlm.utils.responses

Real-time evaluation of responses from OpenAI Responses API.

If you are using OpenAI’s Responses API, this module allows you to incorporate TLM trust scoring without any change to your existing code.


class TLMResponses

Represents a Trustworthy Language Model (TLM) instance specifically designed for evaluating OpenAI Responses API responses.

This class provides a TLM wrapper that can be used to evaluate the quality and trustworthiness of responses from any OpenAI model by passing in the inputs to OpenAI’s Responses API and the Responses object.

Args:

  • quality_preset ({“base”, “low”, “medium”, “high”, “best”}, default = “medium”): an optional preset configuration to control the quality of TLM trustworthiness scores vs. latency/costs.

  • api_key (str, optional): Cleanlab TLM API key. If not provided, will attempt to read from CLEANLAB_API_KEY environment variable.

  • options (TLMOptions, optional): a typed dict of configurations you can optionally specify. See detailed documentation under TLMOptions.

  • timeout (float, optional): timeout (in seconds) to apply to each TLM evaluation.


method score

score(response: 'Response', **openai_kwargs: Any) → TLMScore

Score the trustworthiness of an OpenAI Responses API response.

Args:

  • response (Responses): The OpenAI Responses object to evaluate
  • **openai_kwargs (Any): The original kwargs passed to OpenAI’s responses.create() method

Returns:

  • TLMScore: A dict containing the trustworthiness score and optional logs