fix(ollama): accept prompt alias on /api/embed for Ollama parity#9780
Merged
Conversation
Ollama's embedding endpoint accepts both `input` and `prompt` as the input string value (see ollama/ollama docs/api.md#generate-embeddings). LocalAI only accepted `input`, which broke client libraries that send the `prompt` form. Add `Prompt` to OllamaEmbedRequest and have GetInputStrings fall back to it when Input is unset. Input still wins when both are provided. Fixes #9767. Assisted-by: Claude:claude-opus-4-7 [Claude Code] Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
mudler
approved these changes
May 12, 2026
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
/api/embedendpoint accepts bothinputandpromptfor the input string value (upstream docs). LocalAI only acceptedinput, which silently broke client libraries that send thepromptform (returning400 input is required).PrompttoOllamaEmbedRequestand haveGetInputStringsfall back to it whenInputis unset.Inputstill wins when both are provided.Test plan
core/schema/ollama_test.gocovering both single-string and arraypromptpayloads, plus precedence when both keys are set.input(string /[]string/[]any) behavior preserved.go test ./core/schema/...— 30/30 pass.go vet ./core/schema/... ./core/http/endpoints/ollama/...— clean.curl -s localhost:8080/api/embed -d '{"model":"<m>","prompt":"hello"}'now returns embeddings instead of400.