# zidane-ui/models

Import: `import { … } from 'zidane-ui/models'`. Source: [ui/src/models/index.ts](https://github.com/Tahul/zidane/blob/main/ui/src/models/index.ts).

## Components

### `ModelsProvider`

Component.

`zidane-ui/models`: the model catalog in components. `ModelsProvider` (which
`ComposerHostProvider` mounts) puts a host's catalogs in context;
`useModelCatalog`, `useComposerModelName` and `useComposerProviderLabel`
read them; `providerColor` gives each provider its color. The React-free
catalog is `zidane-ui/models/headless`.

```ts
function ModelsProvider(props: ModelsProviderProps): Element
```

**Parameters**

- `props` (`ModelsProviderProps`): The `models` and the `children`.

**Returns** `Element`

**Props**

- `children` (`ReactNode`): The app's components.
- `models?` (`ComposerModels`): The host's model catalogs. Absent: no catalog, and models keep their readable ids.

Source: [ui/src/models/ModelsProvider.tsx:26](https://github.com/Tahul/zidane/blob/main/ui/src/models/ModelsProvider.tsx#L26)

## Functions

### `providerColor`

Function.

Text / border color.

```ts
function providerColor(providerKey: string): string
```

**Parameters**

- `providerKey` (`string`): The provider key, matched case-insensitively.

**Returns** `string`

Source: [ui/src/models/provider-color.ts:53](https://github.com/Tahul/zidane/blob/main/ui/src/models/provider-color.ts#L53)

### `providerTint`

Function.

Soft tinted fill for chips / badges.

```ts
function providerTint(providerKey: string, percent?: number): string
```

**Parameters**

- `providerKey` (`string`): The provider key, matched case-insensitively.
- `percent?` (`number`, default `16`): How much of the provider color to mix in, 0 to 100.

**Returns** `string`

Source: [ui/src/models/provider-color.ts:66](https://github.com/Tahul/zidane/blob/main/ui/src/models/provider-color.ts#L66)

### `useComposerModelName`

Function.

Names a model as the model picker does; re-renders when the catalog arrives or changes.

```ts
function useComposerModelName(): ModelNamer
```

**Returns** `ModelNamer`

Source: [ui/src/models/use-model-catalog.ts:58](https://github.com/Tahul/zidane/blob/main/ui/src/models/use-model-catalog.ts#L58)

### `useComposerProviderLabel`

Function.

A provider's label as the model picker groups it (`Anthropic`).

```ts
function useComposerProviderLabel(): (providerKey: string) => string
```

**Returns** `(providerKey: string) => string`

Source: [ui/src/models/use-model-catalog.ts:63](https://github.com/Tahul/zidane/blob/main/ui/src/models/use-model-catalog.ts#L63)

### `useModelCatalog`

Function.

The catalog to list: `outer` when the caller loaded one, else the host's for `cwd` on `hostId`.

```ts
function useModelCatalog(
  outer: readonly ComposerModelEntry[] | null,
  cwd?: string,
  hostId?: string | null,
): ModelCatalogState
```

**Parameters**

- `outer` (`readonly ComposerModelEntry[] | null`): A catalog the caller already holds.
- `cwd?` (`string`): The folder.
- `hostId?` (`string | null`, default `null`): The server, `null` for this computer.

**Returns** `ModelCatalogState`

Source: [ui/src/models/use-model-catalog.ts:36](https://github.com/Tahul/zidane/blob/main/ui/src/models/use-model-catalog.ts#L36)

### `useModels`

Function.

`zidane-ui/models`: the model catalog in components. `ModelsProvider` (which
`ComposerHostProvider` mounts) puts a host's catalogs in context;
`useModelCatalog`, `useComposerModelName` and `useComposerProviderLabel`
read them; `providerColor` gives each provider its color. The React-free
catalog is `zidane-ui/models/headless`.

```ts
function useModels(): ComposerModels | undefined
```

**Returns** `ComposerModels | undefined`

Source: [ui/src/models/ModelsProvider.tsx:31](https://github.com/Tahul/zidane/blob/main/ui/src/models/ModelsProvider.tsx#L31)

## Interfaces

### `ModelCatalogState`

Interface.

A model catalog as a picker reads it.

```ts
interface ModelCatalogState
```

**Properties**

- `catalog` (`readonly ComposerModelEntry[] | null`): The rows, `null` while loading.
- `error` (`string | null`): Why it failed to load.
- `retry` (`(() => void) | undefined`): Reads it again.

Source: [ui/src/models/use-model-catalog.ts:20](https://github.com/Tahul/zidane/blob/main/ui/src/models/use-model-catalog.ts#L20)

### `ModelsProviderProps`

Interface.

Props for [`ModelsProvider`](https://zidane.si/docs/reference/ui-models.md#ModelsProvider).

```ts
interface ModelsProviderProps
```

**Properties**

- `children` (`ReactNode`): The app's components.
- `models?` (`ComposerModels`): The host's model catalogs. Absent: no catalog, and models keep their readable ids.

Source: [ui/src/models/ModelsProvider.tsx:14](https://github.com/Tahul/zidane/blob/main/ui/src/models/ModelsProvider.tsx#L14)
