Published Apr 2024

Cookbook recipes to get up and running with Spice.ai quickly ๐
spice add spiceai/cookbook-spiceai-recipespice connect spiceai/cookbook-spiceai-recipedependencies:
- spiceai/cookbook-spiceai-recipeTaxi trips in New York City
version: v2
kind: Spicepod
name: spiceai
datasets:
- from: spice.ai/spiceai/quickstart/datasets/taxi_trips
name: taxi_trips
description: Taxi trips in New York City
params:
spiceai_region: us-east-1
spiceai_api_key: ${secrets:SPICE_SPICEAI_API_KEY}
Works with v2.0+
The Spice.ai Cloud Platform has many datasets that can be used within Spice. A valid login for the Spice.ai Cloud Platform is required to access the datasets. Before beginning this recipe, link your GitHub account to Spice.ai (opens in a new tab) to get access to the platform.
Step 1. Initialize a Spice project:
spice init spiceai-demo
cd spiceai-demo
Step 2. Use spice login and choose "Login with a web browser" to store the Spice.ai Cloud Platform API Key and Token.
spice login
Spice.ai OSS CLI v2.3.0-enterprise
? How would you like to authenticate to Spice Cloud? โบ
โฏ Login with a web browser
Paste an access token
A browser window will open displaying a code that will appear in the terminal. Select Approve if the authorization codes match.

There will be a confirmation in the terminal that login was successful:
โ Successfully logged in to Spice Cloud as <your_username> (<your_email>)
Active org: <your_org>
You belong to 2 organizations โ run 'spice cloud orgs' to list them, or 'spice cloud org use <org>' to switch.
You can now use 'spice cloud' commands to manage your apps and deployments.
Quick start:
spice cloud orgs - List your organizations
spice cloud projects - List your projects
spice cloud project create <name> - Create a new project
spice cloud deploy --project <org/project> - Deploy it
A .env file is created in the spiceai-demo directory with the following content:
SPICE_SPICEAI_API_KEY=<api_key>
SPICE_SPICEAI_TOKEN=<api_token>
Step 3. Start the Spice runtime.
spice run
Step 4. Configure the dataset to connect to Spice.ai:
Open a new terminal window in the spiceai-demo directory.
spice dataset configure
Enter the name of the dataset:
dataset name: (spiceai-demo) taxi_trips
Enter the description of the dataset:
description: Taxi trips in New York City
Specify the location of the dataset:
from: spice.ai/spiceai/quickstart/datasets/taxi_trips
Select "n" when prompted whether to locally accelerate the dataset:
Locally accelerate (y/n)? n
The CLI will confirm the dataset has been configured with the following output:
Saved datasets/taxi_trips/dataset.yaml
The content of dataset.yaml is the following:
cat datasets/taxi_trips/dataset.yaml
from: spice.ai/spiceai/quickstart/datasets/taxi_trips
name: taxi_trips
description: Taxi trips in New York City
params:
spiceai_region: us-east-1
The spiceai_region parameter selects which Spice Cloud region to source the dataset from. Run spice cloud regions to list available regions.
The Spice runtime terminal will show that the dataset has been loaded:
2024-12-16T14:40:29.181034Z INFO runtime::init::dataset: Dataset taxi_trips registered (spice.ai/spiceai/quickstart/datasets/taxi_trips), results cache enabled.
Step 5. Run queries against the dataset using the Spice SQL REPL.
In a new terminal, start the Spice SQL REPL
spice sql
You can now now query taxi_trips in the runtime.
SELECT tpep_pickup_datetime, passenger_count, trip_distance FROM taxi_trips ORDER BY tpep_pickup_datetime LIMIT 10;
+----------------------+-----------------+---------------+
| tpep_pickup_datetime | passenger_count | trip_distance |
+----------------------+-----------------+---------------+
| 2002-12-31T22:59:39 | 1 | 0.63 |
| 2002-12-31T22:59:39 | 1 | 0.63 |
| 2009-01-01T00:24:09 | 2 | 10.88 |
| 2009-01-01T23:30:39 | 1 | 10.99 |
| 2009-01-01T23:58:40 | 1 | 0.46 |
| 2023-12-31T23:39:17 | 2 | 0.47 |
| 2023-12-31T23:41:02 | 1 | 0.4 |
| 2023-12-31T23:47:28 | 2 | 1.44 |
| 2023-12-31T23:49:12 | 1 | 3.14 |
| 2023-12-31T23:54:27 | 1 | 7.7 |
+----------------------+-----------------+---------------+
Time: 0.852775583 seconds. 10 rows.
Next Steps This recipe queries the Spice.ai Cloud Platform directly without any acceleration. Experiment with different acceleration options using Spice Data Accelerators (opens in a new tab).
View the Spice.ai datasets documentation (opens in a new tab) and search on spicerack.org (opens in a new tab) to explore and experiment with retrieving and accelerating multiple datasets to use with Spice.
Published Apr 2024
Published Sep 2024
Published Sep 2024
Published Sep 2024