Class Braintrust

java.lang.Object
dev.braintrust.Braintrust

public class Braintrust extends Object
Main entry point for the Braintrust SDK.

This class provides access to all Braintrust functionality. Most users will interact with a singleton instance via get(), though you can create independent instances if needed.

The Braintrust instance also provides methods for enabling Braintrust in open telemetry builders.

Additionally, vendor-specific instrumentation or functionality is provided by Braintrust<Vendor Name>. E.g. BraintrustOpenAI, BraintrustAnthropic, etc.

See Also:
  • Method Details

    • get

      public static Braintrust get()
      get or create the global braintrust instance. Most users will want to use this method to access the Braintrust SDK.
    • get

      public static Braintrust get(BraintrustConfig config)
      get or create the global braintrust instance from the given config
    • of

      public static Braintrust of(BraintrustConfig config)
      Create a new Braintrust instance from the given config
    • projectUri

      public URI projectUri()
    • openTelemetryCreate

      public io.opentelemetry.api.OpenTelemetry openTelemetryCreate()
      Quick start method that sets up global OpenTelemetry with this Braintrust.

      If you're looking for more options for configuring Braintrust/OpenTelemetry, consult the `enable` method.
    • openTelemetryCreate

      public io.opentelemetry.api.OpenTelemetry openTelemetryCreate(boolean registerGlobal)
      Quick start method that sets up OpenTelemetry with this Braintrust.

      If you're looking for more options for configuring Braintrust and OpenTelemetry, consult the `enable` method.
    • openTelemetryEnable

      public void openTelemetryEnable(@Nonnull io.opentelemetry.sdk.trace.SdkTracerProviderBuilder tracerProviderBuilder, @Nonnull io.opentelemetry.sdk.logs.SdkLoggerProviderBuilder loggerProviderBuilder, @Nonnull io.opentelemetry.sdk.metrics.SdkMeterProviderBuilder meterProviderBuilder)
      Add braintrust to existing open telemetry builders

      This method provides the most options for configuring Braintrust and OpenTelemetry. If you're looking for a more user-friendly setup, consult the `openTelemetryCreate` methods.

      NOTE: if your otel setup does not have any particular builder, pass an instance of the default provider builder. E.g. `SdkMeterProvider.builder()`

      NOTE: This method should only be invoked once. Enabling Braintrust multiple times is unsupported and may lead to undesired behavior
    • evalBuilder

      public <INPUT, OUTPUT> Eval.Builder<INPUT,OUTPUT> evalBuilder()
      Create a new eval builder
    • config

      public BraintrustConfig config()
    • apiClient

      public BraintrustApiClient apiClient()
    • promptLoader

      public BraintrustPromptLoader promptLoader()