Gravicode.TypeSafeSdk 1.1.0

dotnet add package Gravicode.TypeSafeSdk --version 1.1.0
                    
NuGet\Install-Package Gravicode.TypeSafeSdk -Version 1.1.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Gravicode.TypeSafeSdk" Version="1.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Gravicode.TypeSafeSdk" Version="1.1.0" />
                    
Directory.Packages.props
<PackageReference Include="Gravicode.TypeSafeSdk" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Gravicode.TypeSafeSdk --version 1.1.0
                    
#r "nuget: Gravicode.TypeSafeSdk, 1.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Gravicode.TypeSafeSdk@1.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Gravicode.TypeSafeSdk&version=1.1.0
                    
Install as a Cake Addin
#tool nuget:?package=Gravicode.TypeSafeSdk&version=1.1.0
                    
Install as a Cake Tool

TypeSafe .NET SDK

Unofficial, strongly typed .NET 10 client for the TypeSafe System One API, ported from the official Python SDK.

dotnet add package Gravicode.TypeSafeSdk

Ask a question about some text

using TypeSafeSdk;

await using var client = new TypeSafeClient(TypeSafeOptions.FromEnvironment());

var response = await client.SystemOneAsync(
    new { document = "I was charged twice. Please fix this ASAP." },
    Choice.Create("billing", "technical", "other"));

Console.WriteLine(response.Choices["category"].Choice);      // billing
Console.WriteLine(response.Choices["category"].Confidence);  // 1

Three kinds of question, one request

var response = await client.SystemOneAsync(
    new { document = ticket.Body },
    new Dictionary<string, object>
    {
        ["category"] = Choice.Create("billing", "technical", "other"),
        ["urgent"]   = new NoulSchema("Does this need a response within one hour?"),
        ["tone"]     = new ScoreSchema("How frustrated is the customer?", "calm", "annoyed", "angry")
    });

var queue    = response.Choices["category"].Choice;       // a label
var urgent   = response.Nouls["urgent"].IsTrue;           // a 0..1 value, thresholded
var tone     = response.Scores["tone"].NearestLabel;      // an expected value on a scale

Every answer carries its full probability distribution, so an ambiguous case is visible instead of hidden behind a single label.

Typed failures

TypeSafeApiException is the base for every HTTP failure, and each one carries StatusCode, Body, Headers, Endpoint, and RequestId.

catch (TypeSafeRateLimitException ex) { await Task.Delay(ex.RetryAfter ?? TimeSpan.FromSeconds(1)); }
catch (TypeSafeAuthenticationException) { /* 401 — retrying will not help */ }
catch (TypeSafeApiTimeoutException ex) { logger.LogWarning("Timed out after {Timeout}", ex.Timeout); }

Also available: TypeSafeBadRequestException, TypeSafePermissionDeniedException, TypeSafeNotFoundException, TypeSafeUnprocessableEntityException, TypeSafeInternalServerException, TypeSafeApiConnectionException, and TypeSafeApiResponseValidationException.

Retry, timeout, headers

Defaults match the Python SDK: two retries, 0.5 s backoff doubling to a 5 s ceiling with 25% jitter, retrying 408/429/5xx, honouring Retry-After, inside a 30 s budget.

var options = new TypeSafeOptions
{
    Timeout = TimeSpan.FromSeconds(20),
    Retry   = new RetryPolicy(MaxRetries: 4),
    Headers = { ["X-Tenant"] = "acme" }
};

Any of it can be overridden per call, alongside extraHeaders and extraBody.

Tests without a key

await using var client = new TypeSafeClient(new TypeSafeOptions { Simulator = true });

The simulator answers choice, noul, and score questions locally and deterministically — no key, no network. It is lexical rather than semantic: it weights rare criteria words above common ones, honours negation, and abstains with a flat distribution when it finds no signal instead of guessing.

Configuration

TypeSafeOptions.FromEnvironment() reads TYPESAFE_API_KEY, TYPESAFE_BASE_URL, TYPESAFE_DEFAULT_MODEL, TYPESAFE_LOG_LEVEL, and TYPESAFE_SIMULATOR. The names are also constants on TypeSafeConstants.

Created by Gravicode Studios, led by Kang Fadhil. AI assistant: Jack — The Code Bender.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.0 78 9/24/2026

Parity pass against the official Python SDK: full typed exception hierarchy, request ids, Retry-After, client-level retry and timeout, custom headers and extra body, TypeSafeConstants, ListModelsResponse, and a simulator that answers choice, noul, and score questions.