{"record":{"id":"bff3f41a19dfde70","repo":"mastra-ai/mastra","slug":"voyageai-api-key-is-required-set-voyage-api-key-e-bff3f4","errorCode":null,"errorMessage":"VoyageAI API key is required. Set VOYAGE_API_KEY environment variable or pass apiKey in config.","messagePattern":"VoyageAI API key is required\\. Set VOYAGE_API_KEY environment variable or pass apiKey in config\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"embedders/voyageai/src/multimodal-embedding.ts","lineNumber":92,"sourceCode":" * await vectorStore.upsert({ vectors: result.embeddings, ... });\n * ```\n */\nexport class VoyageMultimodalEmbeddingModel {\n  readonly provider = 'voyage' as const;\n  readonly modelId: string;\n  readonly maxEmbeddingsPerCall = 1000;\n  readonly supportsParallelCalls = true;\n\n  private client: VoyageAIClient;\n  private config: VoyageMultimodalEmbeddingConfig;\n\n  constructor(config: VoyageMultimodalEmbeddingConfig) {\n    this.modelId = config.model;\n    this.config = config;\n\n    const apiKey = config.apiKey || process.env.VOYAGE_API_KEY;\n    if (!apiKey) {\n      throw new Error(\n        'VoyageAI API key is required. Set VOYAGE_API_KEY environment variable or pass apiKey in config.',\n      );\n    }\n\n    this.client = new VoyageAIClient({ apiKey, ...(config.baseUrl ? { baseUrl: config.baseUrl } : {}) });\n  }\n\n  /**\n   * Generate embeddings for multimodal inputs\n   *\n   * @param args.values - Array of multimodal inputs, each containing interleaved content\n   * @param args.providerOptions - Runtime options to override config\n   * @returns Object containing embeddings array\n   */\n  async doEmbed(args: {\n    values: VoyageMultimodalInput[];\n    abortSignal?: AbortSignal;\n    headers?: Record<string, string>;","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/embedders/voyageai/src/multimodal-embedding.ts#L74-L110","documentation":"The Voyage multimodal embedding client requires a VoyageAI API key, checked at construction from config.apiKey then VOYAGE_API_KEY. Missing both throws immediately before any API call.","triggerScenarios":"new VoyageMultimodalEmbedding({ model }) with no apiKey in config and VOYAGE_API_KEY unset in the environment.","commonSituations":"Missing env var in production containers, CI secrets not exposed to the deploy step, .env not loaded before construction, or key assigned to the wrong variable name.","solutions":["Pass apiKey in the VoyageMultimodalEmbedding config.","Set VOYAGE_API_KEY in the environment before the process starts.","Load .env before instantiating the embedder.","Verify the variable name is spelled VOYAGE_API_KEY."],"exampleFix":"// before\nconst embedder = new VoyageMultimodalEmbedding({ model: 'voyage-multimodal-3' });\n// after\nconst embedder = new VoyageMultimodalEmbedding({\n  model: 'voyage-multimodal-3',\n  apiKey: process.env.VOYAGE_API_KEY,\n});","handlingStrategy":"validation","validationCode":"const apiKey = config.apiKey ?? process.env.VOYAGE_API_KEY;\nif (!apiKey) {\n  throw new Error('Set VOYAGE_API_KEY or pass apiKey before creating VoyageMultimodalEmbedding');\n}\nconst embedder = new VoyageMultimodalEmbedding({ ...config, apiKey });","typeGuard":"function hasVoyageApiKey(config: { apiKey?: string }): config is { apiKey: string } & typeof config {\n  return Boolean(config.apiKey ?? process.env.VOYAGE_API_KEY);\n}","tryCatchPattern":"let embedder;\ntry {\n  embedder = new VoyageMultimodalEmbedding(config);\n} catch (err) {\n  if ((err as Error).message.includes('API key is required')) {\n    throw new Error('VoyageAI key missing: check VOYAGE_API_KEY and deploy-time secrets');\n  }\n  throw err;\n}","preventionTips":["Configure VOYAGE_API_KEY as a secret in hosting/serverless platforms.","Load environment variables before module-level client construction.","Fail fast at startup with an explicit key-presence assertion.","Avoid empty-string values; the check treats falsy keys as missing."],"tags":["api-key","configuration","env-var","voyageai"],"backgroundTag":"missing-env-var","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}