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

# Function: parseResourceKey()

```ts
function parseResourceKey(
  key: string,
  env?: {
    remoteHost?: string;
    remotePathTemplate?: string;
  },
):
  | {
      filename: string;
      repo: string;
    }
  | undefined;
```

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

Reverse `buildResourcePaths`' remote-URL key back into `{repo, filename}`.

Handles the canonical `{host}{model}/resolve/{revision}/{filename}` template. Returns `undefined`
for any key that is not a remote-host URL (e.g. the local-path probe `tryCache` issues first), so the
caller falls through to the default loader instead of mis-routing.

## Parameters

| Parameter                 | Type                                                            | Description                                                                         |
| ------------------------- | --------------------------------------------------------------- | ----------------------------------------------------------------------------------- |
| `key`                     | `string`                                                        | The string transformers.js passes to `cache.match` (the remote URL).                |
| `env`                     | { `remoteHost?`: `string`; `remotePathTemplate?`: `string`; } | The (possibly customized) host/template; defaults match the library's own defaults. |
| `env.remoteHost?`         | `string`                                                        | -                                                                                   |
| `env.remotePathTemplate?` | `string`                                                        | -                                                                                   |

## Returns

| {
`filename`: `string`;
`repo`: `string`;
}
| `undefined`
