Elastic.Extensions.AI 0.48.0

Prefix Reserved
dotnet add package Elastic.Extensions.AI --version 0.48.0
                    
NuGet\Install-Package Elastic.Extensions.AI -Version 0.48.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Elastic.Extensions.AI" Version="0.48.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Elastic.Extensions.AI" Version="0.48.0" />
                    
Directory.Packages.props
<PackageReference Include="Elastic.Extensions.AI" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Elastic.Extensions.AI --version 0.48.0
                    
#r "nuget: Elastic.Extensions.AI, 0.48.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Elastic.Extensions.AI@0.48.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Elastic.Extensions.AI&version=0.48.0
                    
Install as a Cake Addin
#tool nuget:?package=Elastic.Extensions.AI&version=0.48.0
                    
Install as a Cake Tool

Elastic.Extensions.AI

Microsoft.Extensions.AI integration for the Elastic Agent Builder.

Turns Kibana agents into standard IChatClient instances and connects to the Kibana MCP server — so agent tools are immediately usable with any IChatClient pipeline.

Why?

Microsoft.Extensions.AI defines a unified abstraction layer (IChatClient, IEmbeddingGenerator, AIFunction) for working with AI services in .NET. This package bridges Elastic Agent Builder into that ecosystem:

  • ElasticAgentChatClient : IChatClient — wrap any Kibana agent as a standard chat client, composable with ChatClientBuilder middleware (function invocation, OpenTelemetry, caching, rate limiting).
  • MCP tool discovery — connect to the Kibana MCP server and get back McpClientTool instances that implement AIFunction, ready to use with any IChatClient.
  • DI extensions — one-liner registration for ASP.NET Core / Generic Host apps.

Quick Start — IChatClient

using Elastic.Transport;
using Elastic.Clients.AgentBuilder;
using Elastic.Extensions.AI;
using Microsoft.Extensions.AI;

var config = new AgentTransportConfiguration("my-cloud-id", new ApiKey("key"));
var agentClient = new AgentBuilderClient(config);

// Wrap as IChatClient
IChatClient chatClient = new ElasticAgentChatClient(agentClient, agentId: "my-agent");

// Use with the standard M.E.AI API
var response = await chatClient.GetResponseAsync("What are our top books?");
Console.WriteLine(response.Messages.Last().Text);
Console.WriteLine($"Tokens: {response.Usage?.InputTokenCount} in / {response.Usage?.OutputTokenCount} out");

With Kibana Spaces

var config = new AgentTransportConfiguration("my-cloud-id", new ApiKey("key"))
{
    Space = "analytics"
};
var agentClient = new AgentBuilderClient(config);
IChatClient chatClient = new ElasticAgentChatClient(agentClient, agentId: "my-agent");

Quick Start — MCP Tools

using Elastic.Extensions.AI;
using ModelContextProtocol.Client;

// Connect to the Kibana MCP endpoint
var mcpClient = await AgentBuilderMcp.CreateClientAsync(
    new Uri("https://my-kibana:5601"), "base64apikey");

// List tools — each implements AIFunction
IList<McpClientTool> tools = await mcpClient.ListToolsAsync();

// Pass to any IChatClient
var response = await chatClient.GetResponseAsync(
    "Find the longest book",
    new ChatOptions { Tools = [.. tools] });

Dependency Injection

using Elastic.Extensions.AI;

// In Program.cs — using a Cloud ID
builder.Services.AddElasticAgentBuilder(
    new AgentTransportConfiguration("my-cloud-id", new ApiKey("base64key")),
    agentId: "my-agent");

// Inject anywhere
public class MyService(IChatClient chatClient, AgentBuilderClient agentClient)
{
    public async Task<string> AskAsync(string question)
    {
        var response = await chatClient.GetResponseAsync(question);
        return response.Messages.Last().Text;
    }
}

With a direct Kibana URL and space:

builder.Services.AddElasticAgentBuilder(
    new AgentTransportConfiguration(new Uri("https://my-kibana:5601"), new ApiKey("key"))
    {
        Space = "my-space"
    },
    agentId: "my-agent");

ChatClientBuilder Middleware

Because ElasticAgentChatClient implements IChatClient, it composes with the full ChatClientBuilder pipeline:

IChatClient chatClient = new ChatClientBuilder(
        new ElasticAgentChatClient(agentClient, "my-agent"))
    .UseFunctionInvocation()   // auto-invoke MCP tools
    .UseOpenTelemetry()        // traces + metrics
    .Build();

Conversations

The ConversationId from ChatOptions / ChatResponse maps directly to the Kibana conversation ID, enabling multi-turn conversations:

var r1 = await chatClient.GetResponseAsync("What books do we have?");
Console.WriteLine(r1.Messages.Last().Text);

// Continue the conversation
var r2 = await chatClient.GetResponseAsync(
    [new ChatMessage(ChatRole.User, "Who wrote the longest one?")],
    new ChatOptions { ConversationId = r1.ConversationId });
Console.WriteLine(r2.Messages.Last().Text);
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 is compatible. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.48.0 45 6/3/2026
0.47.0 42 6/3/2026
0.46.0 44 6/2/2026
0.45.0 101 5/12/2026
0.44.1 98 5/12/2026
0.44.0 97 5/11/2026
0.43.0 100 4/20/2026
0.42.0 105 4/20/2026
0.41.2 107 4/15/2026
0.41.1 102 4/15/2026
0.41.0 126 3/31/2026