400 Client Error: Bad Request when using open ai compatible embedding provider. #19

Closed
opened 2026-02-16 10:17:46 -05:00 by yindo · 4 comments
Owner

Originally created by @ritamariavermelho06 on GitHub (Feb 25, 2025).

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.15.2

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

  1. Add a vectorization model with a provider compatible with OpenAI (OpenAI-API-compatible).
  2. Create a knowledge base and upload a file.

requests.exceptions.HTTPError: 400 Client Error: Bad Request for url.

✔️ Expected Behavior

Upload completed successfully and vectorized document.

Actual Behavior

No response

Originally created by @ritamariavermelho06 on GitHub (Feb 25, 2025). ### 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.15.2 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce 1) Add a vectorization model with a provider compatible with OpenAI (OpenAI-API-compatible). 2) Create a knowledge base and upload a file. requests.exceptions.HTTPError: 400 Client Error: Bad Request for url. ### ✔️ Expected Behavior Upload completed successfully and vectorized document. ### ❌ Actual Behavior _No response_
yindo closed this issue 2026-02-16 10:17:46 -05:00
Author
Owner

@crazywoola commented on GitHub (Feb 25, 2025):

I think we need more details to investigate, such as the mode;'s name, and where did you get this model.

@crazywoola commented on GitHub (Feb 25, 2025): I think we need more details to investigate, such as the mode;'s name, and where did you get this model.
Author
Owner

@dosubot[bot] commented on GitHub (Feb 25, 2025):

Hey @ritamariavermelho06! 👋 I'm here to help you out with any bugs, questions, or contributions you have in mind. I'm a bot designed to assist you while you wait for a human maintainer.

I found some relevant information that might help you troubleshoot the 400 Bad Request error when using an OpenAI-compatible embedding provider in Dify.

Common causes of a 400 Bad Request error in this context include:

  1. Special Characters in Query: Ensure that the body format is set to 'JSON' instead of 'raw' to properly escape special characters like newlines ('\n') in the query.
  2. Invalid API Key or Endpoint: Verify that the API key is valid and the endpoint URL is correct and accessible.
  3. ProviderNotInitializeError: Check if valid model provider credentials are set up in the settings.
  4. Model Parameter Range Issues: Ensure that parameters like 'temperature' are within the valid range for the model being used.
  5. Query or Prefix Prompt Too Long: Reduce the length of the prefix prompt or decrease the 'max token' value if necessary [1][2].

Additionally, you might want to check if there are any specific error messages or codes associated with the 400 error, as they can provide more insight into the issue [2].

If these suggestions don't resolve the issue, you might find it helpful to look at similar discussions, such as the one titled "Error: Response output is missing or does not contain embeddings" [3].

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

@dosubot[bot] commented on GitHub (Feb 25, 2025): <!-- Greeting --> Hey @ritamariavermelho06! 👋 I'm here to help you out with any bugs, questions, or contributions you have in mind. I'm a bot designed to assist you while you wait for a human maintainer. <!-- Answer --> I found some relevant information that might help you troubleshoot the 400 Bad Request error when using an OpenAI-compatible embedding provider in Dify. Common causes of a 400 Bad Request error in this context include: 1. **Special Characters in Query**: Ensure that the body format is set to 'JSON' instead of 'raw' to properly escape special characters like newlines ('\n') in the query. 2. **Invalid API Key or Endpoint**: Verify that the API key is valid and the endpoint URL is correct and accessible. 3. **ProviderNotInitializeError**: Check if valid model provider credentials are set up in the settings. 4. **Model Parameter Range Issues**: Ensure that parameters like 'temperature' are within the valid range for the model being used. 5. **Query or Prefix Prompt Too Long**: Reduce the length of the prefix prompt or decrease the 'max token' value if necessary <sup>[[1]](https://github.com/langgenius/dify/blob/main/api/controllers/service_api/app/error.py)</sup><sup>[[2]](https://github.com/langgenius/dify/issues/11643)</sup>. Additionally, you might want to check if there are any specific error messages or codes associated with the 400 error, as they can provide more insight into the issue <sup>[[2]](https://github.com/langgenius/dify/issues/11643)</sup>. If these suggestions don't resolve the issue, you might find it helpful to look at similar discussions, such as the one titled "Error: Response output is missing or does not contain embeddings" <sup>[[3]](https://github.com/langgenius/dify/discussions/10032)</sup>. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.* --- <sup>Help Dosu learn! Give it feedback: [Great Response](https://app.dosu.dev/response-feedback/92a14cb5-f782-444d-bab1-b7829003e607?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/92a14cb5-f782-444d-bab1-b7829003e607?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/92a14cb5-f782-444d-bab1-b7829003e607?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/92a14cb5-f782-444d-bab1-b7829003e607?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/92a14cb5-f782-444d-bab1-b7829003e607?feedback_type=hallucination) | [Bug Report](https://app.dosu.dev/response-feedback/92a14cb5-f782-444d-bab1-b7829003e607?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/92a14cb5-f782-444d-bab1-b7829003e607?feedback_type=other)</sup>
Author
Owner

@ritamariavermelho06 commented on GitHub (Feb 25, 2025):

I think we need more details to investigate, such as the mode;'s name, and where did you get this model.

Hello @crazywoola ! I am using the "Titan Text Embeddings V2" model, the model is executed on Bedrock but access is done using Litellm proxy, for that we are using the openai-compativel interface, direct requests to the Litellm endpoint following the OpenAi pattern occur successfully on Postman.

curl --location 'http://x.x.x.x:4000/v1/embeddings?model=bedrock%2Famazon.titan-embed-text-v2&input=teste'
--header 'accept: application/json'
--header 'x-api-key: sk-xxxxxxx
--header 'Content-Type: application/json'
--data '{
"input": "Dify"
}'

Result {"model":"amazon.titan-embed-text-v2:0","data":[{"embedding":[0.003222302533686161,0.007025...........],"index":0,"object":"embedding"}],"object":"list","usage":{"completion_tokens":0,"prompt_tokens":3,"total_tokens":3,"completion_tokens_details":null,"prompt_tokens_details":null}}

@ritamariavermelho06 commented on GitHub (Feb 25, 2025): > I think we need more details to investigate, such as the mode;'s name, and where did you get this model. Hello @crazywoola ! I am using the "Titan Text Embeddings V2" model, the model is executed on Bedrock but access is done using Litellm proxy, for that we are using the openai-compativel interface, direct requests to the Litellm endpoint following the OpenAi pattern occur successfully on Postman. curl --location 'http://x.x.x.x:4000/v1/embeddings?model=bedrock%2Famazon.titan-embed-text-v2&input=teste' \ --header 'accept: application/json' \ --header 'x-api-key: sk-xxxxxxx \ --header 'Content-Type: application/json' \ --data '{ "input": "Dify" }' `Result {"model":"amazon.titan-embed-text-v2:0","data":[{"embedding":[0.003222302533686161,0.007025...........],"index":0,"object":"embedding"}],"object":"list","usage":{"completion_tokens":0,"prompt_tokens":3,"total_tokens":3,"completion_tokens_details":null,"prompt_tokens_details":null}} `
Author
Owner

@dosubot[bot] commented on GitHub (Mar 28, 2025):

Hi, @ritamariavermelho06. I'm Dosu, and I'm helping the Dify team manage their backlog. I'm marking this issue as stale.

Issue Summary:

  • You reported a 400 Client Error: Bad Request in Dify version 0.15.2 during document upload and vectorization.
  • The issue occurs in a self-hosted Docker setup using an OpenAI-compatible embedding provider.
  • You clarified using the "Titan Text Embeddings V2" model via a Litellm proxy, with successful direct requests in Postman.
  • I suggested troubleshooting steps, including checking for special characters, API key validity, and model parameter issues.

Next Steps:

  • Please confirm if this issue is still relevant with the latest version of the Dify repository. If so, you can keep the discussion open by commenting here.
  • If there is no further activity, this issue will be automatically closed in 15 days.

Thank you for your understanding and contribution!

@dosubot[bot] commented on GitHub (Mar 28, 2025): Hi, @ritamariavermelho06. I'm [Dosu](https://dosu.dev), and I'm helping the Dify team manage their backlog. I'm marking this issue as stale. **Issue Summary:** - You reported a 400 Client Error: Bad Request in Dify version 0.15.2 during document upload and vectorization. - The issue occurs in a self-hosted Docker setup using an OpenAI-compatible embedding provider. - You clarified using the "Titan Text Embeddings V2" model via a Litellm proxy, with successful direct requests in Postman. - I suggested troubleshooting steps, including checking for special characters, API key validity, and model parameter issues. **Next Steps:** - Please confirm if this issue is still relevant with the latest version of the Dify repository. If so, you can keep the discussion open by commenting here. - If there is no further activity, this issue will be automatically closed in 15 days. Thank you for your understanding and contribution!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify-official-plugins#19