Function: resolveProvider()
resolveProvider(
providerId,modelId,overrides?):ResolvedProvider
Defined in: packages/agentos/src/api/model.ts:317
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; that
resolution carries the key and base URL a call that names OpenRouter
resolves: a global default's that names OpenRouter, else
OPENROUTER_API_KEY and OPENROUTER_BASE_URL.
Parameters
providerId
string
Provider identifier (e.g. "openai", "anthropic", "ollama").
modelId
string
Model identifier within the provider.
overrides?
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.
apiKey?
string
baseUrl?
string
quiet?
boolean
strict?
boolean
Returns
ResolvedProvider
A ResolvedProvider ready for createProviderManager().
Throws
When no credentials can be resolved for the given provider.