Provides an implementation of IChatClient and IEmbeddingGenerator for Kimi/DeepSeek API and OpenAI-compatible endpoints, based on Microsoft.Extensions.AI.
From the command-line:
dotnet add package Community.Extensions.AI.CompatibleAIusing OpenAI;
using Microsoft.Extensions.AI;
IChatClient client = new OpenAIClient("kimi-k2.5", Environment.GetEnvironmentVariable("API_KEY"))
.AsIChatClient();
Console.WriteLine(await client.GetResponseAsync("What is AI?"));using OpenAI;
using Microsoft.Extensions.AI;
IChatClient client = new OpenAIClient("kimi-k2.5", Environment.GetEnvironmentVariable("API_KEY"))
.AsIChatClient();
Console.WriteLine(await client.GetResponseAsync(
[
new ChatMessage(ChatRole.System, "You are a helpful AI assistant"),
new ChatMessage(ChatRole.User, "What is AI?")
]));using OpenAI;
using Microsoft.Extensions.AI;
IChatClient client = new OpenAIClient("kimi-k2.5", Environment.GetEnvironmentVariable("API_KEY"))
.AsIChatClient();
await foreach (var update in client.GetStreamingResponseAsync("What is AI?"))
{
Console.Write(update);
}using OpenAI;
using System.ComponentModel;
using Microsoft.Extensions.AI;
IChatClient client = new OpenAIClient("deepseek-v4-flash", Environment.GetEnvironmentVariable("API_KEY"))
.AsIChatClient();
ChatOptions chatOptions = new()
{
Tools = [AIFunctionFactory.Create(GetWeather)]
};
await foreach (var message in client.GetStreamingResponseAsync("Do I need an umbrella?", chatOptions))
{
Console.Write(message);
}
[Description("Gets the weather")]
static string GetWeather() =>
Random.Shared.NextDouble() > 0.5 ? "It's sunny" : "It's raining";- Compatible with Kimi/DeepSeek API
- Supports OpenAI-compatible endpoints
- Fully integrates with
Microsoft.Extensions.AI - Supports streaming, tool-calling, caching, telemetry, and DI
API_KEY=your_api_keyOptional custom endpoint:
BASE_URL=https://api.moonshot.cn/v1
# BASE_URL=https://api.deepseek.comThis package is adapted from Microsoft.Extensions.AI.OpenAI and modified to support Kimi/DeepSeek API while preserving the same programming model.
Same as upstream project.
