{"record":{"id":"e2a0b1d8d56fc4e8","repo":"Mintplex-Labs/anything-llm","slug":"aws-bedrock-llm-api-key-is-required-for-aws-bedroc","errorCode":null,"errorMessage":"AWS_BEDROCK_LLM_API_KEY is required for AWS Bedrock.","messagePattern":"AWS_BEDROCK_LLM_API_KEY is required for AWS Bedrock\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"server/utils/AiProviders/bedrock/index.js","lineNumber":31,"sourceCode":"\nclass AWSBedrockLLM {\n  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`,","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/utils/AiProviders/bedrock/index.js#L13-L49","documentation":"Thrown by the AWSBedrockLLM constructor when process.env.AWS_BEDROCK_LLM_API_KEY is falsy. AnythingLLM's Bedrock provider authenticates via an API key (plus region) rather than the standard AWS sigv4 IAM flow, so the key is a hard precondition. It is the first of two Bedrock constructor guards.","triggerScenarios":"Constructing AWSBedrockLLM with AWS_BEDROCK_LLM_API_KEY unset. The constructor immediately reads the key, region, model, and computes context-window limits — all blocked if the key is missing.","commonSituations":"Bedrock selected but credentials not entered; assumption that AWS SDK picks up IAM role creds (this provider needs the explicit key env); env var misnamed vs AWS_BEDROCK_LLM_ACCESS_KEY; deploying to a new host without the env.","solutions":["Set `AWS_BEDROCK_LLM_API_KEY=<your bedrock api key>` in .env and restart.","Also set AWS_BEDROCK_LLM_REGION (next guard, error 172) at the same time to avoid the immediate follow-on throw.","If you intended IAM/role-based auth, note this provider requires the API-key env vars — generate a Bedrock API key accordingly or adapt the provider.","Re-save Bedrock credentials in the UI to persist both env vars."],"exampleFix":"// before\n// .env\nAWS_BEDROCK_LLM_API_KEY=\n\n// after\n// .env\nAWS_BEDROCK_LLM_API_KEY=<bedrock-key>\nAWS_BEDROCK_LLM_REGION=us-east-1","handlingStrategy":"validation","validationCode":"if (!process.env.AWS_BEDROCK_LLM_API_KEY) {\n  throw new Error(\n    \"AWS_BEDROCK_LLM_API_KEY is missing. This provider authenticates with an API key, not IAM role creds.\"\n  );\n}\nif (!process.env.AWS_BEDROCK_LLM_REGION) {\n  throw new Error(\"AWS_BEDROCK_LLM_REGION is missing (e.g. us-east-1).\");\n}\nconst llm = new AWSBedrockLLM(embedder, modelPref);","typeGuard":"/** @param {unknown} v @returns {boolean} */\nfunction isNonEmptyKey(v) {\n  return typeof v === \"string\" && v.trim().length > 0;\n}","tryCatchPattern":"try {\n  const llm = new AWSBedrockLLM(embedder, modelPref);\n} catch (e) {\n  if (/AWS_BEDROCK_LLM_API_KEY is required/.test(e.message)) {\n    return { ok: false, reason: \"missing-bedrock-key\" };\n  }\n  throw e;\n}","preventionTips":["Note that this Bedrock provider needs explicit API-key env vars, not the usual AWS SDK IAM chain.","Set key, region, and model preference together at provider-save time.","Document the required env var names (AWS_BEDROCK_LLM_*) to avoid confusion with AWS_* defaults.","Restart after credential edits."],"tags":["config","env","authentication","bedrock","aws","constructor"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}