Back to Firebase Js Sdk

SingleRequestOptions interface

docs-devsite/ai.singlerequestoptions.md

12.12.12.4 KB
Original Source

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 %}

SingleRequestOptions interface

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>

typescript
export interface SingleRequestOptions extends RequestOptions 

<b>Extends:</b> RequestOptions

Properties

PropertyTypeDescription
signalAbortSignalAn <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.

SingleRequestOptions.signal

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>

typescript
signal?: AbortSignal;

Example

javascript
const controller = new AbortController();
const model = getGenerativeModel({
  // ...
});
model.generateContent(
  "Write a story about a magic backpack.",
  { signal: controller.signal }
);

// To cancel request:
controller.abort();