QVAC Logo

invokePluginStream( )

Invoke a streaming plugin handler.

function invokePluginStream<TResponse = unknown, TParams = unknown>(
  options: InvokePluginOptions<TParams>
): AsyncGenerator<TResponse>;

Parameters

NameTypeRequired?Description
optionsInvokePluginOptionsThe invocation options (same as invokePlugin())

Returns

AsyncGenerator<TResponse> — Yields streamed chunks from the handler until done is received.

Throws

ErrorWhen
INVALID_RESPONSE_TYPEA chunk's type does not match expected "pluginInvokeStream"

Example

const stream = invokePluginStream<{ token: string }>({
  modelId: "my-custom-model",
  handler: "generateStream",
  params: { prompt: "Tell me a story" },
});

for await (const chunk of stream) {
  process.stdout.write(chunk.token);
}

On this page