Semantic Kernel

Semantic Kernel C# with an OpenAI-compatible uncensored API

Use AddOpenAIChatCompletion with a custom endpoint to run Semantic Kernel for .NET on Abliterator: the SKEXP0010 pragma, streaming and auto function calling.

Reviewed Semantic KernelC#

Quick answer

Call builder.AddOpenAIChatCompletion(modelId: "kimi-k3.1-pro-abliterated", apiKey: key, endpoint: new Uri("https://abliterator.ai/v1")) inside #pragma warning disable SKEXP0010. The endpoint overload is marked experimental.

Microsoft's chat completion guide covers "other" OpenAI-compatible providers under the OpenAI connector: you pass an endpoint and suppress the SKEXP0010 experimental warning. The examples below follow that guide for .NET 8 console apps with top-level statements.

Install

dotnet new console -n AblKernel
cd AblKernel
dotnet add package Microsoft.SemanticKernel
export ABL_API_KEY="sk-abl-v1-..."

Microsoft.SemanticKernel pulls in the OpenAI connector. Get a key at /keys.

Register Abliterator and send a chat

Replace Program.cs with:

using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.ChatCompletion;

var apiKey = Environment.GetEnvironmentVariable("ABL_API_KEY")
    ?? throw new InvalidOperationException("Set ABL_API_KEY");

var builder = Kernel.CreateBuilder();
#pragma warning disable SKEXP0010
builder.AddOpenAIChatCompletion(
    modelId: "kimi-k3.1-pro-abliterated",
    apiKey: apiKey,
    endpoint: new Uri("https://abliterator.ai/v1"),
    httpClient: new HttpClient { Timeout = TimeSpan.FromMinutes(10) });
#pragma warning restore SKEXP0010
Kernel kernel = builder.Build();

var chat = kernel.GetRequiredService<IChatCompletionService>();
var history = new ChatHistory("You are an application security engineer.");
history.AddUserMessage("Review this pattern: string sql = \"SELECT * FROM users WHERE id=\" + id; What is wrong and how do I fix it in C#?");

var reply = await chat.GetChatMessageContentAsync(history, kernel: kernel);
Console.WriteLine(reply.Content);

The endpoint is the full base URL including /v1; the OpenAI .NET client underneath appends /chat/completions.

Streaming

GetStreamingChatMessageContentsAsync returns an IAsyncEnumerable of chunks:

using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.ChatCompletion;

var builder = Kernel.CreateBuilder();
#pragma warning disable SKEXP0010
builder.AddOpenAIChatCompletion(
    modelId: "deepseek-v4.1-flash-abliterated",
    apiKey: Environment.GetEnvironmentVariable("ABL_API_KEY")!,
    endpoint: new Uri("https://abliterator.ai/v1"));
#pragma warning restore SKEXP0010
Kernel kernel = builder.Build();

var chat = kernel.GetRequiredService<IChatCompletionService>();
var history = new ChatHistory();
history.AddUserMessage("Explain the difference between authentication and authorization bugs, with one example of each.");

await foreach (var chunk in chat.GetStreamingChatMessageContentsAsync(history, kernel: kernel))
{
    Console.Write(chunk.Content);
}
Console.WriteLine();

Automatic function calling

Kernel functions are methods marked [KernelFunction]. With FunctionChoiceBehavior.Auto(), Semantic Kernel sends them as tools, invokes the ones the model calls and returns the final answer:

using System.ComponentModel;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.ChatCompletion;
using Microsoft.SemanticKernel.Connectors.OpenAI;

var builder = Kernel.CreateBuilder();
#pragma warning disable SKEXP0010
builder.AddOpenAIChatCompletion(
    modelId: "kimi-k3.1-pro-abliterated",
    apiKey: Environment.GetEnvironmentVariable("ABL_API_KEY")!,
    endpoint: new Uri("https://abliterator.ai/v1"));
#pragma warning restore SKEXP0010
builder.Plugins.AddFromType<FirewallPlugin>("firewall");
Kernel kernel = builder.Build();

var settings = new OpenAIPromptExecutionSettings
{
    FunctionChoiceBehavior = FunctionChoiceBehavior.Auto(),
    MaxTokens = 1024,
};

var chat = kernel.GetRequiredService<IChatCompletionService>();
var history = new ChatHistory();
history.AddUserMessage("Is RDP open to the internet on any of our edge firewalls? Recommend a change.");

var reply = await chat.GetChatMessageContentAsync(history, settings, kernel);
Console.WriteLine(reply.Content);

public sealed class FirewallPlugin
{
    [KernelFunction("list_inbound_rules")]
    [Description("List inbound allow rules on the edge firewalls.")]
    public string ListInboundRules() =>
        "fw-edge-1: allow any -> 10.0.2.15:3389 (rule 114, created 2025-02-03); allow any -> 10.0.2.20:443";
}

In a top-level program, class declarations must come after the statements, as here. kernel.InvokePromptAsync("...", new KernelArguments(settings)) uses the same settings if you prefer prompt functions to chat history.

Troubleshooting

  • error SKEXP0010. Projects with warnings-as-errors fail on the endpoint overload. Keep the #pragma lines, or add <NoWarn>$(NoWarn);SKEXP0010</NoWarn> to the .csproj.
  • 404 Not Found. The endpoint is missing /v1 or ends in /chat/completions. Use https://abliterator.ai/v1 exactly.
  • TaskCanceledException after 100 seconds. HttpClient's default timeout hit a long answer. Pass an HttpClient with a longer Timeout, as in the first example, or stream.
  • Functions are never called. FunctionChoiceBehavior was not set, or kernel was not passed to GetChatMessageContentAsync, so the service has no plugins to offer.
  • Embedding generators fail. Abliterator has no embeddings endpoint; register a separate embedding service for vector stores and memory.

Frequently asked questions

What is SKEXP0010 and is it safe to suppress?

It is Semantic Kernel's experimental-API diagnostic for the OpenAI connector overloads that take a custom endpoint. Suppressing it is the documented way to use OpenAI-compatible services; it only means the overload's signature may change in a future release.

Should I use the Azure OpenAI connector for Abliterator?

No. AddAzureOpenAIChatCompletion builds Azure deployment URLs and auth headers. Abliterator speaks the plain OpenAI format, so use AddOpenAIChatCompletion with endpoint.

Why do long answers time out after 100 seconds?

That is HttpClient's default Timeout. Pass your own HttpClient with a longer Timeout through the httpClient parameter, or stream the response so tokens arrive continuously.