spice-workers
Spice Workers
Workers coordinate model interactions, enabling load balancing and fallback strategies across multiple models.
Basic Configuration
workers:
- name: <worker_name>
type: load_balance
description: |
Worker description
load_balance:
routing:
- from: <model_name>
Load Balancing Strategies
Round Robin
Distribute requests evenly across models:
workers:
- name: round_robin
type: load_balance
load_balance:
routing:
- from: model_a
- from: model_b
- from: model_c
Fallback (Priority Order)
Try models in order, falling back on failure:
workers:
- name: fallback
type: load_balance
load_balance:
routing:
- from: primary_model
order: 1
- from: backup_model
order: 2
- from: emergency_model
order: 3
Weighted Distribution
Route by percentage weight:
workers:
- name: weighted
type: load_balance
load_balance:
routing:
- from: fast_model
weight: 8 # 80% of traffic
- from: slow_model
weight: 2 # 20% of traffic
Using Workers
Workers are invoked using the same API as models:
curl http://localhost:8090/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "fallback",
"messages": [{"role": "user", "content": "Hello"}]
}'
Full Example
models:
- from: openai:gpt-4o
name: gpt4
params:
openai_api_key: ${ secrets:OPENAI_API_KEY }
- from: anthropic:claude-sonnet-4-5
name: claude
params:
anthropic_api_key: ${ secrets:ANTHROPIC_API_KEY }
workers:
- name: smart_router
type: load_balance
description: Try GPT-4 first, fall back to Claude
load_balance:
routing:
- from: gpt4
order: 1
- from: claude
order: 2
Documentation
More from spiceai/skills
spice-models
Configure AI/LLM model providers and connections in Spice — OpenAI, Anthropic, Azure, Google, xAI, Bedrock, Perplexity, Databricks, HuggingFace, and local GGUF models. Use this skill whenever the user wants to add a model, configure a specific LLM provider, set up an OpenAI-compatible endpoint (e.g. Groq, Ollama), serve a local model, configure system prompts, set parameter overrides (temperature, response format), or understand which providers are available. This skill is the model connector reference. For AI features like tools, memory, workers, and NSQL, see spice-ai.
16spice-accelerators
Choose and configure the right acceleration engine — Arrow, DuckDB, SQLite, Cayenne, PostgreSQL, or Turso. Use this skill whenever the user needs to pick an accelerator engine, compare engines (e.g. "should I use DuckDB or Cayenne?"), configure engine-specific parameters (duckdb_file, sqlite_file), tune memory vs file mode, or understand engine capabilities and limitations. This skill is the engine selection and tuning guide. For the broader acceleration feature (refresh modes, retention, snapshots, indexes), see spice-acceleration.
15spice-ai
Add AI and LLM capabilities to Spice — tools, NSQL (text-to-SQL), memory, model routing/workers, and evals. Use this skill whenever the user wants to enable LLM tools (SQL, search, memory, MCP, web search), set up text-to-SQL via /v1/nsql, add persistent conversational memory, configure model routing with workers (load balancing, fallback, weighted distribution), set up evals, or use the OpenAI-compatible chat API. This skill covers AI features and orchestration. For configuring individual model providers (OpenAI, Anthropic, etc.), see spice-models.
7spice-search
Search data using vector similarity, full-text keywords, or hybrid methods with Reciprocal Rank Fusion (RRF). Use this skill whenever the user wants to set up semantic search, full-text search, or hybrid search in Spice — including configuring embedding models and providers, enabling full_text_search on columns, writing vector_search/text_search/rrf SQL queries, using the /v1/search HTTP API, configuring vector engines (S3 Vectors), tuning RRF parameters (rank_weight, recency_decay), or setting up chunking for long documents. Also use when the user asks about search relevance, BM25 scoring, or embedding configuration.
7spice-embeddings
Configure embedding models for vector search in Spice (OpenAI, HuggingFace, local). Use when asked to "add embeddings", "configure vector search", "set up semantic search", or "create embedding columns".
4spice-text-to-sql
Generate accurate SQL for Spice.ai's Apache DataFusion engine (PostgreSQL dialect), and build text-to-SQL workflows. Use this skill whenever the user wants to write SQL queries against Spice datasets, convert natural language to SQL, debug SQL errors, understand Spice/DataFusion data types and type casting, use Spice-specific functions (ai, embed, vector_search, text_search, rrf, JSON operators), build a text-to-SQL pipeline with schema introspection, or construct prompts for LLM-based SQL generation. Also use when the user hits SQL errors like "table not found", "cannot cast", or asks about DataFusion SQL dialect differences from PostgreSQL/MySQL.
1