API reference · Kjarni 0.2.7

Class KjarniChatClientExtensions

Namespace: Microsoft.Extensions.AI
Assembly: Kjarni.Extensions.AI.dll

Extension methods for exposing a Kjarni as an .

public static class KjarniChatClientExtensions

Inheritance

object ← KjarniChatClientExtensions

Methods

AddKjarniChatClient(IServiceCollection, string, string?, ChatMode, string, bool)

Registers a local Kjarni chat model as a singleton .

public static IServiceCollection AddKjarniChatClient(this IServiceCollection services, string model = "llama3.2-3b-instruct", string? systemPrompt = null, ChatMode mode = ChatMode.Default, string device = "cpu", bool quiet = true)

Parameters

services IServiceCollection

The service collection.

model string

Kjarni model name, e.g. llama3.2-3b-instruct.

systemPrompt string?

Default system prompt, or null for none.

mode ChatMode

Chat mode preset.

device string

"cpu" or "gpu".

quiet bool

Suppress model download/progress output.

Returns

IServiceCollection

Remarks

Registered as a singleton because model weights are loaded once and are expensive to re-initialize. The client serializes concurrent calls internally, so sharing one instance across requests is safe — but generation is compute-bound, so concurrent requests queue rather than overlap.

AsChatClient(Chat, string?, bool)

Wraps this in an .

public static IChatClient AsChatClient(this Chat chat, string? modelId = null, bool ownsChat = false)

Parameters

chat Chat

The chat instance to wrap.

modelId string?

Model identifier reported through metadata.

ownsChat bool

When true, disposing the returned client also disposes chat. Defaults to false so the caller keeps ownership of a chat it created.

Returns

IChatClient

Kjarni runs the same engine on every platform: