Package dev.braintrust.api
Interface BraintrustApiClient
- All Known Implementing Classes:
BraintrustApiClient.HttpImpl,BraintrustApiClient.InMemoryImpl
public interface BraintrustApiClient
Provides the necessary API calls for the Braintrust SDK. Users of the SDK should favor using
Eval or BraintrustTracing-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final recordstatic final recordstatic final recordstatic final recordstatic final recordstatic final recordstatic final recordstatic final recordstatic final recordstatic final recordstatic final recordRepresents a Braintrust function (scorer, prompt, tool, or task).static final recordRequest body for invoking a function.static final recordstatic classstatic classImplementation for test doublingstatic final recordstatic final recordstatic final recordstatic final recordstatic final recordstatic final recordstatic final recordstatic final recordstatic final recordstatic final recordstatic final record -
Method Summary
Modifier and TypeMethodDescriptionfetchDatasetEvents(String datasetId, BraintrustApiClient.DatasetFetchRequest request) Fetch dataset events with paginationgetDataset(String datasetId) Get dataset metadata by IDgetFunction(String projectName, String slug, String version) Get a function by project name and slug, with optional version.Creates an experiment.getOrCreateProject(String projectName) Creates or gets a project by name.Get project and org info for the given config.getProject(String projectId) Gets a project by ID.Get project and org info for the default project IDgetProjectAndOrgInfo(String projectId) Get project and org info for the given project IDGet a prompt by slug and optional versioninvokeFunction(String functionId, BraintrustApiClient.FunctionInvokeRequest request) Invoke a function (scorer, prompt, or tool) by its ID.login()Attempt Braintrust loginstatic BraintrustApiClientof(BraintrustConfig config) queryDatasets(String projectName, String datasetName) Query datasets by project name and dataset name
-
Method Details
-
login
Attempt Braintrust login- Returns:
- LoginResponse containing organization info
- Throws:
LoginException- if login fails due to invalid credentials or network errors
-
getOrCreateProject
Creates or gets a project by name. -
getProject
Gets a project by ID. -
getOrCreateExperiment
BraintrustApiClient.Experiment getOrCreateExperiment(BraintrustApiClient.CreateExperimentRequest request) Creates an experiment. -
getProjectAndOrgInfo
Optional<BraintrustApiClient.OrganizationAndProjectInfo> getProjectAndOrgInfo()Get project and org info for the default project ID -
getProjectAndOrgInfo
Get project and org info for the given project ID -
getOrCreateProjectAndOrgInfo
BraintrustApiClient.OrganizationAndProjectInfo getOrCreateProjectAndOrgInfo(BraintrustConfig config) Get project and org info for the given config. Creating them if necessary -
getPrompt
Optional<BraintrustApiClient.Prompt> getPrompt(@Nonnull String projectName, @Nonnull String slug, @Nullable String version) Get a prompt by slug and optional version -
fetchDatasetEvents
BraintrustApiClient.DatasetFetchResponse fetchDatasetEvents(String datasetId, BraintrustApiClient.DatasetFetchRequest request) Fetch dataset events with pagination -
getDataset
Get dataset metadata by ID -
queryDatasets
Query datasets by project name and dataset name -
getFunction
Optional<BraintrustApiClient.Function> getFunction(@Nonnull String projectName, @Nonnull String slug, @Nullable String version) Get a function by project name and slug, with optional version.- Parameters:
projectName- the name of the project containing the functionslug- the unique slug identifier for the functionversion- optional version identifier (transaction id or version string)- Returns:
- the function if found
-
invokeFunction
Object invokeFunction(@Nonnull String functionId, @Nonnull BraintrustApiClient.FunctionInvokeRequest request) Invoke a function (scorer, prompt, or tool) by its ID.- Parameters:
functionId- the ID of the function to invokerequest- the invocation request containing input, expected output, etc.- Returns:
- the result of the function invocation
-
of
-