Principle:Promptfoo Promptfoo Provider Registry
| Knowledge Sources | |
|---|---|
| Domains | Provider_Management, Plugin_Architecture |
| Last Updated | 2026-02-14 08:00 GMT |
Overview
A registry pattern that maps provider path prefixes to factory functions for instantiating 70+ LLM provider implementations.
Description
The Provider Registry is the central mapping between provider identifier strings and their concrete implementations. It uses a factory pattern where each registered ProviderFactory has a `test()` predicate (to match provider paths by prefix or pattern) and a `create()` method (to instantiate the provider).
This architecture enables extensibility: adding a new provider requires only registering a new factory entry, without modifying the core loading logic. The registry supports providers like OpenAI, Anthropic, Google, AWS Bedrock, Azure, Ollama, and many more.
Usage
Use this principle when understanding how providers are resolved from config strings. The registry is consulted by loadApiProvider for every provider that isn't a cloud or file reference.
Theoretical Basis
Pseudo-code Logic:
providerMap = [
{ test: (path) => path.startsWith('openai:'), create: (path, opts) => new OpenAiProvider(...) },
{ test: (path) => path.startsWith('anthropic:'), create: (path, opts) => new AnthropicProvider(...) },
{ test: (path) => path.startsWith('python:'), create: (path, opts) => new PythonProvider(...) },
// ... 70+ entries
]
// Resolution: first matching factory wins
for factory of providerMap:
if factory.test(providerPath):
return factory.create(providerPath, options)