#ai #sdk #run-time #spice #arrow #platform #ai-driven

spiceai

SDK for Spice.ai, an open-source runtime and platform for building AI-driven software

2 stable releases

2.0.0 Apr 30, 2024
1.0.3 Mar 21, 2024

#2 in #spice

Download history 122/week @ 2024-03-18 16/week @ 2024-04-01 2/week @ 2024-04-22 208/week @ 2024-04-29

211 downloads per month

Apache-2.0

18KB
283 lines

Rust Spice SDK

Rust SDK for Spice.ai

Installation

Add Spice SDK

cargo add spiceai

Usage

Usage with locally running spice runtime

Follow the quiqstart guide to install and run spice locally

use spiceai::ClientBuilder;

#[tokio::main]
async fn main() {
  let mut client = ClientBuilder::new()
    .flight_url("http://localhost:50051")
    .build()
    .await
    .unwrap();

  let data = client.query("SELECT trip_distance, total_amount FROM taxi_trips ORDER BY trip_distance DESC LIMIT 10;").await;
}

New client with https://spice.ai cloud

use spiceai::ClientBuilder;

#[tokio::main]
async fn main() {
  let mut client = ClientBuilder::new()
    .api_key("API_KEY")
    .use_spiceai_cloud()
    .build()
    .await
    .unwrap();
}

Arrow Query

SQL Query

use spiceai::ClientBuilder;

#[tokio::main]
async fn main() {
  let mut client = ClientBuilder::new()
    .api_key("API_KEY")
    .use_spiceai_cloud()
    .build()
    .await
    .unwrap();

  let data = client.query("SELECT * FROM eth.recent_blocks LIMIT 10;").await;
}

Firecache Query

Firecache SQL Query

use spiceai::ClientBuilder;

#[tokio::main]
async fn main() {
  let mut client = ClientBuilder::new()
    .api_key("API_KEY")
    .use_spiceai_cloud()
    .build()
    .await
    .unwrap();

  let data = client.fire_query("SELECT * FROM eth.recent_blocks LIMIT 10;").await;
}

Documentation

Check out our Documentation to learn more about how to use the Rust SDK.

Dependencies

~30–47MB
~850K SLoC