AI Provider Factory Registry (families/compatible.ts)

promptfoo · src/providers/families/compatible.ts · typescript · MIT
integration, ai, tag:registry, tag:factory, tag:plugin

Dynamically loads and registers various AI model providers. Use this to implement a pluggable architecture for supporting multiple LLM services.

// Source: https://github.com/promptfoo/promptfoo | License: MIT | Copyright Promptfoo 2025
// Provided via justclaw.it.com; keep this notice with the code.
import type { LoadApiProviderContext } from '../../types/index';
import type { ApiProvider, ProviderOptions } from '../../types/providers';
import type { ProviderCreatorOptions } from '../creator';
import type { ProviderFactory } from '../registryTypes';

type Creator = (path: string, options: ProviderCreatorOptions) => ApiProvider;

// A family lookup loads this small table; only the selected creator loads its implementation.
const creators: readonly (readonly [string, () => Promise<Creator>])[] = [
  ['cerebras', async () => (await import('../cerebras')).createCerebrasProvider],
  ['envoy', async () => (await import('../envoy')).crea

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key