Skip to content

callLanguageModel

callLanguageModel(model, ctx, responseFormat?): Promise<ModelResponse>

Calls a LanguageModelV3 instance with the messages and tools from a ModelContext.

This is the core bridge function: converts Agent Express format → AI SDK V3 format, calls model.doGenerate(), and converts the result back.

LanguageModelV3

Resolved LanguageModelV3 instance

ModelContext

ModelContext with messages and tool definitions

string

string

Record<string, unknown>

"json"

Promise<ModelResponse>

Normalized ModelResponse