Semantic Kernel
Semantic Kernel Python with an OpenAI-compatible uncensored API
Connect Semantic Kernel for Python to Abliterator by passing an AsyncOpenAI client to OpenAIChatCompletion, then stream replies and auto-invoke kernel functions.
OpenAIChatCompletion has no base URL argument in Python. Build AsyncOpenAI(base_url="https://abliterator.ai/v1", api_key=...) and pass it as async_client, with ai_model_id="kimi-k3.1-pro-abliterated".
Semantic Kernel's chat completion docs cover custom OpenAI-compatible endpoints for C#, but in Python the OpenAIChatCompletion connector takes no endpoint. The supported route is to hand it your own AsyncOpenAI client. Tested with semantic-kernel 1.47.
Install
pip install semantic-kernel
export ABL_API_KEY="sk-abl-v1-..."
Register Abliterator as a chat service
import asyncio
import os
from openai import AsyncOpenAI
from semantic_kernel.connectors.ai.open_ai import OpenAIChatCompletion, OpenAIChatPromptExecutionSettings
from semantic_kernel.contents import ChatHistory
client = AsyncOpenAI(base_url="https://abliterator.ai/v1", api_key=os.environ["ABL_API_KEY"])
chat = OpenAIChatCompletion(ai_model_id="kimi-k3.1-pro-abliterated", async_client=client, service_id="abliterator")
async def main() -> None:
history = ChatHistory(system_message="You are a vulnerability management lead.")
history.add_user_message("How should we prioritize 400 open findings when only 30 are internet-facing?")
settings = OpenAIChatPromptExecutionSettings(max_tokens=1024)
reply = await chat.get_chat_message_content(chat_history=history, settings=settings)
print(reply.content)
asyncio.run(main())
ai_model_id is required; Semantic Kernel sends it as model. The service_id lets you register both Abliterator models on one kernel and pick per call.
Streaming
get_streaming_chat_message_content returns an async generator of StreamingChatMessageContent chunks:
import asyncio
import os
from openai import AsyncOpenAI
from semantic_kernel.connectors.ai.open_ai import OpenAIChatCompletion, OpenAIChatPromptExecutionSettings
from semantic_kernel.contents import ChatHistory
chat = OpenAIChatCompletion(
ai_model_id="deepseek-v4.1-flash-abliterated",
async_client=AsyncOpenAI(base_url="https://abliterator.ai/v1", api_key=os.environ["ABL_API_KEY"]),
)
async def main() -> None:
history = ChatHistory()
history.add_user_message("Write a short phishing-awareness quiz with answers for new hires.")
async for chunk in chat.get_streaming_chat_message_content(
chat_history=history, settings=OpenAIChatPromptExecutionSettings()
):
if chunk:
print(str(chunk), end="", flush=True)
print()
asyncio.run(main())
Auto-invoked kernel functions
Plugins are classes whose methods carry @kernel_function. With FunctionChoiceBehavior.Auto(), the kernel sends them as tools, runs the ones the model picks and feeds the results back:
import asyncio
import os
from typing import Annotated
from openai import AsyncOpenAI
from semantic_kernel import Kernel
from semantic_kernel.connectors.ai import FunctionChoiceBehavior
from semantic_kernel.connectors.ai.open_ai import OpenAIChatCompletion, OpenAIChatPromptExecutionSettings
from semantic_kernel.contents import ChatHistory
from semantic_kernel.functions import kernel_function
class AssetPlugin:
@kernel_function(description="Return owner and exposure for a hostname.")
def get_asset(self, hostname: Annotated[str, "The hostname to look up"]) -> str:
return f"{hostname}: owner=payments-team, internet-facing=yes, last patched 2026-08-14"
kernel = Kernel()
kernel.add_service(
OpenAIChatCompletion(
ai_model_id="kimi-k3.1-pro-abliterated",
async_client=AsyncOpenAI(base_url="https://abliterator.ai/v1", api_key=os.environ["ABL_API_KEY"]),
)
)
kernel.add_plugin(AssetPlugin(), plugin_name="assets")
async def main() -> None:
chat = kernel.get_service(type=OpenAIChatCompletion)
settings = OpenAIChatPromptExecutionSettings(function_choice_behavior=FunctionChoiceBehavior.Auto())
history = ChatHistory()
history.add_user_message("CVE-2026-1234 affects pay-gw-01. Who owns it and how urgent is the patch?")
reply = await chat.get_chat_message_content(chat_history=history, settings=settings, kernel=kernel)
print(reply.content)
asyncio.run(main())
Pass kernel=kernel on the call; without it the service has no functions to invoke. For multi-agent setups, the same service works as the service of a ChatCompletionAgent.
Troubleshooting
ServiceInitializationError: The OpenAI API key is required.Noasync_clientwas passed, so the connector looked forOPENAI_API_KEY(andOPENAI_CHAT_MODEL_IDfor the model). Passai_model_idandasync_clientexplicitly.- Requests go to api.openai.com. You passed
api_key=toOpenAIChatCompletioninstead of a client. The key alone cannot change the host; useasync_client. - Functions never run. Either
function_choice_behavioris missing from the settings orkernelwas not passed toget_chat_message_content. - Do not use
OpenAIResponsesAgent. It targets the Responses API, which Abliterator does not serve. UseChatCompletionAgentor the chat service directly. - Embedding services.
OpenAITextEmbeddingwill fail against Abliterator, which has no embeddings endpoint. Register a separate embedding service for memory and vector stores.
Frequently asked questions
Where is the endpoint parameter in Semantic Kernel Python?
There isn't one on OpenAIChatCompletion. The connector accepts a ready-made openai.AsyncOpenAI client through async_client, and that client carries the base URL and key.
Does FunctionChoiceBehavior.Auto work with Abliterator models?
Yes. Semantic Kernel advertises your kernel functions as Chat Completions tools, Abliterator passes them to the model, and the kernel invokes whatever the model calls before asking it to continue.
Can I set reasoning effort from Semantic Kernel?
OpenAIChatPromptExecutionSettings has a reasoning_effort field that is sent as the reasoning_effort request parameter. Which values the Abliterator models accept is covered in the reasoning guide.