Tutorials Microsoft Agent Framework with Ollama Tutorial
Connecting Kernel to Ollama
Connecting Kernel to Ollama: free step-by-step lesson with examples, common mistakes, and interview tips — part of Microsoft Agent Framework with Ollama Tutorial on Toolliyo Academy.
On this page
Microsoft Agent Framework with Ollama Tutorial · Lesson 32 of 100
Connecting Kernel to Ollama
Foundations & Ollama ✓ → .NET & Agents → RAG & Ops → Projects
.NET & Agents · 2 — Kernel · ~6 min · Semantic Kernel & Agents
What is this?
You register an Ollama chat completion service on the Kernel builder so prompts run against your local model instead of a cloud endpoint.
Why should you care?
This is the key wiring lesson: SK + Ollama = private agents with a familiar .NET API.
See it live — copy this example
Run CLI steps in a terminal. Run C# samples in a .NET 8 console or Web API project with Ollama running on localhost:11434.
// Example pattern (package versions vary — check current SK Ollama connector)
using Microsoft.SemanticKernel;
var builder = Kernel.CreateBuilder();
builder.AddOllamaChatCompletion(
modelId: "phi3:mini",
endpoint: new Uri("http://localhost:11434"));
var kernel = builder.Build();
var result = await kernel.InvokePromptAsync("Reply with one word: pong");
Console.WriteLine(result);
What happened?
- AddOllamaChatCompletion points SK at localhost Ollama.
- InvokePromptAsync sends a simple prompt and returns the model text.
Practice next
- Add the correct SK + Ollama connector package for your SK version.
- Start Ollama and ensure the model exists.
- Run InvokePromptAsync.
- Use mistral instead of phi3.
- Wrap invoke in try/catch and log errors.
Remember
SK can target Ollama locally. Model id must match pulled tags. Keep endpoint in config.
Private prompt path
HR FAQ agent never leaves the building network.
Outcome: Kernel → Ollama on localhost.
Interview prep for this lesson
Practice these questions aloud after reading—each links to a full structured answer.
Sign in to ask a question or upvote helpful answers.
No questions yet — be the first to ask!