Function resolveProvider

  • Resolves a complete provider configuration for LLM text providers.

    Reads API keys and base URLs from well-known environment variables (e.g. OPENAI_API_KEY, OLLAMA_BASE_URL) and merges caller-supplied overrides. Applies the Anthropic → OpenRouter fallback when ANTHROPIC_API_KEY is absent but OPENROUTER_API_KEY is set.

    Parameters

    • providerId: string

      Provider identifier (e.g. "openai", "anthropic", "ollama").

    • modelId: string

      Model identifier within the provider.

    • Optional overrides: {
          apiKey?: string;
          baseUrl?: string;
          strict?: boolean;
          quiet?: boolean;
      }

      Optional explicit API key and/or base URL that take precedence over environment variable lookups. The base URL is the override's, else the global default's, else the provider's base-URL variable, each read as resolveBaseUrl reads it: an empty or whitespace-only one is unset and the next source applies, so no request is built on a blank base. strict (set for an agency seat) admits only a setDefaultProvider() default that names this provider, for the key and for the URL, and turns off the Anthropic → OpenRouter fallback, so a provider with no key of its own fails. quiet is for a lookup that sends no request, such as the read of the provider's shared credentials that providerHealthKey compares a call's own with: it resolves the same way and prints no notice that a request goes to OpenRouter.

      • Optional apiKey?: string
      • Optional baseUrl?: string
      • Optional strict?: boolean
      • Optional quiet?: boolean

    Returns ResolvedProvider

    A ResolvedProvider ready for createProviderManager().

    Throws

    When no credentials can be resolved for the given provider.