Agent.getModel()
The .getModel() method retrieves the language model configured for an agent, resolving it if it's a function. This method is used to access the underlying model that powers the agent's capabilities.
Usage exampleUsage example的直接链接
await agent.getModel()
ParametersParameters的直接链接
options?:
{ requestContext?: RequestContext }
= {}
Optional configuration object containing request context.
{ requestContext?: RequestContext }
requestContext?:
RequestContext
Request Context for dependency injection and contextual information.
ReturnsReturns的直接链接
model:
MastraLanguageModel | MastraLegacyLanguageModel | Promise<MastraLanguageModel | MastraLegacyLanguageModel>
The language model configured for the agent, either as a direct instance or a promise that resolves to the model.
Extended usage exampleExtended usage example的直接链接
await agent.getModel({
requestContext: new RequestContext(),
})