Skip to content

Latest commit

 

History

History
40 lines (28 loc) · 1.49 KB

File metadata and controls

40 lines (28 loc) · 1.49 KB

Braintrust API client

The SDK ships a low-level HTTP client for the Braintrust REST API.

If you just want to run evals or trace AI calls, prefer dev.braintrust.eval.Eval and dev.braintrust.trace.BraintrustTracing. Reach for the API client only when you need raw REST access.

The client is generated code. Every resource, method, and model comes from Braintrust's public OpenAPI spec:

Basic usage

import dev.braintrust.api.BraintrustOpenApiClient;
import dev.braintrust.config.BraintrustConfig;
import dev.braintrust.openapi.api.ProjectsApi;
import dev.braintrust.openapi.model.CreateProject;
import dev.braintrust.openapi.model.Project;

var client = BraintrustOpenApiClient.of(BraintrustConfig.fromEnvironment());
var projects = new ProjectsApi(client);

// Create a project. Model classes use fluent setters (not a builder).
Project created = projects.postProject(
        new CreateProject().name("my-project").description("created from java"));

System.out.println(created.getId() + " " + created.getName());

Runnable example

A complete, runnable example can be found in examples/api-client.

Run it with BRAINTRUST_API_KEY=sk-... ./gradlew :examples:api-client:run.