Semantic Kernel Guide 2025: Microsoft's AI Orchestration SDK
Microsoft Semantic Kernel is the open-source SDK powering Copilot — giving .NET, Python, and Java developers a structured way to compose LLMs, plugins, memory, and agents into production AI applications.
What Is Semantic Kernel?
Semantic Kernel (SK) is an open-source AI SDK from Microsoft that connects large language models to your existing code. Rather than sending raw prompts and parsing strings, you define plugins (collections of functions the LLM can invoke), memory (vector-store-backed context retrieval), and agents that plan and execute multi-step workflows autonomously.
Microsoft uses Semantic Kernel internally for Microsoft 365 Copilot, Bing, and Azure AI Studio. The SDK is battle-tested at enterprise scale and designed for production — not just demos.
Install (choose your language)
# Python pip install semantic-kernel # .NET dotnet add package Microsoft.SemanticKernel # Java (Maven) # Add to pom.xml: com.microsoft.semantic-kernel:semantickernel-api
Core Concepts
Semantic Kernel has four building blocks:
- Kernel — the central orchestrator. Holds AI services, plugins, and memory. Every SK app starts with a
Kernelinstance. - Plugins — collections of functions exposed to the AI. A plugin can be native code (a C#/Python class with annotated methods) or a prompt template (a semantic function). The AI calls them by name.
- Memory & Vector Stores — embeddings-backed stores for long-term context. SK connects to Azure AI Search, Chroma, Qdrant, Pinecone, Postgres (pgvector), and more.
- Agents & Planner — autonomous agents that decompose a goal into steps, select plugins, and iterate until the task is done. The
ChatCompletionAgentis the standard single-agent pattern;AgentGroupChathandles multi-agent collaboration.
Quickstart: Python
Connect to OpenAI and call a prompt in five lines:
quickstart.py
import asyncio
from semantic_kernel import Kernel
from semantic_kernel.connectors.ai.open_ai import OpenAIChatCompletion
async def main():
kernel = Kernel()
kernel.add_service(OpenAIChatCompletion(
ai_model_id="gpt-4o",
api_key="sk-...",
))
result = await kernel.invoke_prompt(
"Summarize the key benefits of {{$topic}} in 3 bullet points.",
topic="vector databases"
)
print(result)
asyncio.run(main())
For Azure OpenAI, swap OpenAIChatCompletion with AzureChatCompletion and pass your endpoint + deployment name.
Creating Plugins
Plugins expose your business logic to the AI. Decorate methods with @kernel_function and the AI can discover and call them:
plugins/weather_plugin.py
from semantic_kernel.functions import kernel_function
class WeatherPlugin:
@kernel_function(
name="get_current_weather",
description="Returns current weather for a city",
)
def get_current_weather(self, city: str) -> str:
# Replace with real weather API call
return f"{city}: 22°C, partly cloudy"
@kernel_function(
name="get_forecast",
description="Returns 5-day weather forecast for a city",
)
def get_forecast(self, city: str, days: int = 5) -> str:
return f"{city} forecast for {days} days: mostly sunny" Register plugin with kernel
kernel.add_plugin(WeatherPlugin(), plugin_name="Weather")
# The AI can now call Weather-get_current_weather and Weather-get_forecast
result = await kernel.invoke_prompt(
"What's the weather like in Kyiv and should I bring an umbrella tomorrow?"
) Agents & Auto Function Calling
The ChatCompletionAgent automatically decides which plugins to call to answer a user query — no explicit planner configuration needed with GPT-4o class models:
agent.py
from semantic_kernel.agents import ChatCompletionAgent
from semantic_kernel.connectors.ai.function_choice_behavior import (
FunctionChoiceBehavior,
)
agent = ChatCompletionAgent(
service_id="openai",
kernel=kernel,
name="WeatherAssistant",
instructions="You are a helpful weather assistant. Use plugins to answer questions.",
execution_settings=kernel.get_prompt_execution_settings_from_service_id(
"openai"
),
)
# Agent automatically invokes Weather plugin as needed
async for content in agent.invoke(
messages=[{"role": "user", "content": "Compare weather in London and Tokyo tomorrow"}]
):
print(content.content, end="") Memory & Vector Search
SK's memory layer lets agents retrieve relevant context from a vector store before answering. Connect any supported store:
from semantic_kernel.connectors.memory.chroma import ChromaMemoryStore
from semantic_kernel.memory import SemanticTextMemory
from semantic_kernel.core_plugins import TextMemoryPlugin
# Connect to Chroma (also works with Qdrant, Pinecone, Azure AI Search, etc.)
memory_store = ChromaMemoryStore(persist_directory="./chroma_db")
memory = SemanticTextMemory(
storage=memory_store,
embeddings_generator=kernel.get_service("openai"),
)
kernel.add_plugin(TextMemoryPlugin(memory), "memory")
# Save facts
await memory.save_information("docs", id="faq1",
text="Prismix tracks 75+ AI service statuses in real time.")
# Retrieve relevant context (AI calls this automatically via TextMemoryPlugin)
results = await memory.search("docs", "how many services does Prismix monitor?") Supported vector stores: Azure AI Search, Chroma, Qdrant, Pinecone, Postgres (pgvector), Weaviate, Milvus, Redis, MongoDB Atlas, and SQLite-vec.
C# Quickstart (.NET)
Program.cs
using Microsoft.SemanticKernel;
var builder = Kernel.CreateBuilder();
builder.AddOpenAIChatCompletion("gpt-4o", Environment.GetEnvironmentVariable("OPENAI_API_KEY")!);
var kernel = builder.Build();
// Add a native plugin
kernel.ImportPluginFromType<MathPlugin>();
// Invoke with auto function calling
var result = await kernel.InvokePromptAsync(
"What is 1234 times 5678?",
new KernelArguments(new OpenAIPromptExecutionSettings {
ToolCallBehavior = ToolCallBehavior.AutoInvokeKernelFunctions
})
);
Console.WriteLine(result); Semantic Kernel vs LangChain vs AutoGen
| Framework | Best for | Language | Agents |
|---|---|---|---|
| Semantic Kernel | Enterprise .NET / Azure apps | C#, Python, Java | Yes (ChatCompletionAgent, GroupChat) |
| LangChain | Broad Python ecosystem | Python, JS/TS | Yes (LangGraph) |
| AutoGen | Multi-agent conversations | Python | Yes (core focus) |
| LlamaIndex | RAG / data ingestion pipelines | Python, TS | Basic |
See also: LangChain guide · DSPy guide · Haystack guide
Supported AI Models
Semantic Kernel is model-agnostic via its connector system:
- OpenAI — GPT-4o, GPT-4o mini, GPT-4 Turbo, o1, o3
- Azure OpenAI — same models via your own Azure deployment
- Anthropic — Claude 3.5 Sonnet, Claude 3 Haiku (via connector)
- Google — Gemini 1.5 Pro, Gemini 2.0 Flash
- Ollama — any locally running model via OpenAI-compatible endpoint
- Hugging Face — models via Inference API or self-hosted TGI/vLLM
- Mistral — Mistral Large, Mistral Small
Monitor the AI APIs Your SK App Depends On
Semantic Kernel apps call OpenAI, Azure OpenAI, Anthropic, and others under the hood. When those APIs go down, your agent stops. Prismix tracks real-time status for 75+ AI services and sends alerts the moment something degrades.
Check AI API Status →