Today I had to do some small changes in an existing project where we were using Semantic Kernel together with Ollama during debugging and testing. As Ollama exposes an Open AI compatible API, this is possible without any code changes. At least it was...
Here is the code I was using:
When I opened the project I noticed that some of the packages references where outdated so I started by upgrading to the latest version of the Semantic Kernel NuGet packages. However after doing that the requests started to fail with a 404 error message.
Mmm? Didn’t I got the same error before? And indeed I talked about this issue in an earlier post. The issue is still there as I could confirm by looking at the Ollama log messages:
Here is the successful request using the old Semantic Kernel version:
[GIN] 2025/04/24 - 10:05:40 | 200 | 48.466781s | 127.0.0.1 | POST "/v1/chat/completions"
Here is the failing request using the new(er) Semantic Kernel version:
[GIN] 2025/04/24 - 11:31:35 | 404 | 0s | 127.0.0.1 | POST "/chat/completions"
To finally get rid of the error I should no longer using the Open AI connector to talk to Ollama but instead use the dedicated Ollama connector. Here is the updated code:
The only disadvantage is that I had to introduce a conditional compilation symbol to load and execute the correct code depending on the environment.
But problem solved!