Function resolveModelOption

  • Resolves a { providerId, modelId } pair from flexible caller-supplied options.

    Resolution priority:

    1. Explicit model string — a provider:model id is split when its prefix is a known provider id (a key of PROVIDER_DEFAULTS), whatever provider says, except under provider: 'ollama', where an id is never split. Any other id is kept whole: with provider set, the pair is used as-is; without it, auto-detection from env vars is attempted.
    2. provider only — default model for the requested task is looked up in PROVIDER_DEFAULTS.
    3. Neither — auto-detect the first provider with a set API key/URL env var and use its default model for the requested task.

    Parameters

    • opts: ModelOption

      Caller options containing optional provider and/or model.

    • task: TaskType = 'text'

      Task type used to select the correct default model. Defaults to "text".

    Returns ParsedModel

    A ParsedModel with providerId and modelId.

    Throws

    When no provider can be determined, the provider is unknown, or the provider has no default model for the requested task.