Skip to main content
Batoi AIF Docs

Provider Abstraction

Route AI calls through provider contracts instead of binding apps to one vendor.

Version Foundation release Early foundation work Reviewed Jul 21, 2026 Next review Sep 21, 2026

Owner: Batoi Engineering Reviewed by: Batoi AIF Maintainers Source revision: cd680e8

AIF is the public engineering framework. For the managed intelligence capability used across supported Platform and Flex workflows, see Batoi Intelligence.
Browse Batoi AIF Documentation Provider Abstraction

Provider Abstraction

Provider abstraction keeps application code independent from a single AI vendor SDK. AIF defines normalized provider interfaces for text inference, streaming contracts, embeddings, and moderation.

Why It Matters

  • change providers without rewriting product code
  • apply policy before vendor calls
  • discover normalized operations and model metadata
  • route by operation, capability, and health
  • support mock providers for development and tests
  • keep provider credentials behind backend controls

Provider Registry

The provider registry is responsible for resolving a named provider implementation.

$registry = new InMemoryProviderRegistry([
    'mock' => new MockProvider(),
]);

Production registries can load provider configuration from application configuration, RAD tables, environment variables, or a secrets manager.

Provider Capabilities

Provider metadata should describe what the provider can do:

  • text inference
  • real streaming support
  • embeddings
  • moderation
  • model-specific limits

ProviderRouter selects a capable, healthy provider deterministically and records routing evidence. An explicit provider request does not silently fall back to a different provider. The bundled OpenAICompatibleProvider supports OpenAI-style text, embedding, and moderation endpoints; it does not claim streaming support when the transport only buffers a complete response.

Policy should evaluate the resolved provider and model before execution. UI should use published capabilities to hide unsupported choices.