---
url: >-
  https://adk.nht.io/api/@nhtio/adk/batteries/llm/transformers_js/model_source/functions/installModelSource.md
---

# Function: installModelSource()

```ts
function installModelSource(
  env: TransformersEnvLike,
  hook: TransformersJsModelSource,
): () => void;
```

Defined in: [src/batteries/llm/transformers\_js/model\_source.ts:131](https://github.com/NHTIO/ADK/blob/v1.20260713.1/src/src/batteries/llm/transformers_js/model_source.ts#L131)

Install a model-source hook on `env` and return a restore function. Sets `useCustomCache = true` +
`customCache`, capturing the previous values. The returned `restore()` puts them back. NOT mutex-
guarded on its own — use [withModelSource](withModelSource.md) for the scoped, serialized form.

## Parameters

| Parameter | Type                                                                                 | Description                                                                          |
| --------- | ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------ |
| `env`     | `TransformersEnvLike`                                                                | The transformers.js `env` object (from `await import('@huggingface/transformers')`). |
| `hook`    | [`TransformersJsModelSource`](../../types/type-aliases/TransformersJsModelSource.md) | The resolver to install.                                                             |

## Returns

A function that restores `env`'s prior cache configuration.

() => `void`
