shipwithjev

Catalog / Tools & apps

0494GitHub

typesafe-sdk-java

Zero-dependency Java client (Java 21+).

kgonia/typesafe-sdk-javaREADME ↗
# TypeSafe Java SDK

Zero-dependency Java client for the [TypeSafe AI](https://typesafe.ai) System One API. Requires Java 21 or newer.

TypeSafe turns natural language and application state into typed judgments: yes/no probabilities, choices with
full distributions, and scores on rubrics you define. Learn what you can build in the
[TypeSafe docs](https://docs.typesafe.ai/).

## Quickstart

Add the dependency:

```xml
<dependency>
    <groupId>io.github.kgonia</groupId>
    <artifactId>typesafe-sdk</artifactId>
    <version>0.1.0</version>
</dependency>
```

Set `TYPESAFE_API_KEY` in your environment (create a key in the [console](https://console.typesafe.ai/)), then:

```java
import io.github.kgonia.typesafe.TypeSafeClient;
import io.github.kgonia.typesafe.systemone.*;
import java.util.Map;

try (TypeSafeClient client = TypeSafeClient.create()) {
    SystemOneResponse response = client.systemOne(
        Map.of("document", "I was charged twice. Please fix this ASAP."),
        Map.of(
            "billing", Question.noul("Is this ticket about billing?"),
            "tone", Question.choice("What is the customer's tone?", "calm", "frustrated", "angry"),
            "urgency", Question.score("How urgent is this ticket?", "can wait", "this week", "today")));

    System.out.println(response.noul("billing").noul());      // 0.97
    System.out.println(response.choice("tone").choice());     // "frustrated"
    System.out.println(response.score("urgency").score());    // 1.8
}
```

## Questions and answers

| Need                                | Question                                  | Answer                                                   |
|-------------------------------------|-------------------------------------------|-----------------------------------------------

Also filed under Tools & apps