Class TypeSafeClient
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
httpClientHttpClientoptionsTypeSafeClientOptions
TypeSafeClient(string, HttpClient, TypeSafeClientOptions?)
Create a client with an explicit API key and HttpClient.
public TypeSafeClient(string apiKey, HttpClient httpClient, TypeSafeClientOptions? options = null)
Parameters
apiKeystringhttpClientHttpClientoptionsTypeSafeClientOptions
TypeSafeClient(string, TypeSafeClientOptions?)
Create a client with an explicit API key.
public TypeSafeClient(string apiKey, TypeSafeClientOptions? options = null)
Parameters
apiKeystringoptionsTypeSafeClientOptions
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
optionsTypeSafeClientOptions
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
DefaultModelName
Model used when a request omits model.
public const string DefaultModelName = "jev-latest"
Field Value
HttpClientName
Named HttpClient used with IHttpClientFactory.
public const string HttpClientName = "TypeSafe.AI"
Field Value
Properties
BaseUrl
API root with trailing slashes removed.
public string BaseUrl { get; }
Property Value
DefaultHeaders
Additional headers sent with each request.
public IReadOnlyDictionary<string, string> DefaultHeaders { get; }
Property Value
DefaultModel
Model used when a request omits model.
public string DefaultModel { get; }
Property Value
LogLevel
Configured log verbosity.
public TypeSafeLogLevel LogLevel { get; }
Property Value
Logger
The configured logger, filtered to LogLevel.
public ITypeSafeLogger Logger { get; }
Property Value
Models
The models available to the account.
public ModelsResource Models { get; }
Property Value
Retry
Retry settings with constructor overrides applied.
public RetryPolicy Retry { get; }
Property Value
TimeoutMs
Timeout per attempt in milliseconds.
public int TimeoutMs { get; }
Property Value
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
stateobjectquestionsIDictionary<string, Question>modelstringoptionsRequestOptionscancellationTokenCancellationToken
Returns
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
Returns
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
requestSystemOneRequestoptionsRequestOptionscancellationTokenCancellationToken
Returns
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
stateobjectquestionsIDictionary<string, Question>modelstringoptionsRequestOptionscancellationTokenCancellationToken
Returns
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
Returns
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
requestSystemOneRequestoptionsRequestOptionscancellationTokenCancellationToken