Skip to main content

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.

✓ C#, Python & Java SDKs ✓ Plugin/Planner architecture ✓ Azure OpenAI native integration ✓ Memory & vector store support ✓ Microsoft Copilot foundation
Share this tool: X / Twitter LinkedIn
✓ 60,000+ developers use DevPlaybook ★★★★★ 4.8 / 5 on Gumroad ✓ MIT licensed · Instant download ✓ No login required

Related Products

on Gumroad

You Might Also Need

More Free Tools

Enjoying this tool? Get more like it.

Weekly developer tool guides, productivity playbooks & AI tricks. Free. No spam.

DevPlaybook Pro 7 days free

Unlock AI-Powered Dev Tools

  • ⚡ AI Code Review, Doc Generator & SQL Builder
  • ⚡ All premium templates & early access
  • ⚡ Member discounts on Gumroad products
Start Free Trial →

$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.

$79
$241 separately Save $162 (67% off)
Get DevPlaybook Pro — $79 →

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
LanguagesC#, Python, JavaPython, JS/TSPython, TS
Azure integrationNative, first-classAvailableAvailable
Enterprise supportMicrosoft-backedLangChain Inc.LlamaIndex Inc.
Agent/PlannerExcellent (Process framework)Excellent (LCEL + ReAct)Good
RAG qualityGoodGoodExcellent
Community sizeLarge (Microsoft)LargestLarge
Best for.NET teams, Azure, CopilotGeneral Python AI appsComplex 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.

Share this tool: X / Twitter LinkedIn
✓ 60,000+ developers use DevPlaybook ★★★★★ 4.8 / 5 on Gumroad ✓ MIT licensed · Instant download ✓ No login required

Related Products

on Gumroad

You Might Also Need

More Free Tools

AI Hallucination Detector AI Safety Checklist Generator CrewAI Agent Config Generator AI Model Comparator Test Coverage Calculator AI Agent Memory Planner AI Model Comparison Tool Jotai Atom Explorer LLM Cost Calculator CSS Container Query Builder LLM Context Window Calculator AI Prompt Cost Calculator LLM JSON Schema Builder AI Agent Run Cost Tracker AI Pipeline DAG Builder LLM Benchmark Calculator Prompt Injection Tester LangChain PromptTemplate Builder Embedding Storage Calculator RAG Chunk Size Optimizer AI Token Cost Calculator Azure ARM Template Validator MySQL Query Explainer PostgreSQL EXPLAIN Analyzer GraphQL Fragment Generator Jest Coverage Config Generator AI Model Benchmark Comparator Cron Expression Explainer Font Pairing Preview LLM Prompt Cost Calculator AI Model Context Window Visualizer RAG Chunking Calculator OpenAI Prompt Tester AI Rate Limit Calculator LLM System Prompt Analyzer Vibe Coding Prompt Optimizer AI IDE Comparator RAG Chunking Calculator Token Counter & Cost Estimator AI Model Comparison Table LLM Prompt Template Builder AI Commit Message Generator AI Doc Generator — Pro Tool AI Regex Explainer — Pro Tool AI System Guardian Vitest Configuration Generator Mermaid Diagram Generator Elasticsearch Query Tester mTLS Certificate Chain Builder Prompt Token Estimator JS Prototype Chain Visualizer OpenAI Token Counter System Prompt Builder Token Context Calculator LLM Prompt Caching Calculator Multi-Agent Orchestration Planner AI Prompt Token Estimator OpenAI Function Calling Generator AI Context Window Visualizer AI API Rate Limit Calculator HTTP Headers Analyzer AI Code Review — Pro Tool AI Error Explainer — Pro Tool AI SQL Builder — Pro Tool AI Unit Test Generator — Pro Tool Color Palette Generator Docker Compose Generator JWT Decoder Prompt Template Builder Regex Tester RSA Key Pair Generator SMTP Server Tester Biome Config Generator Terraform Variable Validator Haproxy Config Validator SBOM Generator AI Variable Namer AI PR Description Generator AI JSDoc Generator K8s Resource Limits Calculator Regex Flags Explainer LLM Token Counter OAuth2 Flow Visualizer Jest Testing Framework Guide Vitest Guide — Vite-native Testing Playwright E2E Testing Guide HashiCorp Vault Secrets Management Guide Core Web Vitals Calculator Solana Program ID Generator Multi-Chain Wallet Address Validator AI Embeddings Dimension Explorer Bezier Curve Editor Embedding Similarity Calculator TypeScript Discriminated Union Builder Core Web Vitals Budget Calculator JWT Decoder & Validator Blockchain Transaction Fee Calculator Database Query Cost Analyzer

Enjoying this tool? Get more like it.

Weekly developer tool guides, productivity playbooks & AI tricks. Free. No spam.

DevPlaybook Pro 7 days free

Unlock AI-Powered Dev Tools

  • ⚡ AI Code Review, Doc Generator & SQL Builder
  • ⚡ All premium templates & early access
  • ⚡ Member discounts on Gumroad products
Start Free Trial →

$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.

$79
$241 separately Save $162 (67% off)
Get DevPlaybook Pro — $79 →

MIT licensed · Instant download · No subscription

See what's included → Browse all deals →