The LangSmith Java SDK provides convenient access to the LangSmith REST API from applications written in Java.
To learn more about LangSmith, check out the docs.
The REST API documentation can be found on docs.smith.langchain.com. Javadocs are available on javadoc.io.
implementation("com.langchain.smith0.1.0-alpha.23")
<dependency>
<groupId>com.langchain.smith</groupId>
<artifactId>langsmith-java</artifactId>
<version>0.1.0-alpha.23</version>
</dependency>
This library requires Java 8 or later.
import com.langchain.smith.client.LangsmithClient;
import com.langchain.smith.client.okhttp.LangsmithOkHttpClient;
import com.langchain.smith.models.runs.RunQueryParams;
// Configures using the `langchain.langsmithApiKey`, `langchain.langsmithTenantId`, `langchain.langsmithBearerToken`, `langchain.langsmithOrganizationId` and `langchain.baseUrl` system properties
// Or configures using the `LANGSMITH_API_KEY`, `LANGSMITH_TENANT_ID`, `LANGSMITH_BEARER_TOKEN`, `LANGSMITH_ORGANIZATION_ID` and `LANGSMITH_ENDPOINT` environment variables
LangsmithClient client = LangsmithOkHttpClient.fromEnv();
RunQueryParams params = RunQueryParams.builder()
.addSession("1ffaeba7-541e-469f-bae7-df3208ea3d45")
.limit(10L)
.build();
var response = client.runs().query(params);
// Print runs
System.out.println("Found " + response.runs().size() + " runs:");
for (var run : response.runs()) {
System.out.println("Run ID: " + run.id());
System.out.println("Run Name: " + run.name());
System.out.println("---");
}
This repository includes runnable examples in the langsmith-java-example module to help you get started.
Examples can be run using Gradle:
# Set required environment variables
export LANGSMITH_API_KEY="your-api-key"
export LANGSMITH_ENDPOINT="https://api.smith.langchain.com"
# Run a specific example
./gradlew run -Pexample=ListRuns
export LANGSMITH_PROJECT_ID="your-project-id"
./gradlew run -Pexample=ListRuns
All examples are available in langsmith-java-example.
Configure the client using system properties or environment variables:
import com.langchain.smith.client.LangsmithClient;
import com.langchain.smith.client.okhttp.LangsmithOkHttpClient;
// Configures using the `langchain.langsmithApiKey`, `langchain.langsmithTenantId`, `langchain.langsmithBearerToken`, `langchain.langsmithOrganizationId` and `langchain.baseUrl` system properties
// Or configures using the `LANGSMITH_API_KEY`, `LANGSMITH_TENANT_ID`, `LANGSMITH_BEARER_TOKEN`, `LANGSMITH_ORGANIZATION_ID` and `LANGSMITH_ENDPOINT` environment variables
LangsmithClient client = LangsmithOkHttpClient.fromEnv();
Or manually:
import com.langchain.smith.client.LangsmithClient;
import com.langchain.smith.client.okhttp.LangsmithOkHttpClient;
LangsmithClient client = LangsmithOkHttpClient.builder()
.apiKey("My API Key")
.tenantId("My Tenant ID")
.organizationId("My Organization ID")
.build();
Or using a combination of the two approaches:
import com.langchain.smith.client.LangsmithClient;
import com.langchain.smith.client.okhttp.LangsmithOkHttpClient;
LangsmithClient client = LangsmithOkHttpClient.builder()
// Configures using the `langchain.langsmithApiKey`, `langchain.langsmithTenantId`, `langchain.langsmithBearerToken`, `langchain.langsmithOrganizationId` and `langchain.baseUrl` system properties
// Or configures using the `LANGSMITH_API_KEY`, `LANGSMITH_TENANT_ID`, `LANGSMITH_BEARER_TOKEN`, `LANGSMITH_ORGANIZATION_ID` and `LANGSMITH_ENDPOINT` environment variables
.fromEnv()
.apiKey("My API Key")
.build();
See this table for the available options:
| Setter | System property | Environment variable | Required | Default value |
|---|---|---|---|---|
apiKey |
langchain.langsmithApiKey |
LANGSMITH_API_KEY |
false | - |
tenantId |
langchain.langsmithTenantId |
LANGSMITH_TENANT_ID |
false | - |
bearerToken |
langchain.langsmithBearerToken |
LANGSMITH_BEARER_TOKEN |
false | - |
organizationId |
langchain.langsmithOrganizationId |
LANGSMITH_ORGANIZATION_ID |
false | - |
baseUrl |
langchain.baseUrl |
LANGSMITH_ENDPOINT |
true | "https://api.smith.langchain.com/" |
System properties take precedence over environment variables.
[!TIP] Don't create more than one client in the same application. Each client has a connection pool and thread pools, which are more efficient to share between requests.
To temporarily use a modified client configuration, while reusing the same connection and thread pools, call withOptions() on any client or service:
import com.langchain.smith.client.LangsmithClient;
LangsmithClient clientWithOptions = client.withOptions(optionsBuilder -> {
optionsBuilder.baseUrl("https://example.com");
optionsBuilder.maxRetries(42);
});
The withOptions() method does not affect the original client or service.
To send a request to the LangChain API, build an instance of some Params class and pass it to the corresponding client method. When the response is received, it will be deserialized into an instance of a Java class.
For example, client.sessions().dashboard(...) should be called with an instance of SessionDashboardParams, and it will return an instance of CustomChartsSection.
Each class in the SDK has an associated builder or factory method for constructing it.
Each class is immutable once constructed. If the class has an associated builder, then it has a toBuilder() method, which can be used to convert it back to a builder for making a modified copy.
Because each class is immutable, builder modification will never affect already built class instances.
The default client is synchronous. To switch to asynchronous execution, call the async() method:
import com.langchain.smith.client.LangsmithClient;
import com.langchain.smith.client.okhttp.LangsmithOkHttpClient;
import com.langchain.smith.models.sessions.CustomChartsSection;
import com.langchain.smith.models.sessions.CustomChartsSectionRequest;
import com.langchain.smith.models.sessions.SessionDashboardParams;
import java.util.concurrent.CompletableFuture;
// Configures using the `langchain.langsmithApiKey`, `langchain.langsmithTenantId`, `langchain.langsmithBearerToken`, `langchain.langsmithOrganizationId` and `langchain.baseUrl` system properties
// Or configures using the `LANGSMITH_API_KEY`, `LANGSMITH_TENANT_ID`, `LANGSMITH_BEARER_TOKEN`, `LANGSMITH_ORGANIZATION_ID` and `LANGSMITH_ENDPOINT` environment variables
LangsmithClient client = LangsmithOkHttpClient.fromEnv();
SessionDashboardParams params = SessionDashboardParams.builder()
.sessionId("1ffaeba7-541e-469f-bae7-df3208ea3d45")
.customChartsSectionRequest(CustomChartsSectionRequest.builder().build())
.build();
CompletableFuture<CustomChartsSection> customChartsSection = client.async().sessions().dashboard(params);
Or create an asynchronous client from the beginning:
import com.langchain.smith.client.LangsmithClientAsync;
import com.langchain.smith.client.okhttp.LangsmithOkHttpClientAsync;
import com.langchain.smith.models.sessions.CustomChartsSection;
import com.langchain.smith.models.sessions.CustomChartsSectionRequest;
import com.langchain.smith.models.sessions.SessionDashboardParams;
import java.util.concurrent.CompletableFuture;
// Configures using the `langchain.langsmithApiKey`, `langchain.langsmithTenantId`, `langchain.langsmithBearerToken`, `langchain.langsmithOrganizationId` and `langchain.baseUrl` system properties
// Or configures using the `LANGSMITH_API_KEY`, `LANGSMITH_TENANT_ID`, `LANGSMITH_BEARER_TOKEN`, `LANGSMITH_ORGANIZATION_ID` and `LANGSMITH_ENDPOINT` environment variables
LangsmithClientAsync client = LangsmithOkHttpClientAsync.fromEnv();
SessionDashboardParams params = SessionDashboardParams.builder()
.sessionId("1ffaeba7-541e-469f-bae7-df3208ea3d45")
.customChartsSectionRequest(CustomChartsSectionRequest.builder().build())
.build();
CompletableFuture<CustomChartsSection> customChartsSection = client.sessions().dashboard(params);
The asynchronous client supports the same options as the synchronous one, except most methods return CompletableFutures.
The SDK defines methods that accept files.
To upload a file, pass a Path:
import com.langchain.smith.models.examples.Example;
import com.langchain.smith.models.examples.ExampleUploadFromCsvParams;
import java.nio.file.Paths;
ExampleUploadFromCsvParams params = ExampleUploadFromCsvParams.builder()
.datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.addInputKey("string")
.file(Paths.get("/path/to/file"))
.build();
List<Example> examples = client.examples().uploadFromCsv(params);
Or an arbitrary InputStream:
import com.langchain.smith.models.examples.Example;
import com.langchain.smith.models.examples.ExampleUploadFromCsvParams;
import java.net.URL;
ExampleUploadFromCsvParams params = ExampleUploadFromCsvParams.builder()
.datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.addInputKey("string")
.file(new URL("https://example.com//path/to/file").openStream())
.build();
List<Example> examples = client.examples().uploadFromCsv(params);
Or a byte[] array:
import com.langchain.smith.models.examples.Example;
import com.langchain.smith.models.examples.ExampleUploadFromCsvParams;
ExampleUploadFromCsvParams params = ExampleUploadFromCsvParams.builder()
.datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.addInputKey("string")
.file("content".getBytes())
.build();
List<Example> examples = client.examples().uploadFromCsv(params);
Note that when passing a non-Path its filename is unknown so it will not be included in the request. To manually set a filename, pass a MultipartField:
import com.langchain.smith.core.MultipartField;
import com.langchain.smith.models.examples.Example;
import com.langchain.smith.models.examples.ExampleUploadFromCsvParams;
import java.io.InputStream;
import java.net.URL;
ExampleUploadFromCsvParams params = ExampleUploadFromCsvParams.builder()
.datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.addInputKey("string")
.file(MultipartField.<InputStream>builder()
.value(new URL("https://example.com//path/to/file").openStream())
.filename("/path/to/file")
.build())
.build();
List<Example> examples = client.examples().uploadFromCsv(params);
The SDK defines methods that deserialize responses into instances of Java classes. However, these methods don't provide access to the response headers, status code, or the raw response body.
To access this data, prefix any HTTP method call on a client or service with withRawResponse():
import com.langchain.smith.core.http.Headers;
import com.langchain.smith.core.http.HttpResponseFor;
import com.langchain.smith.models.sessions.CustomChartsSection;
import com.langchain.smith.models.sessions.CustomChartsSectionRequest;
import com.langchain.smith.models.sessions.SessionDashboardParams;
SessionDashboardParams params = SessionDashboardParams.builder()
.sessionId("1ffaeba7-541e-469f-bae7-df3208ea3d45")
.customChartsSectionRequest(CustomChartsSectionRequest.builder().build())
.build();
HttpResponseFor<CustomChartsSection> customChartsSection = client.sessions().withRawResponse().dashboard(params);
int statusCode = customChartsSection.statusCode();
Headers headers = customChartsSection.headers();
You can still deserialize the response into an instance of a Java class if needed:
import com.langchain.smith.models.sessions.CustomChartsSection;
CustomChartsSection parsedCustomChartsSection = customChartsSection.parse();
The SDK throws custom unchecked exception types:
LangChainServiceException: Base class for HTTP errors. See this table for which exception subclass is thrown for each HTTP status code:
| Status | Exception |
|---|---|
| 400 | BadRequestException |
| 401 | UnauthorizedException |
| 403 | PermissionDeniedException |
| 404 | NotFoundException |
| 422 | UnprocessableEntityException |
| 429 | RateLimitException |
| 5xx | InternalServerException |
| others | UnexpectedStatusCodeException |
LangChainIoException: I/O networking errors.
LangChainRetryableException: Generic error indicating a failure that could be retried by the client.
LangChainInvalidDataException: Failure to interpret successfully parsed data. For example, when accessing a property that's supposed to be required, but the API unexpectedly omitted it from the response.
LangChainException: Base class for all exceptions. Most errors will result in one of the previously mentioned ones, but completely generic errors may be thrown using the base class.
The SDK defines methods that return a paginated lists of results. It provides convenient ways to access the results either one page at a time or item-by-item across all pages.
To iterate through all results across all pages, use the autoPager() method, which automatically fetches more pages as needed.
When using the synchronous client, the method returns an Iterable
import com.langchain.smith.models.datasets.Dataset;
import com.langchain.smith.models.datasets.DatasetListPage;
DatasetListPage page = client.datasets().list();
// Process as an Iterable
for (Dataset dataset : page.autoPager()) {
System.out.println(dataset);
}
// Process as a Stream
page.autoPager()
.stream()
.limit(50)
.forEach(dataset -> System.out.println(dataset));
When using the asynchronous client, the method returns an AsyncStreamResponse:
import com.langchain.smith.core.http.AsyncStreamResponse;
import com.langchain.smith.models.datasets.Dataset;
import com.langchain.smith.models.datasets.DatasetListPageAsync;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
CompletableFuture<DatasetListPageAsync> pageFuture = client.async().datasets().list();
pageFuture.thenRun(page -> page.autoPager().subscribe(dataset -> {
System.out.println(dataset);
}));
// If you need to handle errors or completion of the stream
pageFuture.thenRun(page -> page.autoPager().subscribe(new AsyncStreamResponse.Handler<>() {
@Override
public void onNext(Dataset dataset) {
System.out.println(dataset);
}
@Override
public void onComplete(Optional<Throwable> error) {
if (error.isPresent()) {
System.out.println("Something went wrong!");
throw new RuntimeException(error.get());
} else {
System.out.println("No more!");
}
}
}));
// Or use futures
pageFuture.thenRun(page -> page.autoPager()
.subscribe(dataset -> {
System.out.println(dataset);
})
.onCompleteFuture()
.whenComplete((unused, error) -> {
if (error != null) {
System.out.println("Something went wrong!");
throw new RuntimeException(error);
} else {
System.out.println("No more!");
}
}));
To access individual page items and manually request the next page, use the items(),
hasNextPage(), and nextPage() methods:
import com.langchain.smith.models.datasets.Dataset;
import com.langchain.smith.models.datasets.DatasetListPage;
DatasetListPage page = client.datasets().list();
while (true) {
for (Dataset dataset : page.items()) {
System.out.println(dataset);
}
if (!page.hasNextPage()) {
break;
}
page = page.nextPage();
}
The SDK uses the standard OkHttp logging interceptor.
Enable logging by setting the LANGCHAIN_LOG environment variable to info:
export LANGCHAIN_LOG=info
Or to debug for more verbose logging:
export LANGCHAIN_LOG=debug
Although the SDK uses reflection, it is still usable with ProGuard and R8 because langsmith-java-core is published with a configuration file containing keep rules.
ProGuard and R8 should automatically detect and use the published rules, but you can also manually copy the keep rules if necessary.
The SDK depends on Jackson for JSON serialization/deserialization. It is compatible with version 2.13.4 or higher, but depends on version 2.18.2 by default.
The SDK throws an exception if it detects an incompatible Jackson version at runtime (e.g. if the default version was overridden in your Maven or Gradle config).
If the SDK threw an exception, but you're certain the version is compatible, then disable the version check using the checkJacksonVersionCompatibility on LangsmithOkHttpClient or LangsmithOkHttpClientAsync.
[!CAUTION] We make no guarantee that the SDK works correctly when the Jackson version check is disabled.
Also note that there are bugs in older Jackson versions that can affect the SDK. We don't work around all Jackson bugs (example) and expect users to upgrade Jackson for those instead.
The SDK automatically retries 2 times by default, with a short exponential backoff between requests.
Only the following error types are retried:
The API may also explicitly instruct the SDK to retry or not retry a request.
To set a custom number of retries, configure the client using the maxRetries method:
import com.langchain.smith.client.LangsmithClient;
import com.langchain.smith.client.okhttp.LangsmithOkHttpClient;
LangsmithClient client = LangsmithOkHttpClient.builder()
.fromEnv()
.maxRetries(4)
.build();
Requests time out after 90 seconds by default.
To set a custom timeout, configure the method call using the timeout method:
import com.langchain.smith.models.sessions.CustomChartsSection;
CustomChartsSection customChartsSection = client.sessions().dashboard(
params, RequestOptions.builder().timeout(Duration.ofSeconds(30)).build()
);
Or configure the default for all method calls at the client level:
import com.langchain.smith.client.LangsmithClient;
import com.langchain.smith.client.okhttp.LangsmithOkHttpClient;
import java.time.Duration;
LangsmithClient client = LangsmithOkHttpClient.builder()
.fromEnv()
.timeout(Duration.ofSeconds(30))
.build();
To route requests through a proxy, configure the client using the proxy method:
import com.langchain.smith.client.LangsmithClient;
import com.langchain.smith.client.okhttp.LangsmithOkHttpClient;
import java.net.InetSocketAddress;
import java.net.Proxy;
LangsmithClient client = LangsmithOkHttpClient.builder()
.fromEnv()
.proxy(new Proxy(
Proxy.Type.HTTP, new InetSocketAddress(
"https://example.com", 8080
)
))
.build();
To customize the underlying OkHttp connection pool, configure the client using the maxIdleConnections and keepAliveDuration methods:
import com.langchain.smith.client.LangsmithClient;
import com.langchain.smith.client.okhttp.LangsmithOkHttpClient;
import java.time.Duration;
LangsmithClient client = LangsmithOkHttpClient.builder()
.fromEnv()
// If `maxIdleConnections` is set, then `keepAliveDuration` must be set, and vice versa.
.maxIdleConnections(10)
.keepAliveDuration(Duration.ofMinutes(2))
.build();
If both options are unset, OkHttp's default connection pool settings are used.
[!NOTE] Most applications should not call these methods, and instead use the system defaults. The defaults include special optimizations that can be lost if the implementations are modified.
To configure how HTTPS connections are secured, configure the client using the sslSocketFactory, trustManager, and hostnameVerifier methods:
import com.langchain.smith.client.LangsmithClient;
import com.langchain.smith.client.okhttp.LangsmithOkHttpClient;
LangsmithClient client = LangsmithOkHttpClient.builder()
.fromEnv()
// If `sslSocketFactory` is set, then `trustManager` must be set, and vice versa.
.sslSocketFactory(yourSSLSocketFactory)
.trustManager(yourTrustManager)
.hostnameVerifier(yourHostnameVerifier)
.build();
The SDK consists of three artifacts:
langsmith-java-core
LangsmithClient, LangsmithClientAsync, LangsmithClientImpl, and LangsmithClientAsyncImpl, all of which can work with any HTTP clientlangsmith-java-client-okhttp
LangsmithOkHttpClient and LangsmithOkHttpClientAsync, which provide a way to construct LangsmithClientImpl and LangsmithClientAsyncImpl, respectively, using OkHttplangsmith-java
langsmith-java-core and langsmith-java-client-okhttpThis structure allows replacing the SDK's default HTTP client without pulling in unnecessary dependencies.
OkHttpClient[!TIP] Try the available network options before replacing the default client.
To use a customized OkHttpClient:
langsmith-java dependency with langsmith-java-corelangsmith-java-client-okhttp's OkHttpClient class into your code and customize itLangsmithClientImpl or LangsmithClientAsyncImpl, similarly to LangsmithOkHttpClient or LangsmithOkHttpClientAsync, using your customized clientTo use a completely custom HTTP client:
langsmith-java dependency with langsmith-java-coreHttpClient interfaceLangsmithClientImpl or LangsmithClientAsyncImpl, similarly to LangsmithOkHttpClient or LangsmithOkHttpClientAsync, using your new client classThe SDK is typed for convenient usage of the documented API. However, it also supports working with undocumented or not yet supported parts of the API.
To set undocumented parameters, call the putAdditionalHeader, putAdditionalQueryParam, or putAdditionalBodyProperty methods on any Params class:
import com.langchain.smith.core.JsonValue;
import com.langchain.smith.models.sessions.SessionDashboardParams;
SessionDashboardParams params = SessionDashboardParams.builder()
.putAdditionalHeader("Secret-Header", "42")
.putAdditionalQueryParam("secret_query_param", "42")
.putAdditionalBodyProperty("secretProperty", JsonValue.from("42"))
.build();
These can be accessed on the built object later using the _additionalHeaders(), _additionalQueryParams(), and _additionalBodyProperties() methods.
To set a documented parameter or property to an undocumented or not yet supported value, pass a JsonValue object to its setter:
import com.langchain.smith.models.sessions.CustomChartsSectionRequest;
import com.langchain.smith.models.sessions.SessionDashboardParams;
SessionDashboardParams params = SessionDashboardParams.builder()
.customChartsSectionRequest(CustomChartsSectionRequest.builder().build())
.build();
The most straightforward way to create a JsonValue is using its from(...) method:
import com.langchain.smith.core.JsonValue;
import java.util.List;
import java.util.Map;
// Create primitive JSON values
JsonValue nullValue = JsonValue.from(null);
JsonValue booleanValue = JsonValue.from(true);
JsonValue numberValue = JsonValue.from(42);
JsonValue stringValue = JsonValue.from("Hello World!");
// Create a JSON array value equivalent to `["Hello", "World"]`
JsonValue arrayValue = JsonValue.from(List.of(
"Hello", "World"
));
// Create a JSON object value equivalent to `{ "a": 1, "b": 2 }`
JsonValue objectValue = JsonValue.from(Map.of(
"a", 1,
"b", 2
));
// Create an arbitrarily nested JSON equivalent to:
// {
// "a": [1, 2],
// "b": [3, 4]
// }
JsonValue complexValue = JsonValue.from(Map.of(
"a", List.of(
1, 2
),
"b", List.of(
3, 4
)
));
Normally a Builder class's build method will throw IllegalStateException if any required parameter or property is unset.
To forcibly omit a required parameter or property, pass JsonMissing:
import com.langchain.smith.core.JsonMissing;
import com.langchain.smith.models.sessions.CustomChartsSectionRequest;
import com.langchain.smith.models.sessions.SessionDashboardParams;
SessionDashboardParams params = SessionDashboardParams.builder()
.customChartsSectionRequest(CustomChartsSectionRequest.builder().build())
.sessionId(JsonMissing.of())
.build();
To access undocumented response properties, call the _additionalProperties() method:
import com.langchain.smith.core.JsonValue;
import java.util.Map;
Map<String, JsonValue> additionalProperties = client.sessions().dashboard(params)._additionalProperties();
JsonValue secretPropertyValue = additionalProperties.get("secretProperty");
String result = secretPropertyValue.accept(new JsonValue.Visitor<>() {
@Override
public String visitNull() {
return "It's null!";
}
@Override
public String visitBoolean(boolean value) {
return "It's a boolean!";
}
@Override
public String visitNumber(Number value) {
return "It's a number!";
}
// Other methods include `visitMissing`, `visitString`, `visitArray`, and `visitObject`
// The default implementation of each unimplemented method delegates to `visitDefault`, which throws by default, but can also be overridden
});
To access a property's raw JSON value, which may be undocumented, call its _ prefixed method:
import com.langchain.smith.core.JsonField;
import java.util.Optional;
JsonField<Object> field = client.sessions().dashboard(params)._field();
if (field.isMissing()) {
// The property is absent from the JSON response
} else if (field.isNull()) {
// The property was set to literal null
} else {
// Check if value was provided as a string
// Other methods include `asNumber()`, `asBoolean()`, etc.
Optional<String> jsonString = field.asString();
// Try to deserialize into a custom type
MyClass myObject = field.asUnknown().orElseThrow().convert(MyClass.class);
}
In rare cases, the API may return a response that doesn't match the expected type. For example, the SDK may expect a property to contain a String, but the API could return something else.
By default, the SDK will not throw an exception in this case. It will throw LangChainInvalidDataException only if you directly access the property.
If you would prefer to check that the response is completely well-typed upfront, then either call validate():
import com.langchain.smith.models.sessions.CustomChartsSection;
CustomChartsSection customChartsSection = client.sessions().dashboard(params).validate();
Or configure the method call to validate the response using the responseValidation method:
import com.langchain.smith.models.sessions.CustomChartsSection;
CustomChartsSection customChartsSection = client.sessions().dashboard(
params, RequestOptions.builder().responseValidation(true).build()
);
Or configure the default for all method calls at the client level:
import com.langchain.smith.client.LangsmithClient;
import com.langchain.smith.client.okhttp.LangsmithOkHttpClient;
LangsmithClient client = LangsmithOkHttpClient.builder()
.fromEnv()
.responseValidation(true)
.build();
enum classes?Java enum classes are not trivially forwards compatible. Using them in the SDK could cause runtime exceptions if the API is updated to respond with a new enum value.
JsonField<T> instead of just plain T?Using JsonField<T> enables a few features:
data classes?It is not backwards compatible to add new fields to a data class and we don't want to introduce a breaking change every time we add a field to a class.
Checked exceptions are widely considered a mistake in the Java programming language. In fact, they were omitted from Kotlin for this reason.
Checked exceptions:
This package generally follows SemVer conventions, though certain backwards-incompatible changes may be released as minor versions:
We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.
We are keen for your feedback; please open an issue with questions, bugs, or suggestions.
A class representing the SDK client configuration..
A builder for [ClientOptions]..
A class containing timeouts for various processing phases of a request..
A class representing a serializable JSON field.
This class is a Jackson filter that can be used to exclude missing properties from objects.
A class representing an arbitrary JSON value.
A class representing a "known" JSON serializable value of type [T], matching the type the SDK
A [JsonValue] representing an omitted JSON field.
A [JsonValue] representing a JSON null value..
A [JsonValue] representing a JSON boolean value..
A [JsonValue] representing a JSON number value..
A [JsonValue] representing a JSON string value..
A [JsonValue] representing a JSON array value..
A [JsonValue] representing a JSON object value..
A class representing a field in a multipart/form-data request..
A builder for [BadRequestException]..
Exception that indicates a transient error that can be retried.
Configuration for OpenTelemetry trace export.
Utility object for creating OpenTelemetry spans with Gen AI semantic conventions.
Manages OpenTelemetry SDK for exporting traces to OTLP endpoints.
Simple Q&A agent that uses OpenAI to answer questions..
Creates a chat prompt manifest with multiple messages (system + user) compatible with LangSmith..
A class that allows building an instance of [LangsmithClient] with [OkHttpClient] as the
A builder for [LangsmithOkHttpClient]..
A class that allows building an instance of [LangsmithClientAsync] with [OkHttpClient] as the
Create Annotation Queue.
A builder for [AnnotationQueueAnnotationQueuesParams]..
AnnotationQueue schema..
Create Identity Annotation Queue Run Status.
Delete Annotation Queue.
Export Annotation Queue Archived Runs.
Populate annotation queue with runs from an experiment..
Get Annotation Queues.
AnnotationQueue schema with size..
Get Annotation Queue.
Get Annotation Queues For Run.
AnnotationQueue schema with rubric..
Get a run from an annotation queue.
Get Size From Annotation Queue.
Get Total Archived From Annotation Queue.
Get Total Size From Annotation Queue.
AnnotationQueue schema..
Size of an Annotation Queue.
Update Annotation Queue.
Run schema with annotation queue info..
Creates a new commit in a repository.
A builder for [CommitCreateParams]..
Lists all commits for a repository with pagination support.
Response model for get_commit_manifest..
Response model for example runs.
Retrieves a specific commit by hash, tag, or "latest" for a repository.
Dataset schema..
A builder for [Dataset]..
Clone a dataset..
Only modifications made on or before this time are included.
Create a new dataset..
Delete a specific dataset..
Get all datasets by query params and owner..
Enum for dataset data types..
Download a dataset as CSV format..
Download a dataset as CSV format..
Download a dataset as OpenAI Jsonl format..
Download a dataset as OpenAI Evals Jsonl format..
Get a specific dataset..
Get dataset version by as_of or exact tag..
Enum for dataset transformation types.
Update a specific dataset..
Set a tag on a dataset version..
Create a new dataset from a CSV or JSONL file..
Dataset version schema..
Schema used for creating feedback without run id or session id..
Specific value and label pair for feedback.
Feedback from the LangChainPlus App..
A builder for [AttachmentsOperations]..
Mapping of old attachment names to new names.
Example schema..
Create a new example..
Create class for Example..
Soft delete examples.
Soft delete an example.
Get all examples by query params.
Only modifications made on or before this time are included.
Count all examples by query params.
Get a specific example..
Update a specific example..
Upload examples from a CSV file.
API feedback source..
A builder for [ApiFeedbackSource]..
Feedback from the LangChainPlus App..
Auto eval feedback source..
Create a new feedback..
Schema used for creating feedback..
Specific value and label pair for feedback.
Feedback from the LangChainPlus App..
Delete a feedback..
List all Feedback by query params..
Get a specific feedback..
Schema for getting feedback..
Replace an existing feedback entry with a new, modified entry..
Schema used for updating feedback.
Model feedback source..
A builder for [PublicRetrieveFeedbacksPage]..
Read Shared Feedbacks.
A builder for [CreateRepoResponse]..
Create a repo..
Fields to create a repo.
Delete a repo..
Get all repos..
Get a repo..
Update a repo..
All database fields for repos, plus helpful computed fields..
A builder for [Run]..
Ingests a batch of runs in a single JSON payload.
Query Runs.
A builder for [CustomChartsSection]..
Include additional information about where the group_by param was set..
LGP Metrics you can chart..
Metrics you can chart.
Group by param for run stats..
Create a new session..
Create class for TracerSession..
Get a prebuilt dashboard for a tracing project..
Delete a specific session..
Get all sessions..
Get a specific session..
Create a new session..
Timedelta input..
TracerSession schema..
TracerSession schema..
A builder for [AppHubCrudTenantsTenant]..
Get settings..
Immutable context for experiment metadata that will be automatically attached to OpenTelemetry
Configuration utility for setting up OpenTelemetry to export traces to LangSmith.
Wrapped OpenAI client that maintains the same developer experience as the original client while
Spring Boot example: Send OpenTelemetry traces to LangSmith.
Get information about the current deployment of LangSmith..
A builder for [InfoListParams]..
The LangSmith server info..
Batch ingest config..
Customer info..
Add Runs To Annotation Queue.
A builder for [RunCreateParams]..
Enum for available comparative experiment columns to sort by..
An interface that defines how to map each variant of [AsOf] to a value of type [T]..
An interface that defines how to map each variant of [Body] to a value of type [T]..
An interface that defines how to map each variant of [AsOf] to a value of type [T]..