TypeSafe SDK for .NET

Structured answers
from C#.

TypeSafe System One turns application state into Choice, Score, Noul, and Box answers. One NuGet package. The same questions as the JavaScript SDK.

Community port of @typesafe-ai/sdk by Dario Kondratiuk. Not an official TypeSafe product.

dotnet add package TypeSafe.AI.Sdk

One package. It targets net10.0 and netstandard2.0.TypeSafe.AI.Sdk on NuGet.

C#QuickstartGuide source
using TypeSafe.AI.Sdk;

using var client = new TypeSafeClient();
var response = await client.SystemOneAsync(
    new
    {
        document = "I was charged twice. Please fix this ASAP.",
    },
    (
        "category",
        Question.Choice(
            "What is this ticket about?",
            ("billing", null),
            ("technical", null),
            ("other", null))));

Console.WriteLine(
    response.GetChoice("category").Choice);
TypeSafeClient reads TYPESAFE_API_KEY

Package

TypeSafe.AI.Sdk

NuGet package id

Targets

net10.0

and netstandard2.0

Default model

jev-latest

TYPESAFE_DEFAULT_MODEL

License

MIT

Free for commercial use

Why this SDK

The same System One questions, in the C# you already write.

  • Choice, Score, Noul, and Box

    Question.Choice, Question.Score, Question.Noul, and Question.Box. Read them back with GetChoice, GetScore, GetNoul, and GetBox.

    Questions
  • Batch them in one call

    Independent questions go in one SystemOneAsync call. The state is your own object, the same way the JavaScript SDK takes state.

    Getting started
  • Images, when you opt in

    Experimental. PNG or JPEG, behind the TypeSafe-Danger-Zone-Images header.Question.Box locates a region with the jev-preview model.

    Images
  • Retries, compression, and DI

    Two retries by default, zstd on bodies of 1 KiB or more, and AddTypeSafeClient for IServiceCollection.

    Configuration

Get started

From an empty project to a typed answer, in three steps.

Install the package, call System One, then read the answer. Each step links to the page that has the rest.

Read the getting-started guide
  1. Install the package

    Add TypeSafe.AI.Sdk to a project that targets net10.0 or netstandard2.0.

    dotnet add package TypeSafe.AI.Sdk
    Getting started
  2. Call System One

    TypeSafeClient reads TYPESAFE_API_KEY. Pass state and one or more questions to SystemOneAsync.

    using var client = new TypeSafeClient();
    Quickstart
  3. Read the answer

    GetChoice returns the label, probabilities, and confidence. Score, Noul, and Box have their own readers.

    Console.WriteLine(response.GetChoice("category").Choice);
    Questions