Function: extractModelOverride()
extractModelOverride(
req):string|null
Pull a model override out of a single HTTP request, checking sources in priority order:
X-Mastra-Modelheader?model=query string parameter- Body field (
modelormodelId, in that order)
Returns null when nothing is set, so callers can wrap with
if (override) ... without juggling empty strings. Body inspection
is lenient - any plain object with one of the configured keys
counts, mirroring how AI SDK chat clients pass arbitrary metadata
alongside messages.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”string | null