Function resolveModelOption

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

    Resolution priority:

    1. Explicit model string — if it contains ":" it is split directly (backwards-compatible provider:model format). If it is a plain name and provider is set, the pair is used as-is. If neither, 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.