sendRequest
Make a chat request using a language model.
Note that language model use may be subject to access restrictions and user consent. Calling this function for the first time (for an extension) will show a consent dialog to the user and because of that this function must only be called in response to a user action! Extensions can use LanguageModelAccessInformation.canSendRequest to check if they have the necessary permissions to make a request.
This function will return a rejected promise if making a request to the language model is not possible. Reasons for this can be:
user consent not given, see
NoPermissions
model does not exist anymore, see
NotFound
quota limits exceeded, see
Blocked
other issues in which case extension must check LanguageModelError.cause
An extension can make use of language model tool calling by passing a set of tools to LanguageModelChatRequestOptions.tools. The language model will return a LanguageModelToolCallPart and the extension can invoke the tool and make another request with the result.
Parameters
An array of message instances.
Options that control the request.
A cancellation token which controls the request. See CancellationTokenSource for how to create one.