{"record":{"id":"54f4c67963ce2875","repo":"mastra-ai/mastra","slug":"attempted-to-parse-provider-model-from-routerid","errorCode":null,"errorMessage":"Attempted to parse provider/model from ${routerId} but this ID doesn't appear to contain a provider","messagePattern":"Attempted to parse provider/model from (.+?) but this ID doesn't appear to contain a provider","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/core/src/llm/model/gateway-resolver.ts","lineNumber":53,"sourceCode":"    }\n    return {\n      providerId: gatewayPrefix,\n      modelId,\n    };\n  }\n\n  // Standard 3-part format for other prefixed gateways (Netlify, etc.)\n  if (gatewayPrefix && idParts.length < 3) {\n    throw new Error(\n      `Expected atleast 3 id parts ${gatewayPrefix}/provider/model, but only saw ${idParts.length} in ${routerId}`,\n    );\n  }\n\n  const providerId = idParts.at(gatewayPrefix ? 1 : 0);\n  const modelId = idParts.slice(gatewayPrefix ? 2 : 1).join(`/`);\n\n  if (!routerId.includes(`/`) || !providerId || !modelId) {\n    throw new Error(\n      `Attempted to parse provider/model from ${routerId} but this ID doesn't appear to contain a provider`,\n    );\n  }\n\n  return {\n    providerId,\n    modelId,\n  };\n}\n","sourceCodeStart":35,"sourceCodeEnd":63,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/llm/model/gateway-resolver.ts#L35-L63","documentation":"After splitting the router ID, parseModelRouterId validates that the ID contains at least one slash and that both providerId and modelId resolved to non-empty strings. This error is thrown when the resulting providerId or modelId is empty (e.g. trailing/leading slashes) or — when no gatewayPrefix is given — the ID has no slash at all, so no provider can be extracted.","triggerScenarios":"Calling parseModelRouterId with an unprefixed ID lacking a slash (e.g. 'gpt-4o'), or IDs with empty segments such as 'openai/' or '/gpt-4o' (also reachable for gateway-prefixed IDs with empty trailing parts).","commonSituations":"Passing a bare model name without a provider prefix; string interpolation producing empty segments (e.g. `\"${provider}/${undefined}\"` -> 'openai/'); trimming or joining strings incorrectly before resolution.","solutions":["Include the provider in the ID, e.g. use 'openai/gpt-4o' instead of 'gpt-4o'.","Check for empty ID segments — remove trailing or duplicate slashes like 'openai/' or '//model'.","Inspect any template-string construction of the ID for undefined/null variables that collapse to empty segments.","Log the exact routerId in the message and verify it matches the catalog/model-list ID you intend to resolve."],"exampleFix":"// before\nconst model = gateway.resolveModel('gpt-4o');\n// after\nconst model = gateway.resolveModel('openai/gpt-4o');","handlingStrategy":"validation","validationCode":"function ensureProviderPrefixedId(routerId: string): void {\n  const parts = routerId.split('/');\n  if (parts.length < 2 || !parts[0] || !parts[1]) {\n    throw new Error(`Router ID must include a provider: expected provider/model, got \"${routerId}\"`);\n  }\n}","typeGuard":"function hasProviderAndModel(routerId: string): boolean {\n  const [provider, model] = routerId.split('/');\n  return Boolean(provider && model);\n}","tryCatchPattern":"try {\n  const { providerId, modelId } = parseModelRouterId(routerId);\n} catch (e) {\n  throw new Error(`Router ID \"${routerId}\" lacks a provider segment; use provider/model form`, { cause: e });\n}","preventionTips":["Always prefix bare model names with their provider (openai/gpt-4o, not gpt-4o).","Sanitize IDs built via template strings to avoid empty segments from undefined values.","Normalize the ID (collapse duplicate slashes, trim) before resolution."],"tags":["model-router","parsing","invalid-model-id","gateway"],"backgroundTag":"invalid-model-id","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T08:17:16.595Z"}