SDKs

Client libraries for querying Spice.ai Cloud and a local Spice runtime

Client SDKs connect to a Spice project over Apache Arrow Flight and return results as Apache Arrow record batches, which convert cheaply into the dataframe type of each language. They are the recommended way to query Spice from application code.

Every SDK connects to either Spice.ai Cloud or a local Spice runtime. Authentication against Cloud uses a project API key.

LanguagePackageLatestDocumentation
Pythonspicepyv4.0.0Python SDK
TypeScript, Node.js@spiceai/spice3.2.0Node.js SDK
Gogithub.com/spiceai/gospice/v9v9.0.0Go SDK
Rustspiceai4.0.0Rust SDK
Javaai.spice:spiceai0.8.0Java SDK
C#, .NETSpiceAI0.4.0.NET SDK

Synchronous and asynchronous queries

Every SDK separates the two query paths by method name:

  • sql() runs a query synchronously and streams Arrow record batches back on the open connection. This is the default path for querying.
  • query() submits the query for asynchronous execution and returns a job handle used to poll status and fetch results once the query completes. Asynchronous queries require the runtime to be running in distributed (scheduler) mode.
LanguageSynchronousAsynchronous
Pythonsql, sql_with_paramsquery, query_with_params
TypeScript, Node.jssqlquery, queryWithParams
GoSql, SqlWithParamsQuery, QueryWithParams
Rustsql, sql_with_paramsquery, query_with_bindings
Javasql, sqlWithParamsquery, queryWithParams
C#, .NETSqlAsync, SqlWithParamsAsyncQueryAsync, QueryWithParamsAsync

Default endpoints

Each SDK ships defaults for both Cloud and a local runtime. The exact values and how to override them are on each SDK's page, but the hosts are common:

TargetArrow FlightHTTP
Spice.ai Cloudflight.spiceai.io port 443https://data.spiceai.io
Local runtimelocalhost port 50051http://localhost:8090

Choosing between an SDK and the APIs directly

An SDK is preferable for application code: it handles the Flight handshake, authentication headers, and retries. Query directly against the HTTP API or Arrow Flight API when a language has no SDK, or for one-off requests from a shell.