{"record":{"id":"c60a88b527bfe35c","repo":"mastra-ai/mastra","slug":"invalid-model-string-format-config-id-expec-c60a88","errorCode":null,"errorMessage":"Invalid model string format: \"${config.id}\". Expected format: \"provider/model\"","messagePattern":"Invalid model string format: \"(.+?)\"\\. Expected format: \"provider/model\"","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/core/src/llm/model/embedding-router.ts","lineNumber":174,"sourceCode":"        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,\n          headers: config.headers,\n        };\n      }\n    }\n\n    this.provider = normalizedConfig.providerId;\n    this.modelId = normalizedConfig.modelId;\n\n    if (normalizedConfig.providerId === MASTRA_GATEWAY_ID) {\n      const apiKey = normalizedConfig.apiKey ?? process.env['MASTRA_GATEWAY_API_KEY'];\n      if (!apiKey) {","sourceCodeStart":156,"sourceCodeEnd":192,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/llm/model/embedding-router.ts#L156-L192","documentation":"For an object config with an `id` field that is not mastra-prefixed, the id must be exactly \"provider/model\" (two slash-separated parts). Any other segment count (e.g. 1 part or 3+ parts) makes provider/model extraction ambiguous, so the constructor throws.","triggerScenarios":"new EmbeddingRouter({ id: \"openai\" }) (missing model) or { id: \"openai/text-embedding-3-small/v2\" } (extra segment) — anything where id.split('/').length !== 2 without a mastra prefix.","commonSituations":"Passing just a provider name; model ids that naturally contain slashes (Azure, Bedrock, HF paths) without a mastra prefix; accidental double slashes.","solutions":["Make the id exactly \"provider/model\" (e.g. \"openai/text-embedding-3-small\").","For model ids containing slashes, use object config { providerId, modelId } so no slash splitting occurs.","Prefix with \"mastra/\" if you actually want gateway routing (which permits longer ids)."],"exampleFix":"// before\nnew EmbeddingRouter({ id: \"cohere/embed-v3.0/multilingual\" });\n// after\nnew EmbeddingRouter({ providerId: \"cohere\", modelId: \"embed-v3.0/multilingual\" });","handlingStrategy":"validation","validationCode":"function assertProviderModelId(id) {\n  if (!id.startsWith('mastra/') && id.split('/').length !== 2) {\n    throw new Error(`Expected \"provider/model\", got: ${id}`);\n  }\n}\nassertProviderModelId(config.id);","typeGuard":"const isPlainProviderModelId = (id) => !id.startsWith('mastra/') && id.split('/').length === 2 && id.split('/').every(Boolean);","tryCatchPattern":"try {\n  router = new EmbeddingRouter({ id });\n} catch (e) {\n  if (e instanceof Error && e.message.includes('Expected format: \"provider/model\"')) {\n    console.error(`id must be \"provider/model\": ${id}`);\n  } else throw e;\n}","preventionTips":["For slashed model ids (Azure/HF/Bedrock), always use object config with explicit providerId/modelId.","Reject empty segments when composing ids.","Sanitize user-supplied ids (trim, collapse duplicate slashes) before construction."],"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"}