docs-devsite/ai.singlerequestoptions.md
Project: /docs/reference/js/_project.yaml Book: /docs/reference/_book.yaml page_type: reference
{% comment %} DO NOT EDIT THIS FILE! This is generated by the JS SDK team, and any local changes will be overwritten. Changes should be made in the source code at https://github.com/firebase/firebase-js-sdk {% endcomment %}
Options that can be provided per-request. Extends the base RequestOptions (like timeout and baseUrl<!-- -->) with request-specific controls like cancellation via AbortSignal<!-- -->.
Options specified here will override any default RequestOptions configured on a model (for example, GenerativeModel<!-- -->).
<b>Signature:</b>
export interface SingleRequestOptions extends RequestOptions
<b>Extends:</b> RequestOptions
| Property | Type | Description |
|---|---|---|
| signal | AbortSignal | An <code>AbortSignal</code> instance that allows cancelling ongoing requests (like <code>generateContent</code> or <code>generateImages</code>).<!-- -->If provided, calling <code>abort()</code> on the corresponding <code>AbortController</code> will attempt to cancel the underlying HTTP request. An <code>AbortError</code> will be thrown if cancellation is successful.<!-- -->Note that this will not cancel the request in the backend, so any applicable billing charges will still be applied despite cancellation. |
An AbortSignal instance that allows cancelling ongoing requests (like generateContent or generateImages<!-- -->).
If provided, calling abort() on the corresponding AbortController will attempt to cancel the underlying HTTP request. An AbortError will be thrown if cancellation is successful.
Note that this will not cancel the request in the backend, so any applicable billing charges will still be applied despite cancellation.
<b>Signature:</b>
signal?: AbortSignal;
const controller = new AbortController();
const model = getGenerativeModel({
// ...
});
model.generateContent(
"Write a story about a magic backpack.",
{ signal: controller.signal }
);
// To cancel request:
controller.abort();