xonecas.io
64875
Mc

mini-coder / commit 8bf2c8c

Replace ollama-ai-provider with @ai-sdk/openai-compatible for Ollama

ollama-ai-provider v1.2.0 implements spec v1, which is incompatible
with AI SDK v6 (requires spec v2).

Rather than switching to the ollama-ai-provider-v2 community fork
(as suggested in #2), this uses the already-present
@ai-sdk/openai-compatible package to talk to Ollama's
OpenAI-compatible endpoint (/v1). This avoids adding a new
dependency entirely.

Fixes #2

Andy2026-03-08 8bf2c8c589a02bead246d51f087f0c673672d3dc parent 81baffb

2 files changed

package.json+0−1
@@ -23,7 +23,6 @@
2323 "@modelcontextprotocol/sdk": "^1.26.0",
2424 "ai": "^6.0.94",
2525 "ignore": "^7.0.5",
26- "ollama-ai-provider": "^1.2.0",
2726 "yoctocolors": "^2.1.1",
2827 "zod": "^4.3.6"
2928 },
src/llm-api/providers.ts+6−5
@@ -3,7 +3,7 @@ import { createGoogleGenerativeAI } from "@ai-sdk/google";
33 import { createOpenAI } from "@ai-sdk/openai";
44 import { createOpenAICompatible } from "@ai-sdk/openai-compatible";
55 import type { LanguageModel } from "ai";
6-import { createOllama } from "ollama-ai-provider";
6+
77
88 import { logApiEvent } from "./api-log.ts";
99 import {
@@ -343,12 +343,13 @@ export function resolveModel(modelString: string): LanguageModel {
343343
344344 case "ollama": {
345345 const baseURL = process.env.OLLAMA_BASE_URL ?? "http://localhost:11434";
346- const ollamaProvider = createOllama({
346+ const ollamaProvider = createOpenAICompatible({
347+ name: "ollama",
348+ baseURL: `${baseURL}/v1`,
349+ apiKey: "ollama",
347350 fetch: getFetchWithLogging(),
348- baseURL,
349351 });
350- // ollama-ai-provider returns LanguageModelV1; cast to LanguageModel
351- return ollamaProvider(modelId) as unknown as LanguageModel;
352+ return ollamaProvider.chatModel(modelId);
352353 }
353354
354355 default: