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.