# Environment variables

## env

Module used to configure Transformers.js.

**Example:** Disable remote models.

Copied

```
import { env } from '@xenova/transformers';
env.allowRemoteModels = false;
```

**Example:** Set local model path.

Copied

```
import { env } from '@xenova/transformers';
env.localModelPath = '/path/to/local/models/';
```

**Example:** Set cache directory.

Copied

```
import { env } from '@xenova/transformers';
env.cacheDir = '/path/to/cache/directory/';
```

***

### env.env

Global variable used to control execution. This provides users a simple way to configure Transformers.js.

**Kind**: static constant of [`env`](https://huggingface.co/docs/transformers.js/api/env#module_env)\
**Properties**

| Name               | Type      | Description                                                                                                                                                                                                                         |
| ------------------ | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| backends           | `Object`  | Expose environment variables of different backends, allowing users to set these variables if they want to.                                                                                                                          |
| \_\_dirname        | `string`  | Directory name of module. Useful for resolving local paths.                                                                                                                                                                         |
| version            | `string`  | This version of Transformers.js.                                                                                                                                                                                                    |
| allowRemoteModels  | `boolean` | Whether to allow loading of remote files, defaults to `true`. If set to `false`, it will have the same effect as setting `local_files_only=true` when loading pipelines, models, tokenizers, processors, etc.                       |
| remoteHost         | `string`  | Host URL to load models from. Defaults to the Hugging Face Hub.                                                                                                                                                                     |
| remotePathTemplate | `string`  | Path template to fill in and append to `remoteHost` when loading models.                                                                                                                                                            |
| allowLocalModels   | `boolean` | Whether to allow loading of local files, defaults to `true`. If set to `false`, it will skip the local file check and try to load the model from the remote host.                                                                   |
| localModelPath     | `string`  | Path to load local models from. Defaults to `/models/`.                                                                                                                                                                             |
| useFS              | `boolean` | Whether to use the file system to load files. By default, it is `true` if available.                                                                                                                                                |
| useBrowserCache    | `boolean` | Whether to use Cache API to cache models. By default, it is `true` if available.                                                                                                                                                    |
| useFSCache         | `boolean` | Whether to use the file system to cache files. By default, it is `true` if available.                                                                                                                                               |
| cacheDir           | `string`  | The directory to use for caching files with the file system. By default, it is `./.cache`.                                                                                                                                          |
| useCustomCache     | `boolean` | Whether to use a custom cache system (defined by `customCache`), defaults to `false`.                                                                                                                                               |
| customCache        | `Object`  | The custom cache to use. Defaults to `null`. Note: this must be an object which implements the `match` and `put` functions of the Web Cache API. For more information, see <https://developer.mozilla.org/en-US/docs/Web/API/Cache> |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://boinc-ai.gitbook.io/transformers.js/api-reference/environment-variables.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
