TypeSafeClient
Namespace: TypeSafe.AI.Sdk
public sealed class TypeSafeClient : ITypeSafeClient, IDisposableClient for the TypeSafe AI API. Community .NET port of @typesafe-ai/sdk.
Inheritance: object
Implements: ITypeSafeClient, IDisposable
Constructors
Section titled “Constructors”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 |
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 |
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 |
TypeSafeClient(TypeSafeClientOptions?)
Section titled “TypeSafeClient(TypeSafeClientOptions?)”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. |
Fields
Section titled “Fields”DefaultBaseUrl
Section titled “DefaultBaseUrl”public const string DefaultBaseUrl = "https://api.typesafe.ai"API root used when neither config nor TYPESAFE_BASE_URL is set.
Value: string
DefaultModelName
Section titled “DefaultModelName”public const string DefaultModelName = "jev-latest"Model used when a request omits model.
Value: string
HttpClientName
Section titled “HttpClientName”public const string HttpClientName = "TypeSafe.AI"Named HttpClient used with IHttpClientFactory.
Value: string
Properties
Section titled “Properties”BaseUrl
Section titled “BaseUrl”public string BaseUrl { get; }API root with trailing slashes removed.
Value: string
Compression
Section titled “Compression”public bool Compression { get; }Whether request bodies of 1 KiB or more are compressed with zstd.
Value: bool
DefaultHeaders
Section titled “DefaultHeaders”public IReadOnlyDictionary<string, string> DefaultHeaders { get; }Additional headers sent with each request.
Value: IReadOnlyDictionary<string, string>
DefaultModel
Section titled “DefaultModel”public string DefaultModel { get; }Model used when a request omits model.
Value: string
LogLevel
Section titled “LogLevel”public TypeSafeLogLevel LogLevel { get; }Configured log verbosity.
Value: TypeSafeLogLevel
Logger
Section titled “Logger”public ITypeSafeLogger Logger { get; }The configured logger, filtered to LogLevel.
Value: ITypeSafeLogger
Models
Section titled “Models”public ModelsResource Models { get; }The models available to the account.
Value: ModelsResource
public RetryPolicy Retry { get; }Retry settings with constructor overrides applied.
Value: RetryPolicy
TimeoutMs
Section titled “TimeoutMs”public int TimeoutMs { get; }Timeout per attempt in milliseconds.
Value: int
Methods
Section titled “Methods”Dispose()
Section titled “Dispose()”public void Dispose()Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
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>
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>
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>
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>>
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>>
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 |
MIT · Copyright (c) Dario Kondratiuk. · not affiliated with TypeSafe beyond being a client of the public API