> ## Documentation Index
> Fetch the complete documentation index at: https://onr.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Models Block

> Configuring dynamic model listings.

The `models` block (available inside `defaults` blocks only in v0.1) controls how ONR queries and parses the `GET /v1/models` endpoint of an upstream provider to populate its internal registry or Admin Page proxy.

Global reusable presets can now be declared in `config/modes/models_modes.conf` and included from `config/onr.conf`:

```nginx theme={null}
models_mode "openai" {
  path "/v2/models";
}
```

```nginx theme={null}
provider "demo" {
  defaults {
    models {
      models_mode openai;
    }
  }
}
```

## Built-In Handlers

You can rely on built-in parser presets for standard providers. In this repository's default config, the same names are declared in `config/modes/models_modes.conf` as global `models_mode` presets:

```nginx theme={null}
models {
  models_mode openai;    # Default query path: /v1/models
}
```

```nginx theme={null}
models {
  models_mode gemini;    # Default query path: /v1beta/models
}
```

```nginx theme={null}
models {
  models_mode vertex;    # Default query path: /v1beta1/publishers/google/models
}
```

The `vertex` preset lists Google publisher base models. It requires credential metadata from the selected upstream key. Configure `credential_file` and `location` in `keys.yaml`; use `base_url_override` for regional Vertex hosts.

## Custom Model Parsers

For providers exposing bizarre schemas or prefixed namespaces, build a custom parser to extract and clean the model lists explicitly.

```nginx theme={null}
models {
  models_mode custom;
  method GET;
  path "/v1beta/models";
  
  # Locate the array of models
  id_path "$.models[*].name";
  
  # Perform a regex rewrite on the returned model names
  # (e.g., stripping off 'models/' prefix from the string)
  id_regex "^models/(.+)$";
  
  # Only allow models out that begin with "gemini-"
  id_allow_regex "^gemini-";
}
```

### Directives specific to `models_mode custom`

* `id_path` (repeatable): Extracts variables into a deduplicated union list.
* `id_regex`: If it includes a Capture Group, group `1` becomes the final ID. Otherwise, the full Regex Match is used. Non-matching values are dropped.
