Call models from SQL and apps in three steps
# spicepod.yamlmodels: - from: openai:gpt-6-luna name: gpt-6-luna params: openai_api_key: ${secrets:OPENAI_API_KEY}datasets: - from: postgres:public.tickets name: tickets params: pg_host: ${secrets:PG_HOST} pg_db: support pg_user: ${secrets:PG_USER} pg_pass: ${secrets:PG_PASS}sql> SELECT id, ai_classify(body, ['billing', 'technical', 'other']) AS team, ai('Summarize in 8 words: ' || body) AS summary FROM tickets LIMIT 3;# example output101 billing Customer wants a refund for a double charge102 technical Login page shows an error after the update103 other Customer asks how to add a teammate# spicepod.yamlmodels: - from: openai:gpt-6-luna name: gpt-6-luna params: openai_api_key: ${secrets:OPENAI_API_KEY} - from: anthropic:claude-sonnet-5-5 name: claude-sonnet params: anthropic_api_key: ${secrets:ANTHROPIC_API_KEY}workers: - name: router # one name for both models load_balance: routing: - from: gpt-6-luna order: 1 - from: claude-sonnet order: 2 # used when OpenAI failsruntime: auth: api-key: enabled: true # clients send a Spice API key keys: - ${secrets:SPICE_API_KEY}$ curl localhost:8090/v1/chat/completions \ -H "Authorization: Bearer $SPICE_API_KEY" \ -H "Content-Type: application/json" \ -d '{"model": "router", "messages": [{"role": "user", "content": "Draft a reply to a refund request"}]}'# example output: OpenAI returned 429, so Anthropic answered"content": "Thanks for reaching out. We refunded the duplicate charge."Add models
In
spicepod.yaml, add a model for each provider, such asopenai:gpt-6-lunaandanthropic:claude-sonnet-5-5. Spice reads each API key from a secret.Connect data and route
Add datasets for the tables that models work on. Add a worker that puts the models behind one name, in fallback order.
Call from SQL or an SDK
Start Spice with
spice run. Callai()andai_classifyin SQL, or send the worker name asmodelfrom an OpenAI or Anthropic SDK.























