invokePlugin( )
Invoke a non-streaming plugin handler.
function invokePlugin<TResponse = unknown, TParams = unknown>(
options: InvokePluginOptions<TParams>
): Promise<TResponse>;
| Field | Type | Required? | Description |
|---|
| modelId | string | ✓ | The model ID of the loaded plugin model |
| handler | string | ✓ | The handler name to invoke (as defined in the plugin) |
| params | TParams | ✓ | Parameters to pass to the handler (validated against the handler's requestSchema) |
Promise<TResponse> — The handler's response (validated against the handler's responseSchema).
| Error | When |
|---|
INVALID_RESPONSE_TYPE | Response type does not match expected "pluginInvoke" |
const result = await invokePlugin<{ answer: string }>({
modelId: "my-custom-model",
handler: "summarize",
params: { text: "Long document..." },
});
console.log(result.answer);