Microsoft Semantic Kernel: LLM Orchestration for .NET & Python
Microsoft Semantic Kernel is an enterprise-grade, open-source LLM orchestration framework for C#, Python, and Java. It powers Microsoft Copilot products and Azure AI, offering a Kernel/Plugin/Planner architecture for composing LLM calls, native function tools, memory recall, and autonomous AI agents. The top choice for teams building on the Microsoft/Azure ecosystem.
Related Products
on GumroadDeveloper Productivity Bundle
Stop rebuilding the same setup every project. 51 VSCode snippets, 40 Git aliases, 5 Docker Compose stacks, 5 GitHub Actions workflows, 5 README templates, and a dotfiles kit. Set up a professional dev environment in under an hour.
Buy on Gumroad →AI Prompt Engineering Toolkit
58 structured prompt templates for Claude, ChatGPT, and Gemini — organized by use case. Code Review, Debugging, Documentation, Architecture, and 10 model-specific tips. Stop writing prompts from scratch.
Buy on Gumroad →Developer Cheat Sheet Bundle
10 print-ready cheat sheets for the tools developers use every day: Git, Docker, Linux CLI, SQL, Regex, HTTP Status codes, VS Code shortcuts, Bash scripting, jq/JSON, and Markdown.
Buy on Gumroad →You Might Also Need
JSON Formatter & Validator
Format, beautify, and validate JSON online. Paste your JSON to instantly pretty-print it with 2-space, 4-space, or tab indentation. Minify JSON too. Free, runs in your browser.
Open free tool →
Regex Tester
Free regex tester. Test regular expressions against multiple strings with expected match/no-match assertions — see instant pass/fail results. Built-in presets for email, URL, IPv4, and phone. Pro: unl
Open free tool →
Base64 Encoder & Decoder
Free Base64 Encoder & Decoder. Convert text, images, and any file to Base64 and back. Supports URL-safe Base64, image data URIs, and file download from Base64. Runs 100% in your browser — no data sent
Open free tool →
More Free Tools
Related Articles
curl 深度使用手冊:API 測試從入門到進階
curl 是每位開發者必備的 CLI 工具。本文涵蓋 GET/POST/PUT/DELETE 請求、認證、header 設定、檔案上傳、除錯技巧,以及 REST API 測試的完整實戰範例。
Best AI Code Review Tools 2026: CodeRabbit, Sourcery, DeepCode & Bito Compared
Compare top AI code review tools for 2026: CodeRabbit, Sourcery, DeepCode, and Bito. Features, pricing, GitHub/GitLab integration, and choosing the right tool for your team.
AI Code Review Tools 2026: GitHub Copilot, CodeRabbit, Qodo Merge Ranked
Compare AI code review tools for 2026: GitHub Copilot code review, CodeRabbit, Qodo Merge, Sourcery, and PR-Agent. Pricing, accuracy, and GitHub integration.
AI Coding Tools Comparison 2026: GitHub Copilot vs Cursor vs Windsurf vs Cline
Comprehensive comparison of the best AI coding tools in 2026: GitHub Copilot, Cursor, Windsurf, and Cline. Pricing, features, model support, and real-world benchmarks.
AI Pair Programming in 2026: GitHub Copilot vs Cursor vs Claude Code
Master AI pair programming in 2026. Compare GitHub Copilot, Cursor, and Claude Code for autocomplete, chat, and agentic workflows. Includes setup guides and productivity tips.
Enjoying this tool? Get more like it.
Weekly developer tool guides, productivity playbooks & AI tricks. Free. No spam.
Unlock AI-Powered Dev Tools
- ⚡ AI Code Review, Doc Generator & SQL Builder
- ⚡ All premium templates & early access
- ⚡ Member discounts on Gumroad products
$9/mo after trial · Cancel anytime
Want the full toolkit?
Get DevPlaybook Pro
Every template, guide, boilerplate, and automation script in one bundle. 13 premium products — grab them all at once and save big.
MIT licensed · Instant download · No subscription
See what's included → Browse all deals →Python Quick Start: Kernel & Semantic Functions
Create a Kernel, add an AI service, define a semantic function, and invoke it with chat history.
pip install semantic-kernel
import asyncio
from semantic_kernel import Kernel
from semantic_kernel.connectors.ai.open_ai import OpenAIChatCompletion, OpenAITextEmbedding
from semantic_kernel.connectors.ai.function_choice_behavior import FunctionChoiceBehavior
from semantic_kernel.contents import ChatHistory
async def main():
# Create the kernel
kernel = Kernel()
# Add AI services
kernel.add_service(OpenAIChatCompletion(
service_id="gpt4",
ai_model_id="gpt-4o-mini",
api_key="YOUR_OPENAI_KEY"
))
# Or use Azure OpenAI
# from semantic_kernel.connectors.ai.open_ai import AzureChatCompletion
# kernel.add_service(AzureChatCompletion(
# service_id="azure_gpt4",
# deployment_name="gpt-4o",
# endpoint="https://YOUR.openai.azure.com/",
# api_key="YOUR_AZURE_KEY"
# ))
# Define a semantic function (prompt template)
summarize_fn = kernel.add_function(
plugin_name="TextPlugin",
function_name="summarize",
prompt="Summarize the following text in 2-3 sentences:\n\n{{$input}}",
description="Summarizes a text passage"
)
result = await kernel.invoke(summarize_fn, input="Semantic Kernel is Microsoft's SDK for integrating LLMs into applications...")
print(result)
asyncio.run(main()) Plugins: Semantic + Native Functions
Combine LLM semantic functions with regular Python code in a single plugin — the LLM can call both as tools.
from semantic_kernel.functions import kernel_function
from semantic_kernel.connectors.ai.open_ai import OpenAIChatPromptExecutionSettings
import datetime, httpx
class DevToolsPlugin:
"""Plugin with native + semantic functions for developer tools."""
@kernel_function(name="get_current_date", description="Returns today's date")
def get_current_date(self) -> str:
return datetime.date.today().isoformat()
@kernel_function(name="fetch_url", description="Fetches the content of a URL")
async def fetch_url(self, url: str) -> str:
async with httpx.AsyncClient() as client:
resp = await client.get(url, timeout=10)
return resp.text[:2000] # first 2000 chars
@kernel_function(
name="generate_commit_message",
description="Generate a git commit message for a code diff"
)
async def generate_commit_message(
self, kernel: "Kernel", diff: str
) -> str:
prompt = f"Write a concise git commit message for this diff:\n\n{diff}"
result = await kernel.invoke_prompt(prompt)
return str(result)
# Register the plugin
kernel.add_plugin(DevToolsPlugin(), plugin_name="DevTools")
# Let the LLM autonomously pick and call tools
settings = OpenAIChatPromptExecutionSettings(
function_choice_behavior=FunctionChoiceBehavior.Auto() # LLM decides which tools to call
)
chat_history = ChatHistory()
chat_history.add_user_message("What is today's date and what day of the week is it?")
response = await kernel.invoke_prompt(
prompt_template_config=None,
chat_history=chat_history,
settings=settings
)
print(response) Memory: Semantic Recall with Vector Stores
Save and retrieve memories using semantic similarity — connects to Chroma, Qdrant, Azure AI Search, and more.
from semantic_kernel.connectors.memory.chroma import ChromaMemoryStore
from semantic_kernel.core_plugins.text_memory_plugin import TextMemoryPlugin
# Add embedding service for memory
kernel.add_service(OpenAITextEmbedding(
service_id="embedder",
ai_model_id="text-embedding-3-small",
api_key="YOUR_OPENAI_KEY"
))
# Use Chroma as the vector memory store
memory_store = ChromaMemoryStore(persist_directory="./sk_memory")
# Register the memory plugin
await kernel.add_plugin(TextMemoryPlugin(memory_store), plugin_name="memory")
# Save facts to memory
await kernel.memory.save_information(
collection="user_prefs",
id="pref-1",
text="The user prefers Python over JavaScript for backend development",
)
await kernel.memory.save_information(
collection="user_prefs",
id="pref-2",
text="The user uses PostgreSQL with pgvector for vector search",
)
# Retrieve semantically similar memories
memories = await kernel.memory.search(
collection="user_prefs",
query="What database does the user prefer?",
limit=2,
min_relevance_score=0.7
)
for mem in memories:
print(f"score={mem.relevance:.3f} | {mem.text}") Semantic Kernel vs LangChain vs LlamaIndex
| Dimension | Semantic Kernel | LangChain | LlamaIndex |
|---|---|---|---|
| Languages | C#, Python, Java | Python, JS/TS | Python, TS |
| Azure integration | Native, first-class | Available | Available |
| Enterprise support | Microsoft-backed | LangChain Inc. | LlamaIndex Inc. |
| Agent/Planner | Excellent (Process framework) | Excellent (LCEL + ReAct) | Good |
| RAG quality | Good | Good | Excellent |
| Community size | Large (Microsoft) | Largest | Large |
| Best for | .NET teams, Azure, Copilot | General Python AI apps | Complex RAG, doc Q&A |
Frequently Asked Questions
What is Microsoft Semantic Kernel?▼
Semantic Kernel (SK) is Microsoft's open-source LLM orchestration framework for building AI applications in C#, Python, and Java. It is the foundation of Microsoft's own AI products (Copilot, Azure AI) and provides an enterprise-grade Kernel/Plugin/Planner architecture for composing LLM calls, tool use, memory, and complex multi-step AI workflows. It integrates natively with Azure OpenAI, OpenAI, Hugging Face, and other LLM providers.
What is the Kernel in Semantic Kernel?▼
The Kernel is the central orchestrator in Semantic Kernel. It holds the configured AI services (LLMs, embedding models), registered plugins, memory stores, and execution settings. All AI interactions go through the Kernel — you invoke functions, run planners, and manage memory through it. Think of it as the dependency injection container and execution engine combined.
What are Semantic Kernel Plugins?▼
Plugins are collections of functions (both semantic and native) that the Kernel can invoke. A semantic function is defined by a prompt template that calls an LLM. A native function is a regular C# or Python method decorated with @kernel_function. Plugins can be imported from OpenAI function calling definitions, OpenAPI specs, or defined inline. The AI can use plugins as tools — similar to LangChain tools or LlamaIndex tools.
What is the Semantic Kernel Planner?▼
The Planner allows the LLM to automatically create and execute multi-step plans by composing available plugins and functions. FunctionChoiceBehavior.Auto lets the LLM decide which functions to call in sequence. The older StepwisePlanner and HandlebarsPlanner generated explicit execution plans. Planners are SK's equivalent of LangChain's ReAct agents — the LLM reasons about which tools to use to fulfill a user request.
How does Semantic Kernel memory work?▼
Semantic Kernel provides a memory abstraction that stores text + embeddings in a vector store. You save memories with kernel.memory.save_information() and retrieve similar memories with kernel.memory.search(). SK integrates with Azure AI Search, Chroma, Qdrant, Weaviate, Redis, Postgres (pgvector), and Pinecone as memory backends. Memory enables semantic recall across conversations — remembering user preferences, past interactions, or knowledge base content.
Semantic Kernel vs LangChain: which should I choose?▼
Choose Semantic Kernel if: you work in the Microsoft/Azure ecosystem (Azure OpenAI, Azure AI Search, .NET), need enterprise C# support, or are building Copilot-style AI features in Microsoft products. Choose LangChain if: you work primarily in Python, need the widest LLM integrations and community ecosystem, or are building general-purpose AI applications outside the Azure stack. Both support Python — the key differentiator is the Microsoft ecosystem integration and C# support.
Related Products
on GumroadAI Prompt Engineering Toolkit
58 structured prompt templates for Claude, ChatGPT, and Gemini — organized by use case. Code Review, Debugging, Documentation, Architecture, and 10 model-specific tips. Stop writing prompts from scratch.
Buy on Gumroad →AI Developer Prompts Pack
55 battle-tested prompt templates for the workflows developers actually use: code review, debugging, architecture, documentation, and testing. Stop writing prompts from scratch.
Buy on Gumroad →Developer Productivity Bundle
Stop rebuilding the same setup every project. 51 VSCode snippets, 40 Git aliases, 5 Docker Compose stacks, 5 GitHub Actions workflows, 5 README templates, and a dotfiles kit. Set up a professional dev environment in under an hour.
Buy on Gumroad →You Might Also Need
AI Hallucination Detector
Scan LLM-generated text for hallucination risk signals: fabricated citations, overconfident claims, suspect statistics, and verification gaps. Risk score 0-100 with highlighted problem spans.
Open free tool →
AI Safety Checklist Generator
Generate a customized AI safety evaluation checklist for your deployment. Covers technical safety, content moderation, security, bias, privacy, and regulatory compliance. Export to Markdown.
Open free tool →
CrewAI Agent Config Generator
Build CrewAI agent configurations visually. Define roles, goals, backstories, and tools. Generate YAML or Python code for multi-agent crews.
Open free tool →
More Free Tools
Related Articles
Vercel AI SDK vs LangChain.js vs Mastra: AI Framework Comparison 2026
A comprehensive technical comparison of Vercel AI SDK, LangChain.js, and Mastra for building AI applications in 2026 — covering streaming, tool calling, RAG, agents, and when to choose each.
LLM Application Architecture Patterns 2026: RAG, Agents, Tool-Calling & Memory
Design production LLM applications with proven architectural patterns: RAG pipelines, agent loops, tool-calling, memory systems, and evaluation frameworks.
Prompt Engineering Techniques 2026: Chain-of-Thought, RAG, and Advanced Patterns
Advanced prompt engineering guide for 2026: Chain-of-Thought, Tree-of-Thought, RAG integration, few-shot learning, prompt chaining, and evaluation techniques.
Prompt Engineering Techniques 2026: Chain-of-Thought, Few-Shot, and RAG Patterns
Master practical prompt engineering in 2026. Learn chain-of-thought prompting, few-shot examples, RAG integration patterns, and advanced techniques like tree-of-thought and self-consistency with real code examples.
LLM Fine-tuning Complete Guide: When to Fine-tune vs RAG vs Prompting (2026)
A practical guide to LLM fine-tuning in 2026: when fine-tuning actually makes sense, step-by-step PEFT/LoRA and QLoRA walkthrough, OpenAI fine-tuning API, cost estimates, and how to evaluate if it worked.
Enjoying this tool? Get more like it.
Weekly developer tool guides, productivity playbooks & AI tricks. Free. No spam.
Unlock AI-Powered Dev Tools
- ⚡ AI Code Review, Doc Generator & SQL Builder
- ⚡ All premium templates & early access
- ⚡ Member discounts on Gumroad products
$9/mo after trial · Cancel anytime
Want the full toolkit?
Get DevPlaybook Pro
Every template, guide, boilerplate, and automation script in one bundle. 13 premium products — grab them all at once and save big.
MIT licensed · Instant download · No subscription
See what's included → Browse all deals →