{"record":{"id":"f56ea945acdd85b4","repo":"vercel/ai","slug":"description-api-key-is-missing-pass-it-using-t-f56ea9","errorCode":null,"errorMessage":"${description} API key is missing. Pass it using the 'apiKey' parameter or set either the FAL_API_KEY or FAL_KEY environment variable.","messagePattern":"(.+?) API key is missing\\. Pass it using the 'apiKey' parameter or set either the FAL_API_KEY or FAL_KEY environment variable\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/fal/src/fal-provider.ts","lineNumber":115,"sourceCode":"  }\n\n  if (apiKey != null) {\n    throw new Error(`${description} API key must be a string.`);\n  }\n\n  if (typeof process === 'undefined') {\n    throw new Error(\n      `${description} API key is missing. Pass it using the 'apiKey' parameter. Environment variables are not supported in this environment.`,\n    );\n  }\n\n  let envApiKey = process.env.FAL_API_KEY;\n  if (envApiKey == null) {\n    envApiKey = process.env.FAL_KEY;\n  }\n\n  if (envApiKey == null) {\n    throw new Error(\n      `${description} API key is missing. Pass it using the 'apiKey' parameter or set either the FAL_API_KEY or FAL_KEY environment variable.`,\n    );\n  }\n\n  if (typeof envApiKey !== 'string') {\n    throw new Error(\n      `${description} API key must be a string. The value of the environment variable is not a string.`,\n    );\n  }\n\n  return envApiKey;\n}\n\n/**\n * Create a fal.ai provider instance.\n */\nexport function createFal(options: FalProviderSettings = {}): FalProvider {\n  const baseURL = withoutTrailingSlash(options.baseURL ?? defaultBaseURL);","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/fal/src/fal-provider.ts#L97-L133","documentation":"loadFalApiKey throws this when no apiKey parameter was supplied and neither FAL_API_KEY nor FAL_KEY environment variables are set. The fal provider checks both variables in order before giving up.","triggerScenarios":"createFal() (no apiKey) executed in a Node-like environment where process.env.FAL_API_KEY and process.env.FAL_KEY are both undefined.","commonSituations":"Forgetting to add the key to .env, not loading .env (dotenv not invoked), or CI environments lacking the secret.","solutions":["Set the FAL_API_KEY (or FAL_KEY) environment variable.","Pass the key explicitly via createFal({ apiKey: '...' }).","Verify .env is loaded (e.g. dotenv/config) and the variable name matches exactly."],"exampleFix":"// before\nconst fal = createFal(); // no key anywhere\n// after (shell)\nexport FAL_API_KEY=\"fal_...\"\n// or\nconst fal = createFal({ apiKey: process.env.MY_FAL_KEY! });","handlingStrategy":"validation","validationCode":"if (!process.env.FAL_API_KEY && !process.env.FAL_KEY) {\n  throw new Error('Set FAL_API_KEY or FAL_KEY before creating the fal provider');\n}","typeGuard":null,"tryCatchPattern":"try {\n  fal = createFal();\n} catch (e) {\n  if ((e as Error).message.includes('API key is missing')) {\n    console.error('Missing fal credentials: set FAL_API_KEY or FAL_KEY');\n    process.exit(1);\n  }\n  throw e;\n}","preventionTips":["Add FAL_API_KEY to .env and commit a .env.example.","Load dotenv at process startup before creating providers.","Check secrets are present in CI with a preflight validation script."],"tags":["fal","api-key","missing-env-var","configuration"],"backgroundTag":"missing-api-key","analyzedSha":"69428b1f8b037e4d118fb4853428d5c4e620493c","analyzedAt":"2026-08-30T12:32:21.016Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}