{"record":{"id":"bf3b587f9da76e66","repo":"Mintplex-Labs/anything-llm","slug":"aws-bedrock-llm-region-is-required-for-aws-bedrock","errorCode":null,"errorMessage":"AWS_BEDROCK_LLM_REGION is required for AWS Bedrock.","messagePattern":"AWS_BEDROCK_LLM_REGION is required for AWS Bedrock\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"server/utils/AiProviders/bedrock/index.js","lineNumber":33,"sourceCode":"  noSystemPromptModels = [\n    \"amazon.titan-text-express-v1\",\n    \"amazon.titan-text-lite-v1\",\n    \"cohere.command-text-v14\",\n    \"cohere.command-light-text-v14\",\n    \"us.deepseek.r1-v1:0\",\n  ];\n\n  noTemperatureModels = [\n    \"anthropic.claude-opus-4-7\",\n    \"anthropic.claude-opus-4-8\",\n    \"anthropic.claude-sonnet-5\",\n  ];\n\n  constructor(embedder = null, modelPreference = null) {\n    if (!process.env.AWS_BEDROCK_LLM_API_KEY)\n      throw new Error(\"AWS_BEDROCK_LLM_API_KEY is required for AWS Bedrock.\");\n    if (!process.env.AWS_BEDROCK_LLM_REGION)\n      throw new Error(\"AWS_BEDROCK_LLM_REGION is required for AWS Bedrock.\");\n\n    this.className = \"AWSBedrockLLM\";\n    this.model =\n      modelPreference || process.env.AWS_BEDROCK_LLM_MODEL_PREFERENCE;\n    this.region = process.env.AWS_BEDROCK_LLM_REGION;\n\n    const contextWindowLimit = this.promptWindowLimit();\n    this.limits = {\n      history: Math.floor(contextWindowLimit * 0.15),\n      system: Math.floor(contextWindowLimit * 0.15),\n      user: Math.floor(contextWindowLimit * 0.7),\n    };\n\n    this.openai = new OpenAIApi({\n      apiKey: process.env.AWS_BEDROCK_LLM_API_KEY,\n      baseURL: `https://bedrock-mantle.${this.region}.api.aws/v1`,\n    });\n","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/utils/AiProviders/bedrock/index.js#L15-L51","documentation":"Thrown by the AWSBedrockLLM constructor when process.env.AWS_BEDROCK_LLM_REGION is falsy, immediately after the API-key guard. Bedrock endpoints are regional (e.g. us-east-1), so the region is required both for the endpoint URL and for the underlying client. Without it the provider cannot compute a baseURL.","triggerScenarios":"Constructing AWSBedrockLLM with AWS_BEDROCK_LLM_API_KEY set but AWS_BEDROCK_LLM_REGION missing. Fires at construction, before any chat call.","commonSituations":"Key pasted but region omitted; region stored under AWS_REGION (the SDK default) instead of the provider-specific AWS_BEDROCK_LLM_REGION; copy-paste missing the region line; wrong region for the deployed model.","solutions":["Set `AWS_BEDROCK_LLM_REGION=<region>` (e.g. us-east-1, eu-west-1) in .env to match where your Bedrock models are available.","Confirm the region actually hosts the model in AWS_BEDROCK_LLM_MODEL_PREFERENCE.","Re-save Bedrock credentials in the UI to persist the region.","Restart the server after editing .env."],"exampleFix":"// before\n// .env\nAWS_BEDROCK_LLM_API_KEY=<key>\n// no region\n\n// after\nAWS_BEDROCK_LLM_API_KEY=<key>\nAWS_BEDROCK_LLM_REGION=us-east-1","handlingStrategy":"validation","validationCode":"const region = process.env.AWS_BEDROCK_LLM_REGION;\nconst VALID_REGIONS = /^(us|eu|ap|ca|sa|af|me)-(central|east|west|north|south|southeast|southwest|northeast)-\\d+/;\nif (!region || !VALID_REGIONS.test(region)) {\n  throw new Error(\n    \"AWS_BEDROCK_LLM_REGION is missing or malformed (e.g. us-east-1).\"\n  );\n}","typeGuard":"/** @param {unknown} r @returns {boolean} */\nfunction isAwsRegion(r) {\n  return typeof r === \"string\" && /^[a-z]{2}-[a-z]+-\\d+$/.test(r);\n}","tryCatchPattern":"try {\n  const llm = new AWSBedrockLLM(embedder, modelPref);\n} catch (e) {\n  if (/AWS_BEDROCK_LLM_REGION is required/.test(e.message)) {\n    return { ok: false, reason: \"missing-region\" };\n  }\n  throw e;\n}","preventionTips":["Pick a region that actually hosts your Bedrock models — availability is regional.","Don't rely on AWS_REGION/AWS_DEFAULT_REGION; this provider reads its own var.","Validate key+region+model together at save time.","Restart the server after region changes."],"tags":["config","env","bedrock","aws","constructor","region"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}