Solutions · Integrations · Microsoft.Extensions.AI

Drop into any IChatClient pipeline.

The LM-Kit.NET.Integrations.ExtensionsAI package implements IChatClient and IEmbeddingGenerator<string, Embedding<float>> on top of LM-Kit. If your codebase already speaks the Microsoft.Extensions.AI abstractions, swap one line and inference runs on a local model. Streaming works. Function calling works. Tools work. Existing middleware (logging, retry, telemetry) keeps working unchanged.

IChatClient IEmbeddingGenerator One line swap

Chat client

Streaming, multi-turn, function calling, structured output. Identical surface to the Microsoft abstractions.

Embedding generator

Drop-in IEmbeddingGenerator for any vector store. Pair with the LM-Kit catalogue's embedding models.

Middleware compatible

Existing chat-client middleware (logging, caching, function-invocation) works unchanged. Swap the implementation, keep the pipeline.

Why a bridge

The .NET ecosystem standardised on these abstractions.

Microsoft.Extensions.AI is becoming the canonical surface for AI interactions in .NET applications. Web hosts, background services, tools and SDKs increasingly accept any IChatClient. A local-first stack that ignores that abstraction forces every consumer to write a second integration. The bridge package means LM-Kit speaks the standard interface natively.

No rewrites

Code that already accepts IChatClient works as-is. Swap the constructor argument; inference now runs on-device.

Mix providers

Use LM-Kit for the local-first path and a cloud provider as a fallback under the same interface. Routing logic lives in the middleware, not in branch statements.

Function calling

The Microsoft abstraction's tool-invocation flow maps to LM-Kit's [LMFunction] binding. Functions registered for the abstract client run on-device.

Streaming

Token-by-token streaming via IAsyncEnumerable<StreamingChatCompletionUpdate>. Same async pattern your app already uses.

Embeddings interop

IEmbeddingGenerator implementation plugs into vector stores that consume the abstraction. RAG pipelines built on the standard interface stay portable.

DI native

Register the LM-Kit chat client through IServiceCollection like any other implementation. No bespoke configuration surface.

One line

Register and use.

Register an LM-Kit-backed IChatClient and IEmbeddingGenerator in DI with one line each.

Program.cs
using Microsoft.Extensions.AI;
using LMKit.Integrations.ExtensionsAI;

var model = LM.LoadFromModelID("qwen3.5:4b");

// Register the LM-Kit-backed IChatClient.
builder.Services.AddSingleton<IChatClient>(_ => model.AsChatClient());

// Embeddings too.
var embedder = LM.LoadFromModelID("qwen3-embedding:0.6b");
builder.Services.AddSingleton<IEmbeddingGenerator<string, Embedding<float>>>(_ => embedder.AsEmbeddingGenerator());
Where the bridge fits

Existing apps, local backend.

Migrate from cloud to local

An existing app builds against IChatClient with a cloud provider. Swap the registration; inference now runs on the box. Customers keep their data.

Hybrid routing

Route sensitive requests to the local LM-Kit client and bulk requests to a cloud provider. Both implement the same interface; routing is one decorator.

Library publishers

A NuGet that consumes IChatClient works with LM-Kit out of the box. No need for the library author to know about LM-Kit at all.

Existing telemetry & middleware

Logging, caching, retry middleware written against the abstraction works unchanged. The bridge participates as a regular client.

Vector store interop

Vector stores that consume IEmbeddingGenerator get an on-device embedder for free. Local RAG without an API key.

Tests and CI

Run end-to-end tests against the abstraction with the LM-Kit implementation in CI. No external API quota, no flaky network.

Related capabilities

Bridge plus the rest.

Semantic Kernel bridge

The other major .NET AI abstraction. Same idea: drop LM-Kit into existing pipelines.

Semantic Kernel bridge

Tools & function calling

When you need finer control than the abstraction provides, the native Tools API is one constructor away.

Tools & function calling

Multimodal embeddings

Pair the embedding generator with the multimodal embedding catalogue for image-and-text vector spaces.

Multimodal embeddings

Document RAG

When the abstraction is not enough for full-document workflows, the native RAG primitives offer source attribution and adaptive ingestion.

Document RAG

Demos & docs

Build it. Read it. Try it.

Working console demos on GitHub, step-by-step how-to guides on the docs site, and the API reference for the classes used on this page.

Existing pipeline. Local backend.

Get Community Edition Download