BroadRouter
Get started

Use Semantic Kernel with BroadNet Inference

Updated

In Python, create AsyncOpenAI with base_url https://inference.broadnet.ai/v1 and your BroadNet key, then pass it as async_client to OpenAIChatCompletion with ai_model_id set to a BroadNet ID such as broadnet/glm-5.3. In C#, call AddOpenAIChatCompletion with an endpoint Uri, which Microsoft marks experimental (SKEXP0010). Use GLM 5.3 or Qwen3.8 27B for plugins.

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

Prices for every model.

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_url must end in /v1. Check the model ID. Paid models need a top-up; the $5 credit covers only broadnet/gemma-4-26b-a4b and the two Transcribe models.
  • Empty replies. Reasoning counts toward max_tokens on 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 the developer role, so leave instruction_role at its default. Our agent test sent instructions in a system message.
  • 429. A pay-as-you-go key allows 30 requests a minute and 4 in flight. See errors and retries.

Questions

How do I set a custom base URL in Semantic Kernel for Python?

OpenAIChatCompletion has no base_url argument in version 1.47. Create an openai.AsyncOpenAI client with base_url and api_key, and pass it as async_client. That client then sends every request to BroadNet.

Why does the C# custom endpoint need a pragma?

Microsoft's docs say using custom endpoints with the OpenAI connector is experimental, so the endpoint overload needs

Does automatic function calling work with BroadNet?

It uses standard tool calls over chat completions, so use a model BroadNet lists with tools, GLM 5.3 or Qwen3.8 27B. In our mock test, Semantic Kernel sent the plugin as a tool and returned the result in a tool message.

Does Semantic Kernel's ChatCompletionAgent work on BroadNet?

Yes. It takes the same OpenAIChatCompletion service. In our Python test it sent the agent instructions as a system message and called the plugin through chat completions.

Read as MarkdownAsk ChatGPTAsk ClaudeAsk Perplexity