Intelligence · function
createAiProvider
Accept a provider only if it declares what was asked of it, and say so either way.
Explained in Agents and behaviour.
function createAiProvider(config: AiProviderConfig, required: Partial<AiProviderCapabilities>): Promise<AiProviderResult>import { createAiProvider } from '@driftengine/ai';Parameters
| Parameter | Type | Description |
|---|---|---|
config | AiProviderConfig | |
required | Partial<AiProviderCapabilities> |
In depth
Renderer creation already works this way: createRenderer reports which backend it
took and why, and probeDevice refuses in the device's own words. A provider is the
same shape of decision with a bigger bill attached — a request to a provider that
cannot do the thing costs latency and tokens before it fails, where a refusal here
costs a string comparison.
There is no fallback path. A downgrade from a local model to a paid remote one changes where a user's data goes, and a package that does it quietly makes every privacy notice written against it wrong. A caller wanting a second choice asks for it explicitly, having read the first refusal.