Overview
Microsoft Semantic Kernel is an open-source SDK that lets you easily combine cutting-edge AI with traditional programming languages. It provides a unified programming model for integrating LLMs with your existing codebase, with first-class support for .NET, Python, and Java.
Features
- ✓Multi-language support: C#, Python, and Java
- ✓Plugin architecture for reusable components
- ✓Built-in memory connectors with multiple backends
- ✓Native Azure AI services integration
- ✓Dependency injection for clean architecture
Installation
dotnet add package Microsoft.SemanticKernelPros
- +Enterprise-ready design from Microsoft
- +Excellent .NET, Python, and Java support
- +First-class Azure AI services integration
- +Well-organized, testable code structure
- +No vendor lock-in - works with any OpenAI-compatible endpoint
Cons
- −Smaller community than LangChain
- −Fewer pre-built integrations
- −Enterprise patterns can be complex for simple use cases
- −No official JavaScript/TypeScript support
Alternatives
Documentation
Microsoft Semantic Kernel
Overview
Microsoft Semantic Kernel is an open-source SDK that lets you easily combine cutting-edge AI with traditional programming languages. It provides a unified programming model for integrating LLMs with your existing codebase, with first-class support for .NET, Python, and Java.
Key Features
🏗️ Enterprise-Grade Architecture
Semantic Kernel is designed for enterprise use:
- Multi-Language Support: First-class support for C#, Python, and Java
- Dependency Injection: Built-in DI container for clean architecture
- Async/Await Native: Full async support for all operations
- Testable Design: Easy to mock and test all components
🔌 Plugin Architecture
Create reusable plugins that can be composed:
// C# example
public class WeatherPlugin
{
[KernelFunction("get_weather")]
[Description("Gets the current weather for a location")]
public async Task<string> GetWeather(
[Description("The location to get weather for")] string location)
{
return await weatherService.GetWeatherAsync(location);
}
}
// Register plugin
kernel.Plugins.AddFromObject(new WeatherPlugin());
# Python example
from semantic_kernel.functions import kernel_function
class WeatherPlugin:
@kernel_function(
description="Gets the current weather for a location",
name="get_weather"
)
async def get_weather(self, location: str) -> str:
return await self.weather_service.get_weather(location)
🧠 Memory Connectors
Built-in memory with multiple storage backends:
// C# - Vector memory
var memory = new MemoryBuilder()
.WithOpenAITextEmbeddingGeneration("text-embedding-3-small", "api-key")
.WithMemoryStore(new VolatileMemoryStore())
.Build();
// Python - Multiple connectors
from semantic_kernel.connectors.memory.chroma import ChromaMemoryStore
from semantic_kernel.connectors.memory.pinecone import PineconeMemoryStore
from semantic_kernel.connectors.memory.qdrant import QdrantMemoryStore
🤖 Agent Orchestration
Built-in agent framework:
var agent = new ChatCompletionAgent
{
Name = "Assistant",
Instructions = "You are a helpful assistant.",
Kernel = kernel,
ChatCompletionService = openAIService
};
var result = await agent.InvokeAsync("What's the weather in Seattle?");
🔗 Multiple Model Providers
Support for numerous AI providers:
| Provider | Status | Models |
|---|---|---|
| OpenAI | ✅ Full | GPT-4o, GPT-4 Turbo, o1 |
| Azure OpenAI | ✅ Full | All Azure models |
| Anthropic | ✅ Full | Claude 3.5 Sonnet, Opus |
| ✅ Full | Gemini 1.5 Pro, 2.0 | |
| Hugging Face | ✅ Full | Open models |
| Ollama | ✅ Full | Local models |
| Mistral | ✅ Full | Mistral models |
Installation
# .NET
dotnet add package Microsoft.SemanticKernel
# Python
pip install semantic-kernel
# Java (Maven)
<dependency>
<groupId>com.microsoft.semantic-kernel</groupId>
<artifactId>semantic-kernel-api</artifactId>
<version>1.15.0</version>
</dependency>
Quick Start
// C# - Complete example
using Microsoft.SemanticKernel;
var kernel = Kernel.CreateBuilder()
.AddOpenAIChatCompletion("gpt-4o", "api-key")
.Build();
var result = await kernel.InvokePromptAsync("What is AI?");
Console.WriteLine(result);
# Python - Complete example
from semantic_kernel import Kernel
from semantic_kernel.connectors.ai.open_ai import OpenAIChatCompletion
kernel = Kernel()
kernel.add_service(OpenAIChatCompletion(service_id="chat", ai_model_id="gpt-4o"))
result = await kernel.invoke_prompt("What is AI?")
print(result)
Advanced Patterns
Semantic Functions
Define AI-powered functions with prompts:
// C# - Semantic function from string
var summarize = kernel.CreateFunctionFromPrompt(
"Summarize the following text: {{$input}}",
new PromptExecutionSettings
{
Temperature = 0.3,
MaxTokens = 500
}
);
var summary = await kernel.InvokeAsync(summarize, new { input = longText });
Planning and Orchestration
var planner = new SequentialPlanner(kernel);
var plan = await planner.CreatePlanAsync("Book a flight to Paris and find a hotel");
var result = await plan.InvokeAsync();
Memory with RAG
// Add memory
var memory = new MemoryBuilder()
.WithOpenAITextEmbeddingGeneration("text-embedding-3-small", "api-key")
.WithMemoryStore(new VolatileMemoryStore())
.Build();
await memory.SaveInformationAsync("collection", "AI is transformative", "id1");
// Query memory
var result = await memory.SearchAsync("collection", "What is AI?");
Function Calling
kernel.Plugins.AddFromType<CalendarPlugin>();
kernel.Plugins.AddFromType<EmailPlugin>();
var result = await kernel.InvokePromptAsync(
"Schedule a meeting with the team tomorrow at 2pm"
);
Pros
- ✅ Enterprise-Ready: Designed by Microsoft for enterprise scenarios
- ✅ Multi-Language: Excellent support for .NET, Python, and Java
- ✅ Azure Integration: First-class integration with Azure AI services
- ✅ Clean Architecture: Well-organized, testable code structure
- ✅ Active Development: Backed by Microsoft with regular updates
- ✅ Documentation: Comprehensive docs with enterprise focus
- ✅ No Vendor Lock-in: Works with any OpenAI-compatible endpoint
Cons
- ❌ Smaller Community: Less community activity than LangChain
- ❌ Fewer Integrations: Smaller ecosystem of pre-built connectors
- ❌ Learning Curve: Enterprise patterns can be complex for simple use cases
- ❌ JavaScript Gap: No official JavaScript/TypeScript support
Use Cases
| Use Case | Why Semantic Kernel |
|---|---|
| Enterprise .NET Apps | Native integration with C# and .NET ecosystem |
| Azure AI Services | First-class support for Azure OpenAI and Cognitive Services |
| Multi-language Projects | Support for C#, Python, and Java in one codebase |
| Plugin Architecture | Compose reusable AI-powered plugins |
| Enterprise RAG | Memory connectors with enterprise storage backends |
Comparison with Alternatives
| Feature | Semantic Kernel | LangChain | Microsoft AutoGen | Vercel AI SDK |
|---|---|---|---|---|
| Paradigm | Plugin-based | Chain-based | Multi-agent conversation | TypeScript SDK |
| .NET Support | ✅ Excellent | ❌ No | ✅ Yes | ❌ No |
| Java Support | ✅ Yes | ❌ No | ❌ No | ❌ No |
| Enterprise Ready | ✅ Yes | ⚠️ Moderate | ✅ Yes | ⚠️ Moderate |
| Azure Integration | ✅ Native | ⚠️ Via plugins | ✅ Native | ❌ No |
| Learning Curve | Medium | High | Medium | Low |
| Best for | .NET/Enterprise | Complex apps | Multi-agent teams | TS/Next.js |
Best Practices
- Use dependency injection — Leverage built-in DI for clean architecture
- Create reusable plugins — Encapsulate AI functionality in plugins
- Use semantic functions — Define AI-powered functions with prompts
- Leverage memory connectors — Use appropriate storage backend for your needs
- Plan before executing — Use SequentialPlanner for complex tasks
- Test with mocks — All components are designed for testability
Troubleshooting
| Issue | Solution |
|---|---|
| Plugin not loading | Verify plugin class has [KernelFunction] attribute |
| Memory not persisting | Check memory store configuration and connection |
| Function calling fails | Ensure function signatures match expected types |
| Azure auth errors | Verify Azure OpenAI endpoint and key configuration |
| Planning fails | Provide clearer task description to planner |
Resources
- Official Docs: https://learn.microsoft.com/en-us/semantic-kernel/
- GitHub: https://github.com/microsoft/semantic-kernel
- Samples: https://github.com/microsoft/semantic-kernel/tree/main/samples
- NuGet: https://www.nuget.org/packages/Microsoft.SemanticKernel/
Comparison
| Feature | Semantic Kernel | LangChain | CrewAI |
|---|---|---|---|
| .NET Support | ✅ Excellent | ❌ No | ❌ No |
| Java Support | ✅ Good | ❌ No | ❌ No |
| Enterprise Ready | ✅ Yes | ⚠️ Moderate | ⚠️ Moderate |
| Azure Integration | ✅ Native | ⚠️ Via plugins | ❌ No |
| Community Size | Medium | Large | Medium |
| JavaScript | ❌ No | ✅ Yes | ❌ No |
Last updated: May 2026
