microsoft/semantic-kernel
C#
Captured source
source ↗microsoft/semantic-kernel
Description: Integrate cutting-edge LLM technology quickly and easily into your apps
Language: C#
License: MIT
Stars: 28097
Forks: 4639
Open issues: 277
Created: 2023-02-27T17:39:42Z
Pushed: 2026-06-11T00:38:07Z
Default branch: main
Fork: no
Archived: no
README:
Semantic Kernel
> [!IMPORTANT] > Semantic Kernel is now Microsoft Agent Framework! Microsoft Agent Framework (MAF) is the enterprise‑ready successor to Semantic Kernel. Microsoft Agent Framework is now available at version 1.0 as a production-ready release: stable APIs, and a commitment to long-term support. Whether you're building a single assistant or orchestrating a fleet of specialized agents, Microsoft Agent Framework 1.0 gives you enterprise-grade multi-agent orchestration, multi-provider model support, and cross-runtime interoperability via A2A and MCP. > > Learn more about Semantic Kernel and Agent Framework here: Semantic Kernel and Microsoft Agent Framework on the Agent Framework blog, and try out the Semantic Kernel migration guide.
Build intelligent AI agents and multi-agent systems with this enterprise-ready orchestration framework
What is Semantic Kernel?
Semantic Kernel is a model-agnostic SDK that empowers developers to build, orchestrate, and deploy AI agents and multi-agent systems. Whether you're building a simple chatbot or a complex multi-agent workflow, Semantic Kernel provides the tools you need with enterprise-grade reliability and flexibility.
System Requirements
- Python: 3.10+
- .NET: .NET 10.0+
- Java: JDK 17+
- OS Support: Windows, macOS, Linux
Key Features
- Model Flexibility: Connect to any LLM with built-in support for OpenAI, Azure OpenAI, Hugging Face, NVidia and more
- Agent Framework: Build modular AI agents with access to tools/plugins, memory, and planning capabilities
- Multi-Agent Systems: Orchestrate complex workflows with collaborating specialist agents
- Plugin Ecosystem: Extend with native code functions, prompt templates, OpenAPI specs, or Model Context Protocol (MCP)
- Vector DB Support: Seamless integration with Azure AI Search, Elasticsearch, Chroma, and more
- Multimodal Support: Process text, vision, and audio inputs
- Local Deployment: Run with Ollama, LMStudio, or ONNX
- Process Framework: Model complex business processes with a structured workflow approach
- Enterprise Ready: Built for observability, security, and stable APIs
Installation
First, set the environment variable for your AI Services:
Azure OpenAI:
export AZURE_OPENAI_API_KEY=AAA....
or OpenAI directly:
export OPENAI_API_KEY=sk-...
Python
pip install semantic-kernel
.NET
dotnet add package Microsoft.SemanticKernel dotnet add package Microsoft.SemanticKernel.Agents.Core
Java
See semantic-kernel-java build for instructions.
Quickstart
Basic Agent - Python
Create a simple assistant that responds to user prompts:
import asyncio from semantic_kernel.agents import ChatCompletionAgent from semantic_kernel.connectors.ai.open_ai import AzureChatCompletion async def main(): # Initialize a chat agent with basic instructions agent = ChatCompletionAgent( service=AzureChatCompletion(), name="SK-Assistant", instructions="You are a helpful assistant.", ) # Get a response to a user message response = await agent.get_response(messages="Write a haiku about Semantic Kernel.") print(response.content) asyncio.run(main()) # Output: # Language's essence, # Semantic threads intertwine, # Meaning's core revealed.
Basic Agent - .NET
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Agents;
var builder = Kernel.CreateBuilder();
builder.AddAzureOpenAIChatCompletion(
Environment.GetEnvironmentVariable("AZURE_OPENAI_DEPLOYMENT"),
Environment.GetEnvironmentVariable("AZURE_OPENAI_ENDPOINT"),
Environment.GetEnvironmentVariable("AZURE_OPENAI_API_KEY")
);
var kernel = builder.Build();
ChatCompletionAgent agent =
new()
{
Name = "SK-Agent",
Instructions = "You are a helpful assistant.",
Kernel = kernel,
};
await foreach (AgentResponseItem response
in agent.InvokeAsync("Write a haiku about Semantic Kernel."))
{
Console.WriteLine(response.Message);
}
// Output:
// Language's essence,
// Semantic threads intertwine,
// Meaning's core revealed.Agent with Plugins - Python
Enhance your agent with custom tools (plugins) and structured output:
import asyncio from typing import Annotated from pydantic import BaseModel from semantic_kernel.agents import ChatCompletionAgent from semantic_kernel.connectors.ai.open_ai import AzureChatCompletion, OpenAIChatPromptExecutionSettings from semantic_kernel.functions import kernel_function, KernelArguments class MenuPlugin: @kernel_function(description="Provides a list of specials from the menu.") def get_specials(self) -> Annotated[str, "Returns the specials from the menu."]: return """ Special Soup: Clam Chowder Special Salad: Cobb Salad Special Drink: Chai Tea """ @kernel_function(description="Provides the price of the requested menu item.") def get_item_price( self, menu_item: Annotated[str, "The name of the menu item."] ) -> Annotated[str, "Returns the price of the menu item."]: return "$9.99" class MenuItem(BaseModel): price: float name: str async def main(): # Configure structured output format settings = OpenAIChatPromptExecutionSettings() settings.response_format = MenuItem # Create agent with plugin and settings agent = ChatCompletionAgent( service=AzureChatCompletion(), name="SK-Assistant", instructions="You are a helpful assistant.", plugins=[MenuPlugin()],…
Excerpt shown — open the source for the full document.