feat: add local Ollama provider support with prefix stripping - #561
Open
niko4244 wants to merge 1 commit into
Open
feat: add local Ollama provider support with prefix stripping#561niko4244 wants to merge 1 commit into
niko4244 wants to merge 1 commit into
Conversation
Two changes to enable using a local Ollama instance (127.0.0.1:11434) instead of the Ollama Cloud API: 1. providers/index.ts: Change Ollama baseUrl from https://ollama.com/v1 to http://127.0.0.1:11434/v1, and rename from 'Ollama Cloud' to 'Local Ollama'. 2. providers/openai-compat.ts: Strip the 'ollama/' prefix from model IDs before sending to Ollama's API. FreeLLMAPI stores model IDs as 'ollama/<name>' but the local Ollama API expects bare model names (e.g., 'qwen3.5:4b' not 'ollama/qwen3.5:4b'). Both changes are backwards-compatible — the prefix stripping is a no-op when no prefix exists, and the base URL can be overridden via provider config.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two changes to enable using a local Ollama instance (http://127.0.0.1:11434) instead of the Ollama Cloud API:
1. Local Ollama base URL (providers/index.ts)
Changes the Ollama provider
baseUrlfromhttps://ollama.com/v1tohttp://127.0.0.1:11434/v1, and renames from'Ollama Cloud'to'Local Ollama'.2. Prefix stripping (providers/openai-compat.ts)
Strips the
ollama/prefix from model IDs before sending requests to Ollama's API. FreeLLMAPI stores model IDs asollama/<name>but the local Ollama API expects bare model names (e.g.,qwen3.5:4b, notollama/qwen3.5:4b).This is a generic fix — any FreeLLMAPI user running a local Ollama instance will hit this prefix mismatch.
Backwards Compatibility
ollama/prefix existsTesting
Tested end-to-end with 19 local Ollama models (qwen3.5, qwythos, gemma3, qwen3-coder, etc.) — all route correctly through the local instance. Also tested cloud providers (nvidia, minimax, mistral) to confirm the change doesn't affect non-Ollama routing.