# Class AvailableModelsCache

- Defined in packages/nexus-agents/src/config/available-models-cache.ts:79

##### Index

### Constructors

constructor

### Methods

addSource
removeSource
getAll
byProvider
has
refresh

## Constructors

### constructor

- new AvailableModelsCache(
  options: AvailableModelsCacheOptions,
  ): AvailableModelsCache

  #### Parameters

  - options: AvailableModelsCacheOptions

  #### Returns AvailableModelsCache

  - Defined in packages/nexus-agents/src/config/available-models-cache.ts:86

## Methods

### addSource

- addSource(source: AvailableModelsSource): void

  Register a source after construction. Used by adapter factories that wire themselves into the default cache lazily as they're built. Duplicate names are ignored (first registration wins, on the assumption that the same factory might run twice in a test session).

  #### Parameters

  - source: AvailableModelsSource

  #### Returns void

  - Defined in packages/nexus-agents/src/config/available-models-cache.ts:103

### removeSource

- removeSource(name: string): void

  Remove a previously-registered source. Used by tests + by factories that want to drop a probe when an adapter is being disposed.

  #### Parameters

  - name: string

  #### Returns void

  - Defined in packages/nexus-agents/src/config/available-models-cache.ts:113

### getAll

- getAll(): Promise<readonly AvailableModel[]>

  Returns the union of every source's available models. Stale-while- revalidate: serve fresh-or-stale immediately, refresh stale entries in the background. First call (no cache yet) blocks on every source.

  #### Returns Promise<readonly AvailableModel[]>

  - Defined in packages/nexus-agents/src/config/available-models-cache.ts:123

### byProvider

- byProvider(sourceName: string): Promise<readonly AvailableModel[]>

  Models reported by one named source (subset of getAll).

  #### Parameters

  - sourceName: string

  #### Returns Promise<readonly AvailableModel[]>

  - Defined in packages/nexus-agents/src/config/available-models-cache.ts:134

### has

- has(modelId: string): Promise<boolean>

  True iff some source currently reports the given model id.

  #### Parameters

  - modelId: string

  #### Returns Promise<boolean>

  - Defined in packages/nexus-agents/src/config/available-models-cache.ts:140

### refresh

- refresh(): Promise<readonly AvailableModel[]>

  Force a synchronous refresh of every source — used after a 404.

  #### Returns Promise<readonly AvailableModel[]>

  - Defined in packages/nexus-agents/src/config/available-models-cache.ts:146