Skip to content

TypeSafeClient

Namespace: TypeSafe.AI.Sdk

public sealed class TypeSafeClient : ITypeSafeClient, IDisposable

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

Inheritance: object

Implements: ITypeSafeClient, IDisposable

View source

TypeSafeClient(HttpClient, TypeSafeClientOptions?)

Section titled “TypeSafeClient(HttpClient, TypeSafeClientOptions?)”
public TypeSafeClient(HttpClient httpClient, TypeSafeClientOptions? options = null)

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

Parameters

Name Type Description
httpClient HttpClient
options TypeSafeClientOptions

View source

TypeSafeClient(string, HttpClient, TypeSafeClientOptions?)

Section titled “TypeSafeClient(string, HttpClient, TypeSafeClientOptions?)”
public TypeSafeClient(string apiKey, HttpClient httpClient, TypeSafeClientOptions? options = null)

Create a client with an explicit API key and HttpClient.

Parameters

Name Type Description
apiKey string
httpClient HttpClient
options TypeSafeClientOptions

View source

TypeSafeClient(string, TypeSafeClientOptions?)

Section titled “TypeSafeClient(string, TypeSafeClientOptions?)”
public TypeSafeClient(string apiKey, TypeSafeClientOptions? options = null)

Create a client with an explicit API key.

Parameters

Name Type Description
apiKey string
options TypeSafeClientOptions

View source

public TypeSafeClient(TypeSafeClientOptions? options = null)

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

Parameters

Name Type Description
options TypeSafeClientOptions

Exceptions

Type Condition
TypeSafeException The API key is missing or configuration is invalid.

View source

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

API root used when neither config nor TYPESAFE_BASE_URL is set.

Value: string

View source

public const string DefaultModelName = "jev-latest"

Model used when a request omits model.

Value: string

View source

public const string HttpClientName = "TypeSafe.AI"

Named HttpClient used with IHttpClientFactory.

Value: string

View source

public string BaseUrl { get; }

API root with trailing slashes removed.

Value: string

View source

public bool Compression { get; }

Whether request bodies of 1 KiB or more are compressed with zstd.

Value: bool

View source

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

Additional headers sent with each request.

Value: IReadOnlyDictionary<string, string>

View source

public string DefaultModel { get; }

Model used when a request omits model.

Value: string

View source

public TypeSafeLogLevel LogLevel { get; }

Configured log verbosity.

Value: TypeSafeLogLevel

View source

public ITypeSafeLogger Logger { get; }

The configured logger, filtered to LogLevel.

Value: ITypeSafeLogger

View source

public ModelsResource Models { get; }

The models available to the account.

Value: ModelsResource

View source

public RetryPolicy Retry { get; }

Retry settings with constructor overrides applied.

Value: RetryPolicy

View source

public int TimeoutMs { get; }

Timeout per attempt in milliseconds.

Value: int

View source

public void Dispose()

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

View source

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

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

Answer named questions about text or structured state.

Parameters

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

Returns: Task<SystemOneResult>

View source

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

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

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

Parameters

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

Returns: Task<SystemOneResult>

View source

SystemOneAsync(SystemOneRequest, RequestOptions?, CancellationToken)

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

Answer named questions about text or structured state.

Parameters

Name Type Description
request SystemOneRequest
options RequestOptions
cancellationToken CancellationToken

Returns: Task<SystemOneResult>

View source

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

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

Answer named questions and return the HTTP response metadata.

Parameters

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

Returns: Task<TypeSafeResponse<SystemOneResult>>

View source

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

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

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

Parameters

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

Returns: Task<TypeSafeResponse<SystemOneResult>>

View source

SystemOneWithResponseAsync(SystemOneRequest, RequestOptions?, CancellationToken)

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

Answer named questions and return the HTTP response metadata.

Parameters

Name Type Description
request SystemOneRequest
options RequestOptions
cancellationToken CancellationToken

Returns: Task<TypeSafeResponse<SystemOneResult>>

View source

MIT · Copyright (c) Dario Kondratiuk. · not affiliated with TypeSafe beyond being a client of the public API