Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

Fix: Bedrock api_key overridden by existing-key fallback in add_llm (#14707)

VincentLambert870bc5936552
diff --git a/api/apps/llm_app.py b/api/apps/llm_app.py
index eaf56628fe..583e05af7c 100644
--- a/api/apps/llm_app.py
+++ b/api/apps/llm_app.py
@@ -202,7 +202,9 @@ async def add_llm():
elif factory == "Bedrock":
# For Bedrock, due to its special authentication method
# Assemble bedrock_ak, bedrock_sk, bedrock_region
- api_key = apikey_json(["auth_mode", "bedrock_ak", "bedrock_sk", "bedrock_region", "aws_role_arn"])
+ # Write into req["api_key"] to prevent the "existing key" override logic from replacing it
+ req["api_key"] = apikey_json(["auth_mode", "bedrock_ak", "bedrock_sk", "bedrock_region", "aws_role_arn"])
+ api_key = req["api_key"]
elif factory == "LocalAI":
llm_name += "___LocalAI"