{"id":135790,"date":"2026-09-07T10:22:33","date_gmt":"2026-09-07T04:52:33","guid":{"rendered":"https:\/\/www.guvi.in\/blog\/?p=135790"},"modified":"2026-09-07T10:22:34","modified_gmt":"2026-09-07T04:52:34","slug":"semantic-kernel-tutorial","status":"publish","type":"post","link":"https:\/\/www.guvi.in\/blog\/semantic-kernel-tutorial\/","title":{"rendered":"Semantic Kernel Tutorial: Microsoft\u2019s AI Orchestration Framework"},"content":{"rendered":"\n<p>Semantic Kernel is Microsoft\u2019s open-source SDK for orchestrating AI models, plugins, and agents into cohesive applications. It supports .NET, Python, and Java, and integrates with Azure OpenAI, OpenAI, and other LLM providers. This tutorial shows how to set up Semantic Kernel, create your first AI agent, add plugins and memory, and run a simple multi-step workflow.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Direct Answer Box<\/strong><\/h2>\n\n\n\n<p><strong>Semantic Kernel<\/strong> is a model-agnostic orchestration framework that lets you connect LLMs, tools, memory, and business logic into AI agents and workflows. You create a kernel, register AI services and plugins (native code and prompt functions), optionally add vector memory, and then invoke functions or agents that can plan and call tools automatically. Semantic Kernel is designed for building enterprise-grade AI applications, from simple chatbots to complex multi-agent systems.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>TL;DR Summary Box<\/strong><\/h2>\n\n\n\n<ul>\n<li>Semantic Kernel is an SDK for orchestrating LLMs, tools, and memory.<\/li>\n\n\n\n<li>The kernel is the central runtime that invokes plugins and agents.<\/li>\n\n\n\n<li>Plugins can be native code functions or prompt-based functions.<\/li>\n\n\n\n<li>Memory enables retrieval-augmented generation over your data.<\/li>\n\n\n\n<li>Agents and orchestration patterns support multi-step, multi-agent workflows.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>What Is Semantic Kernel?<\/strong><\/h2>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"940\" height=\"498\" src=\"https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2026\/08\/image-566.png\" alt=\"What Is Semantic Kernel?\" class=\"wp-image-135791\" srcset=\"https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2026\/08\/image-566.png 940w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2026\/08\/image-566-300x159.png 300w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2026\/08\/image-566-768x407.png 768w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2026\/08\/image-566-150x79.png 150w\" sizes=\"(max-width: 940px) 100vw, 940px\" title=\"\"><\/figure>\n\n\n\n<p><strong>Semantic Kernel (SK)<\/strong> is an open-source AI orchestration framework from Microsoft. It provides a lightweight runtime and SDK for integrating large language models (LLMs) with your code, data, and services.<\/p>\n\n\n\n<p>Key characteristics:<\/p>\n\n\n\n<ul>\n<li>Model-agnostic: works with Azure OpenAI, OpenAI, and other providers.<\/li>\n\n\n\n<li>Multi-language: .NET, Python, and Java SDKs.<\/li>\n\n\n\n<li>Plugin-based: wrap APIs, databases, and business logic as callable functions.<\/li>\n\n\n\n<li>Prompt + code: combine natural language prompts with native functions.<\/li>\n\n\n\n<li>Memory support: integrate vector stores for retrieval-augmented generation (RAG).<\/li>\n\n\n\n<li>Agent frameworks: build single and multi-agent workflows with orchestration patterns.<\/li>\n<\/ul>\n\n\n\n<p>Semantic Kernel is commonly used for:<\/p>\n\n\n\n<ul>\n<li>Enterprise copilots and assistants.<\/li>\n\n\n\n<li>Document Q&amp;A and knowledge-base chatbots.<\/li>\n\n\n\n<li>Process automation with AI-driven decision making.<\/li>\n\n\n\n<li>Multi-agent systems where specialized agents collaborate.<\/li>\n\n\n\n<li>Integrating AI into existing .NET, Python, or Java applications.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Why Use Semantic Kernel?<\/strong><\/h3>\n\n\n\n<p>Semantic Kernel helps you:<\/p>\n\n\n\n<ul>\n<li>Avoid building AI integration logic from scratch.<\/li>\n\n\n\n<li>Standardize how LLMs call tools and access data.<\/li>\n\n\n\n<li>Combine prompts and code in a unified programming model.<\/li>\n\n\n\n<li>Add memory and retrieval without managing low-level vector details.<\/li>\n\n\n\n<li>Build reusable plugins and agents across projects.<\/li>\n\n\n\n<li>Leverage enterprise patterns for security, observability, and governance.<\/li>\n<\/ul>\n\n\n\n<p>It is especially useful when you want a structured, extensible way to build AI applications on top of LLMs.<\/p>\n\n\n\n<p><em>Semantic Kernel is Microsoft\u2019s open-source, model-agnostic SDK that lets you plug in LLMs, build prompt functions and tools, add vector memory, and orchestrate single- or multi-agent workflows with planning and tool-calling. Learn AI &amp; ML with HCL GUVI\u2019s<\/em><a href=\"https:\/\/www.guvi.in\/mlp\/artificial-intelligence-and-machine-learning?utm_source=semantic-kernel-tutorial\" target=\"_blank\" data-type=\"link\" data-id=\"https:\/\/www.guvi.in\/mlp\/artificial-intelligence-and-machine-learning?utm_source=semantic-kernel-tutorial\" rel=\"noreferrer noopener\"><em> Artificial Intelligence and Machine\u00a0 Learning course<\/em><\/a><em>.\u00a0<\/em><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Core Concepts: Kernel, Plugins, Prompts, and Memory<\/strong><\/h2>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"940\" height=\"498\" src=\"https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2026\/08\/image-567.png\" alt=\"Core Concepts: Kernel, Plugins, Prompts, and Memory\" class=\"wp-image-135793\" srcset=\"https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2026\/08\/image-567.png 940w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2026\/08\/image-567-300x159.png 300w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2026\/08\/image-567-768x407.png 768w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2026\/08\/image-567-150x79.png 150w\" sizes=\"(max-width: 940px) 100vw, 940px\" title=\"\"><\/figure>\n\n\n\n<p>Before writing code, you need to understand four core ideas.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>1. Kernel<\/strong><\/h2>\n\n\n\n<p>The <strong>kernel<\/strong> is the central runtime in Semantic Kernel.<\/p>\n\n\n\n<ul>\n<li>It holds AI services (LLM clients).<\/li>\n\n\n\n<li>It registers plugins (functions callable by the LLM).<\/li>\n\n\n\n<li>It manages execution of prompt and native functions.<\/li>\n\n\n\n<li>It can host agents and orchestration workflows.<\/li>\n<\/ul>\n\n\n\n<p>You can think of the kernel as the \u201capp container\u201d for your AI logic.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>2. Plugins<\/strong><\/h2>\n\n\n\n<p><strong>Plugins<\/strong> are collections of functions that the kernel can invoke.<\/p>\n\n\n\n<p>There are two main types:<\/p>\n\n\n\n<ul>\n<li><strong>Native functions:<\/strong> Regular code methods (C#, Python, Java) that perform actions such as calling APIs, querying databases, or running business logic.<\/li>\n\n\n\n<li><strong>Prompt functions:<\/strong> Natural language prompts stored in files or strings that the LLM executes, optionally with parameters.<\/li>\n<\/ul>\n\n\n\n<p>Plugins enable the LLM to:<\/p>\n\n\n\n<ul>\n<li>Call external tools and services.<\/li>\n\n\n\n<li>Access structured data and APIs.<\/li>\n\n\n\n<li>Perform deterministic actions alongside generative capabilities.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>3. Prompts and Prompt Functions<\/strong><\/h2>\n\n\n\n<p><strong>Prompts<\/strong> are the instructions and context you send to the LLM.<\/p>\n\n\n\n<p>In Semantic Kernel:<\/p>\n\n\n\n<ul>\n<li>Prompts can be defined inline or in template files.<\/li>\n\n\n\n<li>They can include variables, function calls, and conditional logic.<\/li>\n\n\n\n<li>Prompt functions are prompts exposed as callable functions within the kernel.<\/li>\n<\/ul>\n\n\n\n<p>This allows you to treat prompts as first-class functions that can be composed, tested, and versioned.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>4. Memory<\/strong><\/h2>\n\n\n\n<p><strong>Memory<\/strong> in Semantic Kernel refers to vector-based retrieval over your data.<\/p>\n\n\n\n<ul>\n<li>You store documents or chunks with embeddings in a vector store.<\/li>\n\n\n\n<li>The kernel can retrieve relevant pieces based on a query.<\/li>\n\n\n\n<li>Retrieved content is injected into prompts for RAG.<\/li>\n<\/ul>\n\n\n\n<p>Memory enables your AI to answer questions grounded in your own documents, not just its pre-trained knowledge.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Step-by-Step: Setting Up Semantic Kernel (Python)<\/strong><\/h2>\n\n\n\n<p>This section walks you through a minimal end-to-end setup using Python. Equivalent patterns exist in .NET and Java.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 1: Install the SDK<\/strong><\/h3>\n\n\n\n<p>Install the Semantic Kernel package with your preferred AI provider.<\/p>\n\n\n\n<p>For OpenAI:<\/p>\n\n\n\n<p>bash<\/p>\n\n\n\n<p>pip install semantic-kernel openai python-dotenv<\/p>\n\n\n\n<p>For Azure OpenAI:<\/p>\n\n\n\n<p>bash<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pip install semantic-kernel azure-identity python-dotenv<\/code><\/pre>\n\n\n\n<p>Optionally, install Jupyter support for notebooks:<\/p>\n\n\n\n<p>bash<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pip install ipykernel<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 2: Configure Your Environment<\/strong><\/h3>\n\n\n\n<p>Create a .env file in your project directory:<\/p>\n\n\n\n<p>text<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>OPENAI_API_KEY=sk-...\n\n# or for Azure OpenAI:\n\n# AZURE_OPENAI_ENDPOINT=https:\/\/your-resource.openai.azure.com\/\n\n# AZURE_OPENAI_DEPLOYMENT_NAME=your-deployment\n\n# AZURE_OPENAI_API_KEY=...<\/code><\/pre>\n\n\n\n<p>Never hard-code secrets in your code. Load them from environment variables.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 3: Create the Kernel<\/strong><\/h3>\n\n\n\n<p>In a Python script or notebook:<\/p>\n\n\n\n<p>python<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import asyncio\n\nimport os\n\nfrom dotenv import load_dotenv\n\nimport semantic_kernel as sk\n\nfrom semantic_kernel.connectors.ai.open_ai import OpenAIChatCompletion\n\nload_dotenv()\n\napi_key = os.getenv(\"OPENAI_API_KEY\")\n\nmodel_id = \"gpt-4o-mini\"&nbsp; # or your preferred model\n\nkernel = sk.Kernel()\n\nchat_service = OpenAIChatCompletion(\n\n&nbsp;&nbsp;&nbsp;&nbsp;service_id=\"chat\",\n\n&nbsp;&nbsp;&nbsp;&nbsp;ai_model_id=model_id,\n\n&nbsp;&nbsp;&nbsp;&nbsp;api_key=api_key\n\n)\n\nkernel.add_service(chat_service)<\/code><\/pre>\n\n\n\n<p>Now you have a kernel with an <a href=\"https:\/\/www.guvi.in\/blog\/guide-to-large-language-models\/\" target=\"_blank\" rel=\"noreferrer noopener\">LLM <\/a>service registered.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 4: Define a Simple Prompt Function<\/strong><\/h3>\n\n\n\n<p>Create a basic prompt that uses the LLM.<\/p>\n\n\n\n<p>python<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from semantic_kernel.functions import KernelFunctionFromPrompt\n\nsummarize_prompt = \"\"\"\n\nSummarize the following text in 2-3 sentences.\n\nText: {{$input}}\n\nSummary:\n\n\"\"\"\n\nsummarize_function = KernelFunctionFromPrompt(\n\n&nbsp;&nbsp;&nbsp;&nbsp;function_name=\"Summarize\",\n\n&nbsp;&nbsp;&nbsp;&nbsp;plugin_name=\"TextPlugin\",\n\n&nbsp;&nbsp;&nbsp;&nbsp;prompt=summarize_prompt\n\n)\n\nkernel.add_function(summarize_function)<\/code><\/pre>\n\n\n\n<p>This defines a Summarize function in a TextPlugin plugin.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 5: Invoke the Function<\/strong><\/h3>\n\n\n\n<p>Run the function with some input text.<\/p>\n\n\n\n<p>python<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>text = \"\"\"\n\nSemantic Kernel is Microsoft's open-source AI orchestration framework.\n\nIt lets developers integrate LLMs with code, data, and services using plugins,\n\nprompts, and memory. It supports .NET, Python, and Java.\n\n\"\"\"\n\nresult = asyncio.run(\n\n&nbsp;&nbsp;&nbsp;&nbsp;kernel.invoke(\n\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;summarize_function,\n\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;input=text\n\n&nbsp;&nbsp;&nbsp;&nbsp;)\n\n)\n\nprint(str(result))<\/code><\/pre>\n\n\n\n<p>The LLM will generate a short summary based on your prompt.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Adding Native Plugins (Tools)<\/strong><\/h2>\n\n\n\n<p>Native plugins let the LLM call your own <a href=\"https:\/\/www.guvi.in\/blog\/how-to-optimize-code-with-generative-ai\/\" target=\"_blank\" rel=\"noreferrer noopener\">code<\/a>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 6: Define a Native Plugin Class<\/strong><\/h3>\n\n\n\n<p>Create a class with methods that perform actions.<\/p>\n\n\n\n<p>python<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>text = \"\"\"\n\nSemantic Kernel is Microsoft's open-source AI orchestration framework.\n\nIt lets developers integrate LLMs with code, data, and services using plugins,\n\nprompts, and memory. It supports .NET, Python, and Java.\n\n\"\"\"\n\nresult = asyncio.run(\n\n&nbsp;&nbsp;&nbsp;&nbsp;kernel.invoke(\n\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;summarize_function,\n\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;input=text\n\n&nbsp;&nbsp;&nbsp;&nbsp;)\n\n)\n\nprint(str(result))<\/code><\/pre>\n\n\n\n<p>Each method decorated with @kernel_function becomes callable by the kernel and, if enabled, by the LLM.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 7: Register the Plugin<\/strong><\/h3>\n\n\n\n<p>python<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>time_plugin = TimePlugin()\n\nkernel.add_plugin(time_plugin, plugin_name=\"TimePlugin\")<\/code><\/pre>\n\n\n\n<p>Now the kernel knows about TimePlugin.get_current_time and TimePlugin.add_numbers.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 8: Use the Plugin in a Prompt<\/strong><\/h3>\n\n\n\n<p>Create a prompt that can call these functions.<\/p>\n\n\n\n<p>python<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>tool_prompt = \"\"\"\n\nYou are a helpful assistant. You can use the following functions:\n\n- TimePlugin.get_current_time: Get the current date and time.\n\n- TimePlugin.add_numbers: Add two numbers.\n\nUser: {{$input}}\n\nAssistant:\n\n\"\"\"\n\ntool_function = KernelFunctionFromPrompt(\n\n&nbsp;&nbsp;&nbsp;&nbsp;function_name=\"Assistant\",\n\n&nbsp;&nbsp;&nbsp;&nbsp;plugin_name=\"AssistantPlugin\",\n\n&nbsp;&nbsp;&nbsp;&nbsp;prompt=tool_prompt,\n\n&nbsp;&nbsp;&nbsp;&nbsp;prompt_execution_settings=sk.PromptExecutionSettings(\n\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;function_choice_behavior=sk.FunctionChoiceBehavior.Auto()\n\n&nbsp;&nbsp;&nbsp;&nbsp;)\n\n)\n\nkernel.add_function(tool_function)<\/code><\/pre>\n\n\n\n<p>With function choice enabled, the LLM can decide to call get_current_time or add_numbers when appropriate.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 9: Invoke the Tool-Enabled Function<\/strong><\/h3>\n\n\n\n<p>python<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>questions = &#91;\n\n&nbsp;&nbsp;&nbsp;&nbsp;\"What time is it now?\",\n\n&nbsp;&nbsp;&nbsp;&nbsp;\"Add 12.5 and 7.3 for me.\"\n\n]\n\nfor q in questions:\n\n&nbsp;&nbsp;&nbsp;&nbsp;result = asyncio.run(\n\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;kernel.invoke(\n\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tool_function,\n\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;input=q\n\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)\n\n&nbsp;&nbsp;&nbsp;&nbsp;)\n\n&nbsp;&nbsp;&nbsp;&nbsp;print(\"Q:\", q)\n\n&nbsp;&nbsp;&nbsp;&nbsp;print(\"A:\", str(result))\n\n&nbsp;&nbsp;&nbsp;&nbsp;print(\"-\" * 40)<\/code><\/pre>\n\n\n\n<p>The LLM may call the native functions to answer the questions.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Adding Memory for Retrieval-Augmented Generation<\/strong><\/h2>\n\n\n\n<p>Memory lets the kernel retrieve relevant documents from a <a href=\"https:\/\/www.guvi.in\/blog\/what-is-a-vector-database-in-ai\/\" target=\"_blank\" rel=\"noreferrer noopener\">vector <\/a>store.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 10: Set Up a Vector Store (Example with In-Memory)<\/strong><\/h3>\n\n\n\n<p>For demonstration, use the built-in volatile memory store. In production, use a real vector <a href=\"https:\/\/www.guvi.in\/blog\/database-design-principles-and-best-practices\/\" target=\"_blank\" rel=\"noreferrer noopener\">database<\/a>.<\/p>\n\n\n\n<p>python<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from semantic_kernel.connectors.memory.volatile import VolatileMemoryStore\n\nfrom semantic_kernel.core_plugins import TextMemoryPlugin\n\nmemory_store = VolatileMemoryStore()\n\nmemory_plugin = TextMemoryPlugin(\n\n&nbsp;&nbsp;&nbsp;&nbsp;memory_store=memory_store,\n\n&nbsp;&nbsp;&nbsp;&nbsp;embeddings_service=chat_service&nbsp; # or a dedicated embedding service\n\n)\n\nkernel.add_plugin(memory_plugin, plugin_name=\"Memory\")<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 11: Save Documents to Memory<\/strong><\/h3>\n\n\n\n<p>python<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docs = &#91;\n\n&nbsp;&nbsp;&nbsp;&nbsp;\"Semantic Kernel is an AI orchestration SDK from Microsoft.\",\n\n&nbsp;&nbsp;&nbsp;&nbsp;\"It supports .NET, Python, and Java for building AI agents.\",\n\n&nbsp;&nbsp;&nbsp;&nbsp;\"Plugins let LLMs call native code and external APIs.\",\n\n]\n\nfor i, doc in enumerate(docs):\n\n&nbsp;&nbsp;&nbsp;&nbsp;asyncio.run(\n\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;memory_plugin.save_information(\n\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;text=doc,\n\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;id=f\"doc_{i}\",\n\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;collection=\"sk_docs\"\n\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)\n\n&nbsp;&nbsp;&nbsp;&nbsp;)<\/code><\/pre>\n\n\n\n<p>These documents are embedded and stored for retrieval.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 12: Query Memory in a Prompt<\/strong><\/h3>\n\n\n\n<p>python<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>rag_prompt = \"\"\"\n\nYou are a helpful assistant. Use the Memory plugin to retrieve relevant information.\n\nRelevant information:\n\n{{Memory.search collection='sk_docs' query=$input}}\n\nUser question: {{$input}}\n\nAnswer based on the retrieved information:\n\n\"\"\"\n\nrag_function = KernelFunctionFromPrompt(\n\n&nbsp;&nbsp;&nbsp;&nbsp;function_name=\"RagAssistant\",\n\n&nbsp;&nbsp;&nbsp;&nbsp;plugin_name=\"RagPlugin\",\n\n&nbsp;&nbsp;&nbsp;&nbsp;prompt=rag_prompt\n\n)\n\nkernel.add_function(rag_function)<\/code><\/pre>\n\n\n\n<p>When invoked, the <a href=\"https:\/\/www.guvi.in\/blog\/how-to-create-effective-ai-prompts\/\" target=\"_blank\" rel=\"noreferrer noopener\">prompt <\/a>will search memory and ground the answer in your documents.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 13: Run a RAG Query<\/strong><\/h3>\n\n\n\n<p>python<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>question = \"What is Semantic Kernel and what languages does it support?\"\n\nresult = asyncio.run(\n\n&nbsp;&nbsp;&nbsp;&nbsp;kernel.invoke(\n\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rag_function,\n\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;input=question\n\n&nbsp;&nbsp;&nbsp;&nbsp;)\n\n)\n\nprint(\"Q:\", question)\n\nprint(\"A:\", str(result))<\/code><\/pre>\n\n\n\n<p>The LLM uses retrieved snippets to answer based on your data.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Building AI Agents and Multi-Agent Workflows<\/strong><\/h2>\n\n\n\n<p>Semantic Kernel supports agent patterns where the LLM can plan, call tools, and collaborate with other agents.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Single AI Agent<\/strong><\/h2>\n\n\n\n<p>A simple agent is a kernel with:<\/p>\n\n\n\n<ul>\n<li>An LLM service.<\/li>\n\n\n\n<li><a href=\"https:\/\/blog.leena.ai\/glossary\/ai-plugin\/\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">Plugins <\/a>(tools).<\/li>\n\n\n\n<li>A prompt or function that acts as the agent\u2019s \u201cbrain\u201d.<\/li>\n<\/ul>\n\n\n\n<p>You already built this with AssistantPlugin and tool-enabled prompts.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Multi-Agent Orchestration<\/strong><\/h2>\n\n\n\n<p>For more complex scenarios, Semantic Kernel provides agent orchestration patterns:<\/p>\n\n\n\n<ul>\n<li><strong>Sequential:<\/strong> Pass results from one agent to the next in a pipeline.<\/li>\n\n\n\n<li><strong>Parallel:<\/strong> Run multiple agents concurrently and combine results.<\/li>\n\n\n\n<li><strong>Manager-based:<\/strong> A manager agent delegates tasks to specialist agents.<\/li>\n\n\n\n<li><strong>Custom:<\/strong> Implement your own selection and termination strategies.<\/li>\n<\/ul>\n\n\n\n<p>Typical steps:<\/p>\n\n\n\n<ol>\n<li>Define specialist agents (each with its own kernel, plugins, and prompts).<\/li>\n\n\n\n<li>Create an orchestration that wires agents together.<\/li>\n\n\n\n<li>Provide a task to the orchestration.<\/li>\n\n\n\n<li>Run the orchestration and collect final results.<\/li>\n<\/ol>\n\n\n\n<p>Example conceptual pattern (Python-like pseudocode):<\/p>\n\n\n\n<p>python<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Define agents\n\nresearch_agent = create_agent(\"ResearchAgent\", research_plugins)\n\nwriter_agent = create_agent(\"WriterAgent\", writing_plugins)\n\nreviewer_agent = create_agent(\"ReviewerAgent\", review_plugins)\n\n# Create orchestration\n\norchestration = SequentialOrchestration(\n\n&nbsp;&nbsp;&nbsp;&nbsp;agents=&#91;research_agent, writer_agent, reviewer_agent]\n\n)\n\n# Run\n\nresult = asyncio.run(\n\n&nbsp;&nbsp;&nbsp;&nbsp;orchestration.invoke(\"Write a short article about Semantic Kernel.\")\n\n)<\/code><\/pre>\n\n\n\n<p>The exact <a href=\"https:\/\/www.guvi.in\/hub\/computer-programming-tutorial\/working-with-apis\/\" target=\"_blank\" rel=\"noreferrer noopener\">API <\/a>varies by version and language; refer to the latest Semantic Kernel docs for current orchestration classes and patterns.<\/p>\n\n\n\n<p><em>Semantic Kernel is Microsoft\u2019s open-source, model-agnostic SDK that lets you plug in LLMs, build prompt functions and tools, add vector memory, and orchestrate single- or multi-agent workflows with planning and tool-calling. Learn AI &amp; ML with HCL GUVI\u2019s<\/em><a href=\"https:\/\/www.guvi.in\/mlp\/artificial-intelligence-and-machine-learning?utm_source=semantic-kernel-tutorial\" target=\"_blank\" data-type=\"link\" data-id=\"https:\/\/www.guvi.in\/mlp\/artificial-intelligence-and-machine-learning?utm_source=semantic-kernel-tutorial\" rel=\"noreferrer noopener\"><em> Artificial Intelligence and Machine\u00a0 Learning course<\/em><\/a><em>.\u00a0<\/em><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Common Mistakes to Avoid<\/strong><\/h2>\n\n\n\n<ul>\n<li>Hard-coding API keys instead of using environment variables.<\/li>\n\n\n\n<li>Mixing different embedding models for memory and queries.<\/li>\n\n\n\n<li>Registering plugins but not enabling function calling in prompts.<\/li>\n\n\n\n<li>Using volatile memory in production instead of a real vector store.<\/li>\n\n\n\n<li>Overloading a single agent with too many responsibilities.<\/li>\n\n\n\n<li>Not setting clear termination conditions for multi-agent workflows.<\/li>\n\n\n\n<li>Ignoring security and access control when exposing tools to LLMs.<\/li>\n\n\n\n<li>Treating prompts as free-form text instead of versioned, testable functions.<\/li>\n\n\n\n<li>Skipping evaluation of agent behavior and tool usage.<\/li>\n\n\n\n<li>Assuming orchestration patterns are one-size-fits-all without tuning.<\/li>\n<\/ul>\n\n\n\n<div style=\"background-color: #099f4e; border: 3px solid #110053; border-radius: 12px; padding: 18px 22px; color: #FFFFFF; font-size: 18px; font-family: Montserrat, Helvetica, sans-serif; line-height: 1.6; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); max-width: 750px;\"> \n  <strong style=\"font-size: 22px; color: #FFFFFF;\">\ud83d\udca1 Did You Know?<\/strong> \n  <br \/><br \/> \n   Semantic Kernel can automatically choose which plugin functions to call based on your prompt and function metadata.\nYou can combine multiple agents with different specialties and orchestrate them to solve complex tasks that a single model might struggle with.\n<\/div>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>What Should You Do Next?<\/strong><\/h2>\n\n\n\n<p>Use this practical checklist:<\/p>\n\n\n\n<ol>\n<li>Install the Semantic Kernel SDK for your language (.NET, Python, or Java).<\/li>\n\n\n\n<li>Configure your LLM provider (Azure OpenAI, OpenAI, or other).<\/li>\n\n\n\n<li>Create a kernel and register an AI service.<\/li>\n\n\n\n<li>Define your first prompt function and invoke it.<\/li>\n\n\n\n<li>Build native plugins for your key tools and APIs.<\/li>\n\n\n\n<li>Enable function calling in prompts to let the LLM use tools.<\/li>\n\n\n\n<li>Add memory with a vector store for RAG over your documents.<\/li>\n\n\n\n<li>Experiment with a simple single-agent assistant.<\/li>\n\n\n\n<li>Explore multi-agent orchestration patterns for complex workflows.<\/li>\n\n\n\n<li>Integrate logging, monitoring, and access control for production use.<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Conclusion<\/strong><\/h2>\n\n\n\n<p><strong>Semantic Kernel<\/strong> provides a structured, extensible way to build AI applications on top of LLMs. By combining a kernel, plugins, prompts, and memory, you can create agents that call tools, retrieve knowledge, and execute multi-step workflows.<\/p>\n\n\n\n<p>Whether you are building a simple chatbot, an enterprise copilot, or a multi-agent system, Semantic Kernel offers the primitives to orchestrate AI capabilities with enterprise-grade flexibility. Start with a single agent and simple plugins, then evolve to richer orchestration patterns as your needs grow.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>FAQs<\/strong><\/h2>\n\n\n<div id=\"rank-math-faq\" class=\"rank-math-block\">\n<div class=\"rank-math-list \">\n<div id=\"faq-question-1787738720266\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \"><strong>What is Semantic Kernel?<\/strong><\/h3>\n<div class=\"rank-math-answer \">\n\n<p>Semantic Kernel is Microsoft\u2019s open-source SDK for orchestrating LLMs, tools, memory, and agents into AI applications. It supports .NET, Python, and Java.<\/p>\n\n<\/div>\n<\/div>\n<div id=\"faq-question-1787738726959\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \"><strong>Do I need Azure to use Semantic Kernel?<\/strong><\/h3>\n<div class=\"rank-math-answer \">\n\n<p>No. Semantic Kernel works with Azure OpenAI, OpenAI, and other LLM providers. Azure is optional but common in enterprise scenarios.<\/p>\n\n<\/div>\n<\/div>\n<div id=\"faq-question-1787738733834\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \"><strong>What languages does Semantic Kernel support?<\/strong><\/h3>\n<div class=\"rank-math-answer \">\n\n<p>Semantic Kernel has SDKs for .NET (C#), Python, and Java, with similar concepts and patterns across languages.<\/p>\n\n<\/div>\n<\/div>\n<div id=\"faq-question-1787738741350\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \"><strong>What is a plugin in Semantic Kernel?<\/strong><\/h3>\n<div class=\"rank-math-answer \">\n\n<p>A plugin is a collection of functions (native code or prompts) that the kernel can invoke. Plugins let LLMs call tools, APIs, and business logic.<\/p>\n\n<\/div>\n<\/div>\n<div id=\"faq-question-1787738750267\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \"><strong>How does memory work in Semantic Kernel?<\/strong><\/h3>\n<div class=\"rank-math-answer \">\n\n<p>Memory uses vector embeddings and a vector store to retrieve relevant documents for a query. Retrieved content is injected into prompts for retrieval-augmented generation.<\/p>\n\n<\/div>\n<\/div>\n<\/div>\n<\/div>","protected":false},"excerpt":{"rendered":"<p>Semantic Kernel is Microsoft\u2019s open-source SDK for orchestrating AI models, plugins, and agents into cohesive applications. It supports .NET, Python, and Java, and integrates with Azure OpenAI, OpenAI, and other LLM providers. This tutorial shows how to set up Semantic Kernel, create your first AI agent, add plugins and memory, and run a simple multi-step [&hellip;]<\/p>\n","protected":false},"author":7,"featured_media":135981,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[933],"tags":[],"views":"444","authorinfo":{"name":"HCL GUVI","url":"https:\/\/www.guvi.in\/blog\/author\/guvipr\/"},"thumbnailURL":"https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2026\/08\/Semantic-Kernel-Tutorial-Microsofts-AI-Orchestration-Framework-300x117.webp","_links":{"self":[{"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/posts\/135790"}],"collection":[{"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/comments?post=135790"}],"version-history":[{"count":4,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/posts\/135790\/revisions"}],"predecessor-version":[{"id":137469,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/posts\/135790\/revisions\/137469"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/media\/135981"}],"wp:attachment":[{"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/media?parent=135790"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/categories?post=135790"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/tags?post=135790"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}