Class BraintrustConfig

java.lang.Object
dev.braintrust.config.BraintrustConfig

public final class BraintrustConfig extends Object
Configuration for Braintrust SDK with sane defaults.

Most SDK users will want to use envars to configure all Braintrust settings.

However, it's also possible to override any envar during config construction.

  • Field Details

  • Method Details

    • fromEnvironment

      public static BraintrustConfig fromEnvironment()
    • apiKey

      public String apiKey()
    • of

      public static BraintrustConfig of(String... envOverrides)
    • getBraintrustParentValue

      public Optional<String> getBraintrustParentValue()
      The parent attribute tells braintrust where to send otel data

      The otel ingestion endpoint looks for (a) braintrust.parent = project_id|project_name|experiment_id:value otel attribute and routes accordingly

      (b) if a span has no parent marked explicitly, it will look to see if there's an x-bt-parent http header (with the same format marked above e.g. project_name:andrew) that parent will apply to all spans in a request that don't have one

      If neither (a) nor (b) exists, the data is dropped
    • fetchProjectURI

      @Deprecated public URI fetchProjectURI()
      Deprecated.
      Deprecated. Please use Braintrust.projectUri() instead
    • builder

      public static BraintrustConfig.Builder builder()
    • apiUrl

      public String apiUrl()
    • appUrl

      public String appUrl()
    • tracesPath

      public String tracesPath()
    • logsPath

      public String logsPath()
    • defaultProjectId

      public Optional<String> defaultProjectId()
    • defaultProjectName

      public Optional<String> defaultProjectName()
    • enableTraceConsoleLog

      public boolean enableTraceConsoleLog()
    • debug

      public boolean debug()
    • requestTimeout

      public Duration requestTimeout()
    • filterAISpans

      public Boolean filterAISpans()
    • compressOtelPayload

      public Boolean compressOtelPayload()
      compress otel data before exporting to braintrust
    • autoConvertAIAttachments

      public Boolean autoConvertAIAttachments()
      When true (the default), the Braintrust span processor automatically extracts base64 data-URI attachments from LLM conversation spans, uploads them to object storage, and replaces the inline data with a lightweight reference. This reduces the size of spans exported to Braintrust.
    • sslContext

      public SSLContext sslContext()
      Custom SSL context for OTLP exporter. Builder-only field, not backed by envars.
    • x509TrustManager

      public X509TrustManager x509TrustManager()
      Custom X509 trust manager for OTLP exporter. Builder-only field, not backed by envars.
    • devserverCorsOriginWhitelistCsv

      public String devserverCorsOriginWhitelistCsv()
      CORS origins to allow when running remote eval devserver
    • getConfig

      @Nonnull protected <T> T getConfig(@Nonnull String settingName, @Nonnull T defaultValue)
    • getConfig

      @Nullable protected <T> T getConfig(@Nonnull String settingName, @Nullable T defaultValue, @Nonnull Class<T> settingClass)
    • getRequiredConfig

      @Nonnull protected String getRequiredConfig(@Nonnull String settingName)
    • getRequiredConfig

      @Nonnull protected <T> T getRequiredConfig(String settingName, Class<T> settingClass)
    • cast

      protected <T> T cast(@Nonnull String value, @Nonnull Class<T> clazz)
    • getEnvValue

      @Nullable protected String getEnvValue(@Nonnull String settingName)
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • canEqual

      protected boolean canEqual(Object other)
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object