byterover-cli icon indicating copy to clipboard operation
byterover-cli copied to clipboard

[BUG] Ollama embeddings endpoint mismatch

Open radixm46 opened this issue 1 year ago • 4 comments

Bug Description

Cipher’s Ollama embedding backend calls a non‑existent path POST $OLLAMA_BASE_URL/api/embedding. Per Ollama’s API, the correct endpoints are POST /api/embed (current) or POST $OLLAMA_BASE_URL/v1/embeddings (OpenAI‑compatible). As a result, embedding requests return 404.

Steps to Reproduce

Steps to reproduce the behavior:

  1. Configure Cipher to use the Ollama embedding provider.
embedding:
  type: ollama
  model: mxbai-embed-large
  baseUrl: $OLLAMA_BASE_URL
  dimensions: 1024
OLLAMA_BASE_URL="http://ollama-address/v1"
  1. Execute a workflow or command that triggers an embedding request through Cipher.
  2. Observe the resulting HTTP request sent to Ollama.

Expected Behavior

call below instead of /api/embedding

  • Native Ollama: POST /api/embed ollama
  • OpenAI-compatible: POST /v1/embeddings ollama

Actual Behavior

Requests are sent to POST /api/embedding and fail with 404.

Screenshots

N/A

Environment Information

  • OS: Linux
  • Browser: N/A
  • Version: 0.3.0
  • Node.js: v24.7.0
  • Ollama: 0.11.6

Logs and Error Messages

Observed request on ollama server from cipher

[GIN] 2025/09/01 - 16:42:24 | 404 |        5.16µs |     <ipaddr> | POST     "/v1/embedding"

Additional Context

possibly related comments

  • https://github.com/campfirein/cipher/blob/84e775a7ce1666e2be34d43dc6a84d0b8c5971fc/src/core/brain/embedding/backend/ollama.ts#L62
  • https://github.com/campfirein/cipher/blob/84e775a7ce1666e2be34d43dc6a84d0b8c5971fc/src/core/utils/service-initializer.ts#L70

Possible Solution

  • Update the Ollama embedding backend to call /api/embed for native API.
  • Optionally, when baseUrl ends with /v1, route to /v1/embeddings (OpenAI-compatible).

Checklist

  • [x] I have searched for similar issues before creating this one
  • [x] I have provided all the requested information above
  • [x] I have tested this on the latest version

radixm46 avatar Sep 01 '25 20:09 radixm46

I will resolve this error asap.

willingWill17 avatar Sep 03 '25 08:09 willingWill17

Thanks for the response and the PR! I tested the changes locally and confirmed that the Ollama endpoint has been updated to /v1/embeddings.

However, I’m still seeing HTTP 400 errors. Capturing the request shows that the payload is currently:

{
 "model": "embedding-model-name",
 "prompt": "text to embed"
}

According to Ollama’s API (and the OpenAI-compatible schema), the correct field should be input, not prompt:

{
 "model": "embedding-model-name",
 "input": "text to embed"
}

It looks like the endpoint fix landed, but the request body format still needs to be updated as well. Could you please check this?

radixm46 avatar Sep 03 '25 13:09 radixm46

Thank you for the thorough notes. I pushed the code yesterday and was aware that it didnt resolve the issue. I push a new commit to tackle the problem, you can check the new code update now

willingWill17 avatar Sep 04 '25 09:09 willingWill17

I tested with the latest changes, and both the endpoint and the request payload are now working correctly. Thanks for the fix!

radixm46 avatar Sep 04 '25 10:09 radixm46