diff --git a/python/dify_plugin/interfaces/model/openai_compatible/rerank.py b/python/dify_plugin/interfaces/model/openai_compatible/rerank.py index 6d116027..81cef672 100644 --- a/python/dify_plugin/interfaces/model/openai_compatible/rerank.py +++ b/python/dify_plugin/interfaces/model/openai_compatible/rerank.py @@ -55,9 +55,12 @@ def _invoke( url = server_url headers = { - "Authorization": f"Bearer {credentials.get('api_key')}", "Content-Type": "application/json", } + # Only add Authorization header when api_key is not empty + api_key = credentials.get("api_key") + if api_key: + headers["Authorization"] = f"Bearer {api_key}" # TODO: Do we need truncate docs to avoid llama.cpp return error?