跳到主要内容
非官方简体中文翻译,内容版权归 Mastra 所有,遵循 Apache-2.0 许可。

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 example
Usage example的直接链接

await agent.getModel()

Parameters
Parameters的直接链接

options?:

{ requestContext?: RequestContext }
= {}
Optional configuration object containing request context.
{ requestContext?: RequestContext }

requestContext?:

RequestContext
Request Context for dependency injection and contextual information.

Returns
Returns的直接链接

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 example
Extended usage example的直接链接

await agent.getModel({
requestContext: new RequestContext(),
})