1---
2title: 'Getting started with Spice.ai OSS'
3sidebar_label: 'Getting started'
4sidebar_position: 1
5description: 'Get started with Spice in 5 minutes'
6image: /img/og/getting-started.png
7pagination_next: null
8---
9
10import ReactPlayer from 'react-player';
11import Tabs from '@theme/Tabs';
12import TabItem from '@theme/TabItem';
13
14<div style={{display: 'flex', justifyContent: 'center', marginBottom: '15px'}}>
15 <ReactPlayer
16 controls
17 url='https://www.youtube.com/watch?v=RvUvmCzuqYI'
18 />
19</div>
20
21### Follow these steps to get started with Spice
22
23Download the latest version of Spice, connect to a dataset in S3, and ask questions about the data using AI, in less than 5 minutes.
24
25**Step 1.** Install the Spice CLI:
26
27<Tabs>
28 <TabItem value="default" label="macOS, Linux, and WSL" default>
29 ### Install Script
30
31 ```bash
32 curl https://install.spiceai.org | /bin/bash
33 ```
34
35 ### Homebrew
36
37 ```bash
38 brew install spiceai/spiceai/spice
39 ```
40 </TabItem>
41 <TabItem value="windows" label="Windows" default>
42 ### PowerShell Install Script
43
44 ```bash
45 iex ((New-Object System.Net.WebClient).DownloadString("https://install.spiceai.org/Install.ps1"))
46 ```
47 </TabItem>
48</Tabs>
49
50**Step 2.** Initialize a new Spice app with the `spice init` command:
51
52```bash
53spice init spice_qs
54```
55
56A `spicepod.yaml` file is created in the `spice_qs` directory. Change to that directory:
57
58```bash
59cd spice_qs
60```
61
62**Step 3.** Add the `spiceai/quickstart` Spicepod. A Spicepod is a package of configuration defining datasets and ML models.
63
64```bash
65spice add spiceai/quickstart
66```
67
68The `spicepod.yaml` file will be updated with the `spiceai/quickstart` dependency.
69
70```yaml
71version: v1
72kind: Spicepod
73name: spice_qs
74dependencies:
75 - spiceai/quickstart
76```
77
78**Step 4.** Add an [OpenAI] model to the Spicepod, with tools enabled to enable the model to access the data:
79
80[OpenAI]: /docs/components/models/openai
81
82```yaml
83models:
84 - from: openai:gpt-4o-mini
85 name: openai_model
86 params:
87 openai_api_key: ${ env:OPENAI_API_KEY }
88 tools: auto
89```
90
91Add your OpenAI API key to a `.env` file that will be automatically loaded:
92
93```bash
94echo "OPENAI_API_KEY=sk-..." > .env
95```
96
97Start the Spice runtime:
98
99```bash
100spice run
101```
102
103Example output:
104
105```bash
106Spice.ai runtime starting...
1072024-08-05T13:02:40.247484Z INFO runtime::flight: Spice Runtime Flight listening on 127.0.0.1:50051
1082024-08-05T13:02:40.247490Z INFO runtime::metrics_server: Spice Runtime Metrics listening on 127.0.0.1:9090
1092024-08-05T13:02:40.247949Z INFO runtime: Initialized results cache; max size: 128.00 MiB, item ttl: 1s
1102024-08-05T13:02:40.248611Z INFO runtime::http: Spice Runtime HTTP listening on 127.0.0.1:8090
1112024-08-05T13:02:40.252356Z INFO runtime::opentelemetry: Spice Runtime OpenTelemetry listening on 127.0.0.1:50052
112```
113
114**Step 5.** Start the Spice Chat REPL and ask a question:
115
116```bash
117$ spice chat
118Using model: openai_model
119chat> How many taxi trips were taken?
120A total of 2,964,624 trips were taken according to the dataset.
121```
122
123The OpenAI model was automatically provided with the `taxi_trips` dataset and was able to answer the question.
124
125**Step 6.** Start the Spice SQL REPL:
126
127```bash
128spice sql
129```
130
131The SQL REPL inferface will be shown:
132
133```
134Welcome to the Spice.ai SQL REPL! Type 'help' for help.
135
136show tables; -- list available tables
137sql>
138```
139
140Enter `show tables;` to display the available tables for query:
141
142```
143sql> show tables
144+---------------+--------------+---------------+------------+
145| table_catalog | table_schema | table_name | table_type |
146+---------------+--------------+---------------+------------+
147| spice | public | taxi_trips | BASE TABLE |
148| spice | runtime | task_history | BASE TABLE |
149| spice | runtime | metrics | BASE TABLE |
150+---------------+--------------+---------------+------------+
151
152Time: 0.022671708 seconds. 3 rows.
153```
154
155Enter a query to display the longest taxi trips:
156
157```
158sql> SELECT trip_distance, total_amount FROM taxi_trips ORDER BY trip_distance DESC LIMIT 10;
159```
160
161Output:
162
163```
164+---------------+--------------+
165| trip_distance | total_amount |
166+---------------+--------------+
167| 312722.3 | 22.15 |
168| 97793.92 | 36.31 |
169| 82015.45 | 21.56 |
170| 72975.97 | 20.04 |
171| 71752.26 | 49.57 |
172| 59282.45 | 33.52 |
173| 59076.43 | 23.17 |
174| 58298.51 | 18.63 |
175| 51619.36 | 24.2 |
176| 44018.64 | 52.43 |
177+---------------+--------------+
178
179Time: 0.045150667 seconds. 10 rows.
180```
181
182## Next Steps
183
184import DocCardList from '@theme/DocCardList';
185
186<DocCardList items={[{type: 'link', label: 'Cookbook', href: 'https://github.com/spiceai/cookbook', description: 'Spice.ai Cookbook Recipes.'}]} />
187
1---
2title: 'Getting started with Spice.ai OSS'
3sidebar_label: 'Getting started'
4sidebar_position: 1
5description: 'Get started with Spice in 5 minutes'
6image: /img/og/getting-started.png
7pagination_next: null
8---
9
10import ReactPlayer from 'react-player';
11import Tabs from '@theme/Tabs';
12import TabItem from '@theme/TabItem';
13
14<div style={{display: 'flex', justifyContent: 'center', marginBottom: '15px'}}>
15 <ReactPlayer
16 controls
17 url='https://www.youtube.com/watch?v=RvUvmCzuqYI'
18 />
19</div>
20
21### Follow these steps to get started with Spice
22
23Download the latest version of Spice, connect to a dataset in S3, and ask questions about the data using AI, in less than 5 minutes.
24
25**Step 1.** Install the Spice CLI:
26
27<Tabs>
28 <TabItem value="default" label="macOS, Linux, and WSL" default>
29 ### Install Script
30
31 ```bash
32 curl https://install.spiceai.org | /bin/bash
33 ```
34
35 ### Homebrew
36
37 ```bash
38 brew install spiceai/spiceai/spice
39 ```
40 </TabItem>
41 <TabItem value="windows" label="Windows" default>
42 ### PowerShell Install Script
43
44 ```bash
45 iex ((New-Object System.Net.WebClient).DownloadString("https://install.spiceai.org/Install.ps1"))
46 ```
47 </TabItem>
48</Tabs>
49
50**Step 2.** Initialize a new Spice app with the `spice init` command:
51
52```bash
53spice init spice_qs
54```
55
56A `spicepod.yaml` file is created in the `spice_qs` directory. Change to that directory:
57
58```bash
59cd spice_qs
60```
61
62**Step 3.** Add the `spiceai/quickstart` Spicepod. A Spicepod is a package of configuration defining datasets and ML models.
63
64```bash
65spice add spiceai/quickstart
66```
67
68The `spicepod.yaml` file will be updated with the `spiceai/quickstart` dependency.
69
70```yaml
71version: v1
72kind: Spicepod
73name: spice_qs
74dependencies:
75 - spiceai/quickstart
76```
77
78**Step 4.** Add an [OpenAI] model to the Spicepod, with tools enabled to enable the model to access the data:
79
80[OpenAI]: /docs/components/models/openai
81
82```yaml
83models:
84 - from: openai:gpt-4o-mini
85 name: openai_model
86 params:
87 openai_api_key: ${ env:OPENAI_API_KEY }
88 tools: auto
89```
90
91Add your OpenAI API key to a `.env` file that will be automatically loaded:
92
93```bash
94echo "OPENAI_API_KEY=sk-..." > .env
95```
96
97Start the Spice runtime:
98
99```bash
100spice run
101```
102
103Example output:
104
105```bash
106Spice.ai runtime starting...
1072024-08-05T13:02:40.247484Z INFO runtime::flight: Spice Runtime Flight listening on 127.0.0.1:50051
1082024-08-05T13:02:40.247490Z INFO runtime::metrics_server: Spice Runtime Metrics listening on 127.0.0.1:9090
1092024-08-05T13:02:40.247949Z INFO runtime: Initialized results cache; max size: 128.00 MiB, item ttl: 1s
1102024-08-05T13:02:40.248611Z INFO runtime::http: Spice Runtime HTTP listening on 127.0.0.1:8090
1112024-08-05T13:02:40.252356Z INFO runtime::opentelemetry: Spice Runtime OpenTelemetry listening on 127.0.0.1:50052
112```
113
114**Step 5.** Start the Spice Chat REPL and ask a question:
115
116```bash
117$ spice chat
118Using model: openai_model
119chat> How many taxi trips were taken?
120A total of 2,964,624 trips were taken according to the dataset.
121```
122
123The OpenAI model was automatically provided with the `taxi_trips` dataset and was able to answer the question.
124
125**Step 6.** Start the Spice SQL REPL:
126
127```bash
128spice sql
129```
130
131The SQL REPL inferface will be shown:
132
133```
134Welcome to the Spice.ai SQL REPL! Type 'help' for help.
135
136show tables; -- list available tables
137sql>
138```
139
140Enter `show tables;` to display the available tables for query:
141
142```
143sql> show tables
144+---------------+--------------+---------------+------------+
145| table_catalog | table_schema | table_name | table_type |
146+---------------+--------------+---------------+------------+
147| spice | public | taxi_trips | BASE TABLE |
148| spice | runtime | task_history | BASE TABLE |
149| spice | runtime | metrics | BASE TABLE |
150+---------------+--------------+---------------+------------+
151
152Time: 0.022671708 seconds. 3 rows.
153```
154
155Enter a query to display the longest taxi trips:
156
157```
158sql> SELECT trip_distance, total_amount FROM taxi_trips ORDER BY trip_distance DESC LIMIT 10;
159```
160
161Output:
162
163```
164+---------------+--------------+
165| trip_distance | total_amount |
166+---------------+--------------+
167| 312722.3 | 22.15 |
168| 97793.92 | 36.31 |
169| 82015.45 | 21.56 |
170| 72975.97 | 20.04 |
171| 71752.26 | 49.57 |
172| 59282.45 | 33.52 |
173| 59076.43 | 23.17 |
174| 58298.51 | 18.63 |
175| 51619.36 | 24.2 |
176| 44018.64 | 52.43 |
177+---------------+--------------+
178
179Time: 0.045150667 seconds. 10 rows.
180```
181
182## Next Steps
183
184import DocCardList from '@theme/DocCardList';
185
186<DocCardList items={[{type: 'link', label: 'Cookbook', href: 'https://github.com/spiceai/cookbook', description: 'Spice.ai Cookbook Recipes.'}]} />
187