{"record":{"id":"5597d88930df558b","repo":"mastra-ai/mastra","slug":"invalid-model-string-format-config-id-expec","errorCode":null,"errorMessage":"Invalid model string format: \"${config.id}\". Expected format: \"mastra/provider/model\"","messagePattern":"Invalid model string format: \"(.+?)\"\\. Expected format: \"mastra/provider/model\"","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/core/src/llm/model/embedding-router.ts","lineNumber":163,"sourceCode":"          throw new Error(`Invalid model string format: \"${config}\". Expected format: \"provider/model\"`);\n        }\n        const [providerId, modelId] = parts as [string, string];\n        normalizedConfig = { providerId, modelId };\n      }\n    } else if ('providerId' in config && 'modelId' in config) {\n      normalizedConfig = {\n        providerId: config.providerId,\n        modelId: config.modelId,\n        url: config.url,\n        apiKey: config.apiKey,\n        headers: config.headers,\n      };\n    } else {\n      // config has 'id' field\n      const parts = config.id.split('/');\n      if (parts[0] === MASTRA_GATEWAY_ID) {\n        if (parts.length < 3) {\n          throw new Error(`Invalid model string format: \"${config.id}\". Expected format: \"mastra/provider/model\"`);\n        }\n        normalizedConfig = {\n          providerId: MASTRA_GATEWAY_ID,\n          modelId: parts.slice(1).join('/'),\n          url: config.url,\n          apiKey: config.apiKey,\n          headers: config.headers,\n        };\n      } else {\n        if (parts.length !== 2) {\n          throw new Error(`Invalid model string format: \"${config.id}\". Expected format: \"provider/model\"`);\n        }\n        const [providerId, modelId] = parts as [string, string];\n        normalizedConfig = {\n          providerId,\n          modelId,\n          url: config.url,\n          apiKey: config.apiKey,","sourceCodeStart":145,"sourceCodeEnd":181,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/llm/model/embedding-router.ts#L145-L181","documentation":"When config is an object with an `id` field whose first segment is \"mastra\", the EmbeddingRouter expects the Mastra gateway 3-part format \"mastra/provider/model\". If splitting on '/' yields fewer than 3 parts (e.g. just \"mastra/model\"), it throws, because the provider segment between the gateway prefix and model id is missing.","triggerScenarios":"new EmbeddingRouter({ id: \"mastra/openai\" }) or { id: \"mastra\" } — a mastra-prefixed id with no provider/model sub-path.","commonSituations":"Truncating a copied model id; assuming \"mastra\" alone selects the gateway without naming provider and model; programmatic string building that dropped a segment.","solutions":["Use the full 3-part id: \"mastra/provider/model\" (e.g. \"mastra/openai/text-embedding-3-small\").","If not using the Mastra gateway, drop the \"mastra/\" prefix and use \"provider/model\".","Verify the id was not truncated during string interpolation or env-var loading."],"exampleFix":"// before\nnew EmbeddingRouter({ id: \"mastra/openai\" });\n// after\nnew EmbeddingRouter({ id: \"mastra/openai/text-embedding-3-small\" });","handlingStrategy":"validation","validationCode":"function assertMastraId(id) {\n  const parts = id.split('/');\n  if (parts[0] === 'mastra' && parts.length < 3) {\n    throw new Error(`Mastra ids need \"mastra/provider/model\", got: ${id}`);\n  }\n}\nassertMastraId(config.id);","typeGuard":"const isMastraId = (id) => id.startsWith('mastra/') && id.split('/').length >= 3;","tryCatchPattern":"try {\n  router = new EmbeddingRouter({ id });\n} catch (e) {\n  if (e instanceof Error && e.message.includes('mastra/provider/model')) {\n    console.error(`Mastra gateway ids require 3 parts: ${id}`);\n  } else throw e;\n}","preventionTips":["Keep full mastra ids (all 3 segments) in config/storage — never truncate.","When building ids from parts, join and validate segment count before use.","Document the mastra id format where gateway ids are authored."],"tags":["validation","configuration","model-router"],"backgroundTag":"invalid-model-string-format","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}