Skip to content

Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active

🪨 feat: AWS Bedrock Default Credentials Chain (#4038)

Danny Avilae293ff63f9ac
diff --git a/api/app/clients/OpenAIClient.js b/api/app/clients/OpenAIClient.js
index 789bf9915e..405465a61e 100644
--- a/api/app/clients/OpenAIClient.js
+++ b/api/app/clients/OpenAIClient.js
@@ -914,7 +914,9 @@ ${convo}
*/
getStreamUsage() {
if (
+ this.usage &&
typeof this.usage === 'object' &&
+ 'completion_tokens_details' in this.usage &&
typeof this.usage.completion_tokens_details === 'object'
) {
const outputTokens = Math.abs(
diff --git a/api/server/services/Config/EndpointService.js b/api/server/services/Config/EndpointService.js
index 485c99f373..56768905b8 100644
--- a/api/server/services/Config/EndpointService.js
+++ b/api/server/services/Config/EndpointService.js
@@ -45,7 +45,9 @@ module.exports = {
AZURE_ASSISTANTS_BASE_URL,
EModelEndpoint.azureAssistants,
),
- [EModelEndpoint.bedrock]: generateConfig(process.env.BEDROCK_AWS_SECRET_ACCESS_KEY),
+ [EModelEndpoint.bedrock]: generateConfig(
+ process.env.BEDROCK_AWS_SECRET_ACCESS_KEY ?? process.env.BEDROCK_AWS_DEFAULT_REGION,
+ ),
/* key will be part of separate config */
[EModelEndpoint.agents]: generateConfig(process.env.I_AM_A_TEAPOT),
},
diff --git a/api/server/services/Endpoints/bedrock/options.js b/api/server/services/Endpoints/bedrock/options.js
index 0839d033ce..d3a33fee3c 100644
--- a/api/server/services/Endpoints/bedrock/options.js
+++ b/api/server/services/Endpoints/bedrock/options.js
@@ -19,7 +19,7 @@ const getOptions = async ({ req, endpointOption }) => {
const expiresAt = req.body.key;
const isUserProvided = BEDROCK_AWS_SECRET_ACCESS_KEY === AuthType.USER_PROVIDED;
- const credentials = isUserProvided
+ let credentials = isUserProvided
? await getUserKey({ userId: req.user.id, name: EModelEndpoint.bedrock })
: {
accessKeyId: BEDROCK_AWS_ACCESS_KEY_ID,
@@ -30,6 +30,14 @@ const getOptions = async ({ req, endpointOption }) => {
throw new Error('Bedrock credentials not provided. Please provide them again.');
}
+ if (
+ !isUserProvided &&
+ (credentials.accessKeyId === undefined || credentials.accessKeyId === '') &&
+ (credentials.secretAccessKey === undefined || credentials.secretAccessKey === '')
+ ) {
+ credentials = undefined;
+ }
+
if (expiresAt && isUserProvided) {
checkUserKeyExpiry(expiresAt, EModelEndpoint.bedrock);
}