Ollama's embedding model api support error #5060

Closed
opened 2026-02-21 18:09:12 -05:00 by yindo · 4 comments
Owner

Originally created by @i220319 on GitHub (Aug 15, 2024).

Self Checks

  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

0.70

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

When using Ollama's embedding model, your code should have hardcoded http://localhost:11434/api/embeddings instead of http://localhost:11434/api/embed. The correct endpoint is api/embeddings, not api/embed.

✔️ Expected Behavior

fix this bug

Actual Behavior

wait for fixed

Originally created by @i220319 on GitHub (Aug 15, 2024). ### Self Checks - [X] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [X] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [X] I confirm that I am using English to submit this report (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [X] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:) - [X] Please do not modify this template :) and fill in all the required fields. ### Dify version 0.70 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce When using Ollama's embedding model, your code should have hardcoded http://localhost:11434/api/embeddings instead of http://localhost:11434/api/embed. The correct endpoint is api/embeddings, not api/embed. ### ✔️ Expected Behavior fix this bug ### ❌ Actual Behavior wait for fixed
yindo added the 🐞 bug label 2026-02-21 18:09:12 -05:00
yindo closed this issue 2026-02-21 18:09:12 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Aug 15, 2024):

Hello @i220319, I'm here to assist you with any bugs, questions, or contributions you may have for the Dify repository. Let me know how I can help while we wait for a human maintainer.

To fix the issue with Ollama's embedding model API support in Dify version 0.70, you need to update the endpoint in the code from http://localhost:11434/api/embed to http://localhost:11434/api/embeddings.

Here is the updated code snippet:

# Original endpoint
http://localhost:11434/api/embed

# Updated endpoint
http://localhost:11434/api/embeddings

Make sure to replace all instances of the old endpoint in your code with the new one. Additionally, ensure that your Ollama service is correctly configured and accessible at http://localhost:11434. If you are using Docker, you might need to expose the Ollama service to the network properly. For Docker deployments, consider using the host's IP address or host.docker.internal instead of localhost to avoid connection issues [1][2][3].

To continue talking to Dosu, mention @dosu.

@dosubot[bot] commented on GitHub (Aug 15, 2024): <!-- Greeting --> Hello @i220319, I'm here to assist you with any bugs, questions, or contributions you may have for the Dify repository. Let me know how I can help while we wait for a human maintainer. <!-- Answer --> To fix the issue with Ollama's embedding model API support in Dify version 0.70, you need to update the endpoint in the code from `http://localhost:11434/api/embed` to `http://localhost:11434/api/embeddings`. Here is the updated code snippet: ```bash # Original endpoint http://localhost:11434/api/embed # Updated endpoint http://localhost:11434/api/embeddings ``` Make sure to replace all instances of the old endpoint in your code with the new one. Additionally, ensure that your Ollama service is correctly configured and accessible at `http://localhost:11434`. If you are using Docker, you might need to expose the Ollama service to the network properly. For Docker deployments, consider using the host's IP address or `host.docker.internal` instead of `localhost` to avoid connection issues <sup>[[1]](https://github.com/langgenius/dify-docs/blob/main/en/guides/model-configuration/ollama.md)</sup><sup>[[2]](https://github.com/langgenius/dify-docs/blob/main/zh_CN/guides/model-configuration/ollama.md)</sup><sup>[[3]](https://github.com/langgenius/dify-docs/blob/main/jp/guides/model-configuration/ollama.md)</sup>. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
Author
Owner

@crazywoola commented on GitHub (Aug 15, 2024):

See their docs:

Note: this endpoint has been superseded by /api/embed

POST /api/embeddings

Ref: https://github.com/langgenius/dify/pull/6876

@crazywoola commented on GitHub (Aug 15, 2024): - https://github.com/ollama/ollama/blob/main/docs/api.md#generate-embeddings - https://github.com/ollama/ollama/blob/main/docs/api.md#generate-embedding See their docs: > Note: this endpoint has been superseded by /api/embed ``` POST /api/embeddings ``` Ref: https://github.com/langgenius/dify/pull/6876
Author
Owner

@daocoder2 commented on GitHub (Aug 21, 2024):

This is a problem with the ollama API documentation.

I modified this code locally, and it works.

api/core/model_runtime/model_providers/ollama/text_embedding/text_embedding.py

  endpoint_url = endpoint_url.replace("api/embed", "api/embeddings")
  # Make the request to the OpenAI API
  response = requests.post(
      endpoint_url, headers=headers, data=json.dumps(payload), timeout=(10, 300)
  )

  response.raise_for_status()  # Raise an exception for HTTP errors
  response_data = response.json()

  # Extract embeddings and used tokens from the response
  embeddings = response_data["embedding"]
@daocoder2 commented on GitHub (Aug 21, 2024): This is a problem with the ollama API documentation. I modified this code locally, and it works. api/core/model_runtime/model_providers/ollama/text_embedding/text_embedding.py ```python endpoint_url = endpoint_url.replace("api/embed", "api/embeddings") # Make the request to the OpenAI API response = requests.post( endpoint_url, headers=headers, data=json.dumps(payload), timeout=(10, 300) ) response.raise_for_status() # Raise an exception for HTTP errors response_data = response.json() # Extract embeddings and used tokens from the response embeddings = response_data["embedding"] ```
Author
Owner

@crazywoola commented on GitHub (Sep 10, 2024):

You need to upgrade the Ollama client instead of doing this.

@crazywoola commented on GitHub (Sep 10, 2024): You need to upgrade the Ollama client instead of doing this.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#5060