Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Principle:Promptfoo Promptfoo Provider Interface

From Leeroopedia
Revision as of 17:47, 16 February 2026 by Admin (talk | contribs) (Auto-imported from principles/Promptfoo_Promptfoo_Provider_Interface.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Knowledge Sources
Domains Provider_Management, API_Design
Last Updated 2026-02-14 08:00 GMT

Overview

A polymorphic interface contract that all LLM providers must implement for uniform evaluation across heterogeneous AI services.

Description

The Provider Interface defines the contract that any LLM integration must fulfill to participate in Promptfoo evaluations. At its core, every provider must implement `id()` (returning a unique identifier) and `callApi()` (sending a prompt and returning a response).

This abstraction layer is what enables Promptfoo to evaluate 70+ providers uniformly: whether the provider is OpenAI, a local Ollama instance, a custom Python script, or an HTTP endpoint, the evaluation engine interacts with them all through the same interface.

Optional methods extend the interface for embedding APIs, classification APIs, session management, and resource cleanup.

Usage

Use this principle when creating custom providers for Promptfoo. Any JavaScript/TypeScript module, Python script, or HTTP endpoint that conforms to this interface can be used as a provider.

Theoretical Basis

Interface Contract:

ApiProvider:
  REQUIRED:
    id() → string           // Unique provider identifier
    callApi(prompt, context, options) → ProviderResponse  // Main API call

  OPTIONAL:
    callEmbeddingApi(input) → ProviderEmbeddingResponse
    callClassificationApi(prompt) → ProviderClassificationResponse
    getSessionId() → string  // For multi-turn conversations
    cleanup() → void         // Resource cleanup on abort
    transform: string        // Output transformation expression
    delay: number            // Delay between calls (ms)

Related Pages

Implemented By

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment