Skip to content

Providers

Fabric provides a provider-agnostic execution layer for local and remote AI capabilities.

ProviderTierModalitiesStreamingConfig
OpenAIPremiumText, Image (DALL-E), EmbeddingYes (SSE)OPENAI_API_KEY
AnthropicPremiumTextNoANTHROPIC_API_KEY
OllamaBasicText, EmbeddingYes (NDJSON)OLLAMA_ENABLED
WhisperBasicAudioNoWHISPER_URL
ComfyUIBasicImage (Stable Diffusion)No (async poll)COMFYUI_ENABLED
ONNXBasicConfigurableNoONNX_MODEL_DIR
CandleBasicText, EmbeddingNoCANDLE_ENABLED
EchoBasicAll (test stub)NoAlways available

Requests specify a tier preference:

  • basic — Local/free providers (Ollama, Whisper, Echo)
  • premium — Remote/paid providers (OpenAI, Anthropic)

The router selects by:

  1. Tier — Match the requested tier
  2. Cost — Cheapest provider first within the tier
  3. Health — Skip unhealthy providers
  4. Capability — Provider must support the requested modality

If no tier is specified, the router selects by cost (cheapest first).

Providers declare capabilities with estimated_cost_per_request for cost-aware fallback.

When multiple providers support the same modality, Fabric routes based on registration order:

  1. OpenAI (if OPENAI_API_KEY set)
  2. Anthropic (if ANTHROPIC_API_KEY set)
  3. Ollama (if OLLAMA_ENABLED or OLLAMA_URL set)
  4. Whisper (if WHISPER_URL set)
  5. Echo providers (always available, fallback for testing)

To force a specific provider, include "model": "qwen3:latest" — the router matches the provider that advertises that model.

Terminal window
curl http://localhost:3001/v1/providers

Returns all registered providers with their capabilities, modalities, and health status.

Terminal window
curl -X POST http://localhost:3001/v1/providers/execute \
-H 'content-type: application/json' \
-d '{
"modality": "text",
"model": "qwen3:latest",
"input": {"prompt": "Hello world"},
"params": {"temperature": 0.7}
}'
Terminal window
curl -N -X POST http://localhost:3001/v1/providers/execute/stream \
-H 'content-type: application/json' \
-d '{
"modality": "text",
"input": {"prompt": "Write a poem"},
"params": {"stream": true}
}'
Terminal window
curl -X POST http://localhost:3001/v1/providers/estimate \
-H 'content-type: application/json' \
-d '{
"modality": "text",
"model": "gpt-4",
"input": {"prompt": "Hello"}
}'

Local models return $0.00.

Terminal window
OPENAI_API_KEY=sk-...
OPENAI_BASE_URL=https://api.openai.com/v1 # optional, for compatible servers
Terminal window
ANTHROPIC_API_KEY=sk-ant-...
Terminal window
OLLAMA_ENABLED=true
OLLAMA_URL=http://localhost:11434 # default
Terminal window
WHISPER_URL=http://localhost:8080
Terminal window
COMFYUI_ENABLED=true
COMFYUI_URL=http://localhost:8188 # default

Requires the onnx-runtime feature flag.

Terminal window
ONNX_MODEL_DIR=/path/to/models

Requires the candle feature flag.

Terminal window
CANDLE_ENABLED=true
FeatureDescription
onnx-runtimeActual ONNX inference via ort
candleHuggingFace model loading via Candle
wasm-runtimeWasmtime plugin execution

Enable with: cargo build --features onnx-runtime,candle,wasm-runtime