Table of Contents

Class TypeSafeClient

Namespace
TypeSafe.AI.Sdk
Assembly
TypeSafe.AI.Sdk.dll

Client for the TypeSafe AI API. Community .NET port of @typesafe-ai/sdk.

public sealed class TypeSafeClient : ITypeSafeClient, IDisposable
Inheritance
TypeSafeClient
Implements
Inherited Members

Constructors

TypeSafeClient(HttpClient, TypeSafeClientOptions?)

Create a client that uses the given HttpClient (typically from IHttpClientFactory).

public TypeSafeClient(HttpClient httpClient, TypeSafeClientOptions? options = null)

Parameters

httpClient HttpClient
options TypeSafeClientOptions

TypeSafeClient(string, HttpClient, TypeSafeClientOptions?)

Create a client with an explicit API key and HttpClient.

public TypeSafeClient(string apiKey, HttpClient httpClient, TypeSafeClientOptions? options = null)

Parameters

apiKey string
httpClient HttpClient
options TypeSafeClientOptions

TypeSafeClient(string, TypeSafeClientOptions?)

Create a client with an explicit API key.

public TypeSafeClient(string apiKey, TypeSafeClientOptions? options = null)

Parameters

apiKey string
options TypeSafeClientOptions

TypeSafeClient(TypeSafeClientOptions?)

Create a client. Explicit options take precedence over environment variables, then SDK defaults. Empty or whitespace-only environment values are ignored.

public TypeSafeClient(TypeSafeClientOptions? options = null)

Parameters

options TypeSafeClientOptions

Exceptions

TypeSafeException

The API key is missing or configuration is invalid.

Fields

DefaultBaseUrl

API root used when neither config nor TYPESAFE_BASE_URL is set.

public const string DefaultBaseUrl = "https://api.typesafe.ai"

Field Value

string

DefaultModelName

Model used when a request omits model.

public const string DefaultModelName = "jev-latest"

Field Value

string

HttpClientName

Named HttpClient used with IHttpClientFactory.

public const string HttpClientName = "TypeSafe.AI"

Field Value

string

Properties

BaseUrl

API root with trailing slashes removed.

public string BaseUrl { get; }

Property Value

string

DefaultHeaders

Additional headers sent with each request.

public IReadOnlyDictionary<string, string> DefaultHeaders { get; }

Property Value

IReadOnlyDictionary<string, string>

DefaultModel

Model used when a request omits model.

public string DefaultModel { get; }

Property Value

string

LogLevel

Configured log verbosity.

public TypeSafeLogLevel LogLevel { get; }

Property Value

TypeSafeLogLevel

Logger

The configured logger, filtered to LogLevel.

public ITypeSafeLogger Logger { get; }

Property Value

ITypeSafeLogger

Models

The models available to the account.

public ModelsResource Models { get; }

Property Value

ModelsResource

Retry

Retry settings with constructor overrides applied.

public RetryPolicy Retry { get; }

Property Value

RetryPolicy

TimeoutMs

Timeout per attempt in milliseconds.

public int TimeoutMs { get; }

Property Value

int

Methods

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

SystemOneAsync(object?, IDictionary<string, Question>, string?, RequestOptions?, CancellationToken)

Answer named questions about text or structured state.

public Task<SystemOneResult> SystemOneAsync(object? state, IDictionary<string, Question> questions, string? model = null, RequestOptions? options = null, CancellationToken cancellationToken = default)

Parameters

state object
questions IDictionary<string, Question>
model string
options RequestOptions
cancellationToken CancellationToken

Returns

Task<SystemOneResult>

SystemOneAsync(object?, params (string Name, Question Question)[])

Answer named questions about text or structured state. Duplicate names throw. Use the dictionary overload for model, options, or a cancellation token.

public Task<SystemOneResult> SystemOneAsync(object? state, params (string Name, Question Question)[] questions)

Parameters

state object
questions (string Name, Question Question)[]

Returns

Task<SystemOneResult>

SystemOneAsync(SystemOneRequest, RequestOptions?, CancellationToken)

Answer named questions about text or structured state.

public Task<SystemOneResult> SystemOneAsync(SystemOneRequest request, RequestOptions? options = null, CancellationToken cancellationToken = default)

Parameters

request SystemOneRequest
options RequestOptions
cancellationToken CancellationToken

Returns

Task<SystemOneResult>

SystemOneWithResponseAsync(object?, IDictionary<string, Question>, string?, RequestOptions?, CancellationToken)

Answer named questions and return the HTTP response metadata.

public Task<TypeSafeResponse<SystemOneResult>> SystemOneWithResponseAsync(object? state, IDictionary<string, Question> questions, string? model = null, RequestOptions? options = null, CancellationToken cancellationToken = default)

Parameters

state object
questions IDictionary<string, Question>
model string
options RequestOptions
cancellationToken CancellationToken

Returns

Task<TypeSafeResponse<SystemOneResult>>

SystemOneWithResponseAsync(object?, params (string Name, Question Question)[])

Answer named questions and return the HTTP response metadata. Duplicate names throw. Use the dictionary overload for model, options, or a cancellation token.

public Task<TypeSafeResponse<SystemOneResult>> SystemOneWithResponseAsync(object? state, params (string Name, Question Question)[] questions)

Parameters

state object
questions (string Name, Question Question)[]

Returns

Task<TypeSafeResponse<SystemOneResult>>

SystemOneWithResponseAsync(SystemOneRequest, RequestOptions?, CancellationToken)

Answer named questions and return the HTTP response metadata.

public Task<TypeSafeResponse<SystemOneResult>> SystemOneWithResponseAsync(SystemOneRequest request, RequestOptions? options = null, CancellationToken cancellationToken = default)

Parameters

request SystemOneRequest
options RequestOptions
cancellationToken CancellationToken

Returns

Task<TypeSafeResponse<SystemOneResult>>