{"record":{"id":"17974dc39c527395","repo":"mastra-ai/mastra","slug":"parallel-api-key-is-required-pass-apikey-or-s","errorCode":null,"errorMessage":"Parallel API key is required. Pass { apiKey } or set the PARALLEL_API_KEY environment variable.","messagePattern":"Parallel API key is required\\. Pass (.+?) or set the PARALLEL_API_KEY environment variable\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"integrations/parallel/src/client.ts","lineNumber":10,"sourceCode":"import Parallel from 'parallel-web';\nimport type { ClientOptions } from 'parallel-web';\n\nexport type ParallelClientOptions = ClientOptions;\nexport type ParallelClient = Parallel;\n\nexport function getParallelClient(config?: ParallelClientOptions): ParallelClient {\n  const apiKey = config?.apiKey ?? process.env.PARALLEL_API_KEY;\n  if (!apiKey) {\n    throw new Error('Parallel API key is required. Pass { apiKey } or set the PARALLEL_API_KEY environment variable.');\n  }\n\n  return new Parallel({ ...config, apiKey });\n}\n\nexport function createLazyParallelClient(config?: ParallelClientOptions): () => ParallelClient {\n  let client: ParallelClient | undefined;\n\n  return () => {\n    client ??= getParallelClient(config);\n    return client;\n  };\n}\n","sourceCodeStart":1,"sourceCodeEnd":24,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/integrations/parallel/src/client.ts#L1-L24","documentation":"getParallelClient resolves the Parallel API key from the explicit config or the PARALLEL_API_KEY env var; if neither is present it throws, since every request to the Parallel API needs authentication.","triggerScenarios":"Calling getParallelClient() or createLazyParallelClient()() with no apiKey option while process.env.PARALLEL_API_KEY is unset.","commonSituations":".env file not loaded (dotenv not called before use); env var present locally but missing in the deploy environment/CI; typo like PARALLEL_API_KEYS; lazy client deferred until runtime where the env differs.","solutions":["Set PARALLEL_API_KEY in the environment (export or .env loaded before client creation).","Pass { apiKey: process.env.PARALLEL_API_KEY } (or a secret-manager value) explicitly to getParallelClient.","Check the deploy environment / CI secrets include PARALLEL_API_KEY."],"exampleFix":"// before\nconst client = getParallelClient();\n// after\nconst client = getParallelClient({ apiKey: process.env.PARALLEL_API_KEY! });","handlingStrategy":"validation","validationCode":"const apiKey = config?.apiKey ?? process.env.PARALLEL_API_KEY;\nif (!apiKey) throw new Error('Set PARALLEL_API_KEY before creating the Parallel client');","typeGuard":"function hasParallelApiKey(config?: { apiKey?: string }): config is { apiKey: string } {\n  return typeof config?.apiKey === 'string' && config.apiKey.length > 0 || !!process.env.PARALLEL_API_KEY;\n}","tryCatchPattern":"let client: ParallelClient;\ntry {\n  client = getParallelClient();\n} catch (e) {\n  if ((e as Error).message.includes('Parallel API key is required')) {\n    throw new Error('PARALLEL_API_KEY missing in this environment');\n  }\n  throw e;\n}","preventionTips":["Load .env at process startup before any client creation","Add a startup env-var checklist (assert all required keys exist before serving traffic)","Add PARALLEL_API_KEY to deploy/CI secret configuration"],"tags":["api-key","configuration","environment","parallel"],"backgroundTag":"missing-api-key","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}