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
<PackageReference Include="Elastic.Extensions.AI" Version="0.48.0" />
<PackageVersion Include="Elastic.Extensions.AI" Version="0.48.0" />
<PackageReference Include="Elastic.Extensions.AI" />
paket add Elastic.Extensions.AI --version 0.48.0
#r "nuget: Elastic.Extensions.AI, 0.48.0"
#:package Elastic.Extensions.AI@0.48.0
#addin nuget:?package=Elastic.Extensions.AI&version=0.48.0
#tool nuget:?package=Elastic.Extensions.AI&version=0.48.0
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 withChatClientBuildermiddleware (function invocation, OpenTelemetry, caching, rate limiting).- MCP tool discovery — connect to the Kibana MCP server and get back
McpClientToolinstances that implementAIFunction, ready to use with anyIChatClient. - 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 | Versions 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. |
-
.NETStandard 2.0
- Elastic.Clients.AgentBuilder (>= 0.48.0)
- Microsoft.Bcl.Memory (>= 10.0.5)
- Microsoft.Extensions.AI (>= 10.4.1)
- ModelContextProtocol (>= 1.1.0)
-
.NETStandard 2.1
- Elastic.Clients.AgentBuilder (>= 0.48.0)
- Microsoft.Bcl.Memory (>= 10.0.5)
- Microsoft.Extensions.AI (>= 10.4.1)
- ModelContextProtocol (>= 1.1.0)
-
net10.0
- Elastic.Clients.AgentBuilder (>= 0.48.0)
- Microsoft.Bcl.Memory (>= 10.0.5)
- Microsoft.Extensions.AI (>= 10.4.1)
- ModelContextProtocol (>= 1.1.0)
-
net8.0
- Elastic.Clients.AgentBuilder (>= 0.48.0)
- Microsoft.Bcl.Memory (>= 10.0.5)
- Microsoft.Extensions.AI (>= 10.4.1)
- ModelContextProtocol (>= 1.1.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.