Documentation
Table of Contents

Class IntentClient

Namespace
IntentSharp
Assembly
IntentSharp.dll

The one entry point. Holds the providers, options, memory, cache and rate limiter for an application. It sends a value and an intent to a model you choose, checks the reply against the result type and your rules, retries with the findings within the limits you set, and returns a typed result. Create it with IntentClientBuilder or services.AddIntentSharp(...). There is no static default instance.

public sealed class IntentClient : IAsyncDisposable, IDisposable
Inheritance
object
IntentClient
Implements
IAsyncDisposable
IDisposable
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.ReferenceEquals(object, object)
object.ToString()
Extension Methods

Properties

Cache

The request cache identical requests are served from, or null when there is none.

FallbackProvider

The provider used when the primary fails with a transient error, or null when there is none.

License

The license status, evaluated offline when the client was built. The date-based states of a valid key are refreshed at most once per LicenseReminderInterval while the client is used. Payload is a copy: enforcement never reads it back, so changing it changes nothing.

Memory

The memory completed requests are recorded in, or null when none is configured (WithMemory(ISemanticMemory?) with null). RecordInMemory and DoNotRecord can still turn recording off, and results served from the cache are not recorded.

Options

The client-wide options this client was built with. Treat them as read-only: they are validated once, when the client is built.

PrimaryProvider

The provider every request uses unless it names another through Provider.

RateLimiter

The rate limiter every completion and judge call waits on, or null when there is none. EmbedAsync(string, CancellationToken) calls do not wait on it.

TotalModelCalls

Model calls that returned a reply since this client was created: completions, judge calls and EmbedAsync(string, CancellationToken) calls. Calls that failed and replies served from the cache are not counted.

TotalUsage

Token totals since this client was created.

Methods

AsAmbient()

Makes this client ambient for the current async flow (see IntentClientScope).

Dispose()

Disposes the primary and the fallback provider when they implement IDisposable, including providers passed to UseProvider(IAIProvider) or UseFallbackProvider(IAIProvider): the client owns its providers, so do not share one provider instance between clients. Memory, cache, rate limiter and judge are not disposed.

DisposeAsync()

Disposes the primary and the fallback provider when they implement IDisposable, including providers passed to UseProvider(IAIProvider) or UseFallbackProvider(IAIProvider): the client owns its providers, so do not share one provider instance between clients. Memory, cache, rate limiter and judge are not disposed.

EmbedAsync(string, CancellationToken)

Returns an embedding from the first provider that supports embeddings, or null when none does.

ExecuteIntentAsync<T>(MethodInfo, object?, CancellationToken)

Executes a method decorated with AIIntentAttribute and optional AIGuardrailAttributes. The method body is not invoked; the attributes define the operation and input is the data.

GenerateAsync<T>(string, AIRequestOptions?, CancellationToken)

Runs an intent with no input value (generation).

TransformAsync(object?, string, AIRequestOptions?, CancellationToken)

Applies the intent to the input and returns text.

TransformAsync(object?, string, JsonNode, AIRequestOptions?, CancellationToken)

Applies the intent to the input and returns JSON that conforms to outputSchema, a shape defined at run time rather than by a .NET type. A strict copy of the schema is sent to the provider as the shape of the result. The reply is checked to be well-formed JSON; the schema's own rules are enforced only by validators (for example those registered by the intent catalog). Result values are detached copies.

TransformAsync<T>(object?, string, AIRequestOptions?, CancellationToken)

Applies intent to input and returns a verified T.