AI Model Serving

Serve hosted and local AI models next to your data

Spice serves hosted and local AI models from the same runtime that queries your data. Call chat and decision models through OpenAI-compatible APIs or from SQL, with no separate inference server.

Diagram of Spice.ai connecting apps to S3, Databricks, and MySQL data stores, AI model providers, and data catalogs

Do more with your data

Increase the reliability, performance, and security of data-driven AI workflows.

100x

up to 100x faster queries

80%

up to 80% cost savings on data lakehouse spend

2x

increase in data reliability for critical workloads

AI grounded in your data

AI grounded in your data

Spice runs local models in the same process as the accelerated data they read, and it calls hosted models from that same runtime. Tools such as sql and search let each chat model answer from federated and accelerated datasets, which reduces hallucinations.

View the docs

Diagram of Spice.ai serving agents, models, tools, evals, and embeddings between apps and OpenAI, Anthropic, xAI, and NVIDIA NIM
Flexible models and deployments

Flexible models and deployments

Serve commercial models from OpenAI, Anthropic, xAI, Google, and Amazon Bedrock, or open-weight models from Hugging Face, in one Spicepod. The same runtime deploys on a laptop, in Kubernetes, at the edge, or in Spice Cloud.

View the docs

Grid of supported AI model providers including OpenAI, xAI, Anthropic, and NVIDIA NIM
Built-in tooling and memory

Built-in tooling and memory

Give models built-in tools for SQL queries, search, and table schemas. The memory tools store facts in a read-write memory dataset, so a model can recall them in later conversations.

View the docs

Diagram of Spice.ai OSS serving search and SQL over accelerated data and local embeddings backed by Amazon S3 buckets
AI sandboxing

AI sandboxing

Limit what each model can reach. A model calls only the tools in its tools parameter. The built-in data tools query only the datasets in its datasets list, and MCP tools call their configured MCP servers. Task history, on by default, records each call.

View the docs

Diagram of Spice.ai sandboxing AI execution with monitoring, policy, and a firewall between models and Amazon S3, Snowflake, and PostgreSQL

Integrations across all your data sources

Spice connects to OpenAI, Anthropic, xAI, Azure OpenAI, Google Vertex AI, Amazon Bedrock, Databricks, TypeSafe, and OpenAI-compatible endpoints such as NVIDIA NIM. It also runs Hugging Face and local models. Every model shares one runtime for API access, rate limits, and observability, and chat models also share its tools.

Spice logo surrounded by integration logos, including AWS, OpenAI, Snowflake, and Slack

Deployed in production

Teams use Spice to run AI inference next to their data in production.

Tim Ottersburg

“Partnering with Spice AI has transformed how NRC Health delivers AI-driven insights. By unifying siloed data across systems, we accelerated AI feature development, reducing time-to-market from months to weeks - and sometimes days. With predictable costs and faster innovation, Spice isn't just solving some of our data and AI challenges - it's helping us redefine personalized healthcare.”

Tim Ottersburg

VP of Technology, NRC Health

Rachel Wong

“Spice AI grounds AI in our actual data, using SQL queries across many data sources. This brings accuracy to probabilistic AI systems, which are very prone to hallucinations.”

Rachel Wong

CTO, Basis Set

FAQs

Answers to common questions about serving AI models in Spice

Yes. Model serving is part of the Spice runtime, which is open source under the Apache 2.0 license. The same Spicepod runs on a laptop, in a container, or on Kubernetes. Spice Cloud and Enterprise add managed hosting, prebuilt GPU images, and support.

Spice gives models tools that read your data, such as sql and search. The model can then answer from current records instead of from its training data alone. Grounding reduces hallucinations but does not remove them. Retrieval-augmented generation applies the same pattern to documents.

No. Spice v2.0 removed the evals feature and the /v1/evals endpoint. To score model output, run an external evaluation framework against the Spice chat endpoint. Task history keeps the input of each call, and setting captured_output: truncated under runtime.task_history keeps the output too.

Spice runs as one binary or container, so models deploy wherever the runtime runs. Options are a laptop, a Kubernetes cluster, an edge device, or Spice Cloud. See edge-to-cloud deployments for the architecture of each option.

Spice serves AI models from the same runtime that federates and accelerates SQL queries. Local models run inside that runtime, in the same process as the accelerated data they read. Hosted models stay with their provider, and Spice sends each call to the provider's API. Applications reach both kinds through OpenAI-compatible HTTP APIs and SQL functions. A model call moves through four steps:

  1. Declare: the models section of spicepod.yaml names each model. The from prefix selects the provider, such as openai:gpt-4o-mini or huggingface:huggingface.co/<org>/<repo>.
  2. Load: at startup, Spice resolves each ${secrets:...} reference in the model parameters from a secret store. Spice downloads Hugging Face weights, or reads a file: model from disk. The mistral.rs inference engine then loads the local weights.
  3. Ground: the tools in a model's tools parameter, such as sql, search, and table_schema, let the model query federated and accelerated datasets. A model with no tools parameter gets no tools.
  4. Serve: applications call a chat model at /v1/chat/completions, or from a SQL query with ai(). Decision models answer /v1/decisions and the SQL decision functions. Task history, which is on by default, records each call in the spice.runtime.task_history table.

The following Spicepod defines one hosted model and one local model:

version: v1
kind: Spicepod
name: model-serving

models:
  - name: hosted
    from: openai:gpt-4o-mini
    params:
      openai_api_key: ${secrets:OPENAI_API_KEY}
      system_prompt: Answer questions about the sales datasets.
      tools: auto

  - name: local
    from: huggingface:huggingface.co/lmstudio-community/Qwen2.5-Coder-3B-Instruct-GGUF
    files:
      - path: Qwen2.5-Coder-3B-Instruct-Q3_K_L.gguf

Any OpenAI-compatible client can then call either model by its Spice name:

curl http://localhost:8090/v1/chat/completions \
  -H 'Content-Type: application/json' \
  -d '{"model": "local", "messages": [{"role": "user", "content": "What is a Spicepod?"}], "stream": true}'

To use the OpenAI SDK, set its base URL to http://localhost:8090/v1 and pass the Spice model name as model. The same client code then calls hosted and local models. The models documentation has the full configuration reference for each provider.

Spice calls hosted models through each provider's API and runs local models in the runtime. The from prefix sets the provider:

Providerfrom prefixWhere the model runsCredentials
OpenAI and compatible endpoints, such as NVIDIA NIMopenai:Hostedopenai_api_key, plus endpoint for a compatible API
Anthropicanthropic:Hostedanthropic_api_key
xAIxai:Hostedxai_api_key
Azure OpenAIazure:Hostedazure_api_key or azure_entra_token
Google Vertex AIgoogle:Hostedgoogle_project and google_location, plus google_service_account_path, google_service_account_key, or google_application_default_credentials
Amazon Bedrockbedrock:Hostedaws_region, plus aws_access_key_id and aws_secret_access_key or an IAM role through aws_iam_role_source
Databricksdatabricks:Hosteddatabricks_token, or databricks_client_id and databricks_client_secret
Spice Cloudspiceai:Hostedspiceai_api_key
TypeSafetypesafe:Hosted, for decisions onlytypesafe_api_key
Hugging Facehuggingface:Local, after downloadhf_token for gated models
Local filefile:LocalNone

TypeSafe models, such as typesafe:jev, answer only the SQL decision functions and /v1/decisions. They do not serve chat. Local models load from GGUF, GGML, or SafeTensors files. Spice rejects pickle-format weights (.pt, .pth, .bin, .ckpt) unless the model sets trust_pickle: true, because loading a pickle file can run code.

Release builds of the open-source runtime run local models on the CPU, so a GPU is optional. Small quantized GGUF models give the best CPU latency. For CUDA or Metal, build from source with make install-cuda or make install-metal. Spice Cloud and Enterprise ship prebuilt CUDA images. The distributions reference lists each build.

Spice exposes each model through several interfaces. One model can serve a chat application and a batch SQL job at the same time:

InterfaceEndpoint or functionUse it for
Chat CompletionsPOST /v1/chat/completionsOpenAI SDK clients, streamed chat, and tool calls
ResponsesPOST /v1/responsesOpenAI Responses API clients, for models whose provider offers that API
SQL textai(message) or ai(message, model_name)Summarizing, translating, or generating text for each row in a query
SQL decisionsai_if, ai_probability, ai_classify, ai_score, and ai_decideA typed answer for each row: true or false, a probability, a label, or a score
Decisions APIPOST /v1/decisionsSeveral typed questions about one input, in the request shape of OpenAI's Decisions API
Text-to-SQLPOST /v1/nsqlNatural-language questions that Spice answers with generated SQL
EmbeddingsPOST /v1/embeddingsVectors from the models in the embeddings section
Model listGET /v1/modelsDiscovering the models a runtime serves

The ai() function sends one model call per row and runs the calls in parallel. It splits large inputs into batches of up to 1,000 rows, and each message can be up to 1 MB. The decision functions and /v1/decisions run on any chat model, an OpenAI decision model such as gpt-6-luna, or a TypeSafe model. LLM inference from SQL shows these functions in larger workloads.

Spice applies the same runtime controls to every model, hosted or local. Configure them per model in the Spicepod:

  • Tool access: a model calls only the tools in its tools parameter. The MCP server gateway adds tools from external MCP servers to the same list.
  • Rate limits: max_concurrency and requests_per_minute_limit cap the calls Spice sends to a model. Defaults follow each provider's published limits, and the cap also applies to the parallel calls from ai().
  • Tool recursion: tool_recursion_limit, 10 by default, stops a chain of tool calls inside one request from looping.
  • Secrets: ${secrets:...} references resolve API keys at startup, so keys stay out of the Spicepod file.
  • Usage tracking: task history records chat and completion calls as ai_chat and ai_completion tasks with their token counts. It records /v1/decisions calls as ai_decision tasks and SQL decision batches as ai_decide tasks. Query them in spice.runtime.task_history. The llm_prompt_tokens_total and llm_completion_tokens_total metrics give the same totals for dashboards.

A W3C traceparent header on the request sets the trace_id that task history records, so each call matches the caller's trace. For isolation beyond these controls, see secure AI sandboxing. To run model serving as a managed service, compare Spice Cloud and Enterprise plans.

See Spice in action

Walk through your use case with an engineer and see how Spice handles federation, acceleration, and AI integration for production workloads.

Talk to an engineer (opens in a new tab)