Semantic Kernel is Microsoft’s SDK for building AI apps and agents in C#, Python and Java. Its OpenAI connector works with other OpenAI-compatible services: Python takes your own OpenAI client, and C# takes a custom endpoint. BroadNet Inference serves standard chat completions at https://inference.broadnet.ai/v1, so either route works. BroadRouter is BroadNet’s own site; this follows Microsoft’s Semantic Kernel docs and the Python 1.47.0 source.
Python
pip install semantic-kernel
export BROADNET_API_KEY='your-broadnet-key'
import asyncio, 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://inference.broadnet.ai/v1", api_key=os.environ["BROADNET_API_KEY"])
chat = OpenAIChatCompletion(ai_model_id="broadnet/glm-5.3", async_client=client, service_id="broadnet")
async def main():
history = ChatHistory()
history.add_user_message("Give me three names for a billing microservice.")
settings = OpenAIChatPromptExecutionSettings(max_tokens=4000)
print(await chat.get_chat_message_content(chat_history=history, settings=settings))
asyncio.run(main())
ai_model_id is sent unchanged, so keep the broadnet/ prefix. The api_key argument of OpenAIChatCompletion is not needed when you pass a client.
Plugins and function calling
from semantic_kernel import Kernel
from semantic_kernel.connectors.ai.function_choice_behavior import FunctionChoiceBehavior
from semantic_kernel.functions import kernel_function
class Weather:
@kernel_function(description="Get the weather for a city.")
def get_weather(self, city: str) -> str:
return f"21C in {city}"
kernel = Kernel()
kernel.add_service(chat)
kernel.add_plugin(Weather(), plugin_name="weather")
settings = OpenAIChatPromptExecutionSettings(
max_tokens=4000,
function_choice_behavior=FunctionChoiceBehavior.Auto(),
)
# await chat.get_chat_message_content(chat_history=history, settings=settings, kernel=kernel)
Semantic Kernel sends the plugin as a tool named weather-get_weather, runs it when the model asks, and sends the result back. Use broadnet/glm-5.3 or broadnet/qwen3.8-27b; BroadNet’s docs list tools for these two only.
Agents
from semantic_kernel.agents import ChatCompletionAgent
agent = ChatCompletionAgent(service=chat, name="helper", instructions="Answer briefly.", plugins=[Weather()])
# response = await agent.get_response(messages="What's the weather in Dubai?")
C# (.NET)
Microsoft’s docs give this pattern for “other AI service providers that support the OpenAI chat completion API”. We did not run the C# version.
using Microsoft.SemanticKernel;
#pragma warning disable SKEXP0010
IKernelBuilder kernelBuilder = Kernel.CreateBuilder();
kernelBuilder.AddOpenAIChatCompletion(
modelId: "broadnet/glm-5.3",
apiKey: Environment.GetEnvironmentVariable("BROADNET_API_KEY"),
endpoint: new Uri("https://inference.broadnet.ai/v1")
);
Kernel kernel = kernelBuilder.Build();
Install the connector with dotnet add package Microsoft.SemanticKernel.Connectors.OpenAI.
Which model to pick
| Use | Model |
|---|---|
| Plugins, function calling, agents | broadnet/glm-5.3 |
| Plugins plus image input or Arabic text | broadnet/qwen3.8-27b |
| Chat and summaries without tools, flat-price plan | broadnet/deepseek-v4.1-flash |
How we tested this
On 2026-11-15 we installed semantic-kernel 1.47.0 for Python in a clean virtual environment and ran plain chat, streaming, automatic function calling and a ChatCompletionAgent against a local mock server that speaks BroadNet’s chat-completions shape. We read the logged requests. All went to /v1/chat/completions with the BroadNet model ID unchanged and a Bearer key. max_tokens was sent under that name, streaming added stream_options.include_usage, and function calling sent tool_choice: "auto". We had no BroadNet key, so we did not test real model output. The C# snippet is from Microsoft’s docs and was not run.
Troubleshooting
- 401. The key is wrong, expired or out of allowance.
- 404. The client
base_urlmust end in/v1. Check the model ID. Paid models need a top-up; the $5 credit covers onlybroadnet/gemma-4-26b-a4band the two Transcribe models. - Empty replies. Reasoning counts toward
max_tokenson DeepSeek V4.1 Flash, GLM 5.3 and Qwen3.8 27B. Raise it. Why answers come back empty. - Reasoning models and roles. Microsoft’s docs suggest
instruction_role="developer"for OpenAI reasoning models. BroadNet’s API reference doesn’t mention thedeveloperrole, so leaveinstruction_roleat its default. Our agent test sent instructions in asystemmessage. - 429. A pay-as-you-go key allows 30 requests a minute and 4 in flight. See errors and retries.
