### Spicepod configuration with quickstart Source: https://github.com/spiceai/docs/blob/trunk/website/versioned_docs/version-1.11.x/getting-started/index.mdx Example spicepod.yaml file after adding the quickstart dependency. ```yaml version: v1 kind: Spicepod name: spice_qs dependencies: - spiceai/quickstart ``` -------------------------------- ### Examples Source: https://github.com/spiceai/docs/blob/trunk/website/docs/cli/reference/install.md Install the core runtime that only includes data components. ```shell spice install ``` -------------------------------- ### Example 1 Source: https://github.com/spiceai/docs/blob/trunk/website/versioned_docs/version-1.11.x/cli/reference/connect.md Connect to the quickstart app. ```shell > spice connect spiceai/quickstart ``` -------------------------------- ### Additional Example Source: https://github.com/spiceai/docs/blob/trunk/website/docs/cli/reference/install.md Install the runtime with CUDA GPU acceleration. ```shell spice install cuda ``` -------------------------------- ### Add the quickstart Spicepod Source: https://github.com/spiceai/docs/blob/trunk/website/docs/getting-started/index.mdx Adds the 'spiceai/quickstart' Spicepod to the application, which includes the 'taxi_trips' dataset. ```bash spice add spiceai/quickstart ``` -------------------------------- ### Install Go SDK Source: https://github.com/spiceai/docs/blob/trunk/website/docs/sdks/golang/index.md Install the Go SDK using go get. ```shell go get github.com/spiceai/gospice/v8@latest ``` -------------------------------- ### Quickstart Source: https://github.com/spiceai/docs/blob/trunk/website/docs/deployment/kubernetes/helm/index.md Add the Spice Helm repository, update it, and install Spice.ai. ```bash helm repo add spiceai https://helm.spiceai.org helm repo update helm upgrade --install spiceai spiceai/spiceai ``` -------------------------------- ### Example: Basic Usage Source: https://github.com/spiceai/docs/blob/trunk/website/docs/cli/reference/sql.md Starts the SQL REPL and shows available tables. ```shell $ spice sql Welcome to the Spice.ai SQL REPL! Type 'help' for help. show tables; -- list available tables sql> show tables +---------------+--------------------+---------------+------------+ | table_catalog | table_schema | table_name | table_type | +---------------+--------------------+---------------+------------+ | datafusion | public | tmp_view_test | VIEW | | datafusion | information_schema | tables | VIEW | | datafusion | information_schema | views | VIEW | | datafusion | information_schema | columns | VIEW | | datafusion | information_schema | df_settings | VIEW | +---------------+--------------------+---------------+------------+ ``` -------------------------------- ### Ask a question using Spice Chat Source: https://github.com/spiceai/docs/blob/trunk/website/versioned_docs/version-1.11.x/getting-started/index.mdx Example interaction with the Spice Chat REPL, asking a question about taxi trips. ```bash Using model: openai_model chat> How many taxi trips were taken? A total of 2,964,624 trips were taken according to the dataset. ``` -------------------------------- ### Initialize a new Spice app Source: https://github.com/spiceai/docs/blob/trunk/website/docs/getting-started/index.mdx Initializes a new Spice application and navigates into its directory. ```bash spice init spice_qs cd spice_qs ``` -------------------------------- ### Example: mTLS Client Authentication Source: https://github.com/spiceai/docs/blob/trunk/website/docs/cli/reference/sql.md Starts the SQL REPL with mTLS client authentication enabled. ```shell $ spice sql --tls-root-certificate-file /path/to/ca.pem \ --client-tls-certificate-file /path/to/client-cert.pem \ --client-tls-key-file /path/to/client-key.pem Welcome to the Spice.ai SQL REPL! Type 'help' for help. ``` -------------------------------- ### Example: TLS Root Certificate Source: https://github.com/spiceai/docs/blob/trunk/website/docs/cli/reference/sql.md Starts the SQL REPL with a specified TLS root certificate. ```shell $ spice sql --tls-root-certificate-file /path/to/cert.pem Welcome to the Spice.ai SQL REPL! Type 'help' for help. ``` -------------------------------- ### Example: Multiple Ready Models Prompt Source: https://github.com/spiceai/docs/blob/trunk/website/docs/cli/reference/chat.md When multiple models are ready, the command prompts for a selection before starting the REPL. ```shell > spice chat Use the arrow keys to navigate: ↓ ↑ → ← ? Select model: ▸ openai llama Using model: openai chat> hello Hello! How can I assist you today? Time: 0.55s (first token 0.43s). Tokens: 18. Prompt: 8. Completion: 10 (80.09/s). ``` -------------------------------- ### Start the Spice Chat REPL Source: https://github.com/spiceai/docs/blob/trunk/website/docs/getting-started/index.mdx Starts the Spice Chat REPL for interacting with AI models and datasets. ```bash $ spice chat ``` -------------------------------- ### Sample output with upgrade available Source: https://github.com/spiceai/docs/blob/trunk/website/docs/cli/reference/version.md Example output showing the current CLI and runtime versions, and a notification about an available upgrade. ```shell > spice version CLI version: v1.0.6 Runtime version: v1.0.6+models CLI version v1.1.0 is now available! To upgrade, run "spice upgrade". ``` -------------------------------- ### Example: Remote Connection with Show Tables Source: https://github.com/spiceai/docs/blob/trunk/website/docs/cli/reference/sql.md Demonstrates connecting to a remote instance and showing tables. ```shell show tables; -- list available tables sql> show tables +---------------+--------------------+---------------+------------+ | table_catalog | table_schema | table_name | table_type | +---------------+--------------------+---------------+------------+ | datafusion | public | tmp_view_test | VIEW | | datafusion | information_schema | tables | VIEW | | datafusion | information_schema | views | VIEW | | datafusion | information_schema | columns | VIEW | | datafusion | information_schema | df_settings | VIEW | +---------------+--------------------+---------------+------------+ ``` -------------------------------- ### Auto-detect shell and install completions Source: https://github.com/spiceai/docs/blob/trunk/website/docs/cli/reference/completions.md Example of auto-detecting the user's shell and installing completions. ```shell spice completions ``` -------------------------------- ### Complete example Source: https://github.com/spiceai/docs/blob/trunk/website/docs/features/data-acceleration/snapshots.md This example shows how to configure snapshots for both batch and stream datasets. ```yaml snapshots: enabled: true location: s3://some_bucket/some_folder/ bootstrap_on_failure_behavior: warn params: s3_auth: iam_role datasets: # Batch dataset with refresh-triggered snapshots - from: s3://some_bucket/batch_table/ name: batch_table params: file_format: parquet s3_auth: iam_role acceleration: enabled: true engine: duckdb mode: file snapshots: enabled snapshots_trigger: refresh_complete snapshots_compaction: enabled params: duckdb_file: /nvme/batch_table.db # Stream dataset with time-interval snapshots - from: debezium:cdc_source name: stream_table acceleration: enabled: true engine: duckdb mode: file refresh_mode: changes snapshots: enabled snapshots_trigger: time_interval snapshots_trigger_threshold: 5m params: duckdb_file: /nvme/stream_table.db ``` -------------------------------- ### Example: Connect to Spice Cloud Source: https://github.com/spiceai/docs/blob/trunk/website/docs/cli/reference/sql.md Connects to Spice Cloud using an API key. ```shell # Connect to Spice Cloud spice sql --cloud --api-key ``` -------------------------------- ### octet_length Example Source: https://github.com/spiceai/docs/blob/trunk/website/docs/reference/sql/scalar_functions.md Example of using the octet_length function to get the number of bytes in a string. ```sql > select octet_length('Ångström'); +--------------------------------+ | octet_length(Utf8("Ångström")) | +--------------------------------+ | 10 | +--------------------------------+ ``` -------------------------------- ### character_length Example Source: https://github.com/spiceai/docs/blob/trunk/website/docs/reference/sql/scalar_functions.md Example of using the character_length function to get the number of characters in a string. ```sql > select character_length('Ångström'); +------------------------------------+ | character_length(Utf8("Ångström")) | +------------------------------------+ | 8 | +------------------------------------+ ``` -------------------------------- ### Sample output for latest version Source: https://github.com/spiceai/docs/blob/trunk/website/docs/cli/reference/version.md Example output showing the current CLI and runtime versions when they are the latest. ```shell > spice version CLI version: v1.1.0 Runtime version: v1.1.0+models ``` -------------------------------- ### chr Example Source: https://github.com/spiceai/docs/blob/trunk/website/docs/reference/sql/scalar_functions.md Example of using the chr function to get a character from its Unicode code point. ```sql > select chr(128640); +--------------------+ | chr(Int64(128640)) | +--------------------+ | 🚀 | +--------------------+ ``` -------------------------------- ### Full TLS Configuration Example Source: https://github.com/spiceai/docs/blob/trunk/website/docs/reference/spicepod/runtime.md An example demonstrating a complete TLS configuration including client authentication. ```yaml runtime: tls: enabled: true certificate_file: /path/to/cert.pem key_file: /path/to/key.pem client_auth_mode: required client_auth_ca_file: /path/to/client-ca.pem ``` -------------------------------- ### Spice CLI Install Specific Version Source: https://github.com/spiceai/docs/blob/trunk/website/releases/v1.9.0-rc.4.md Examples of using the 'spice install' command to install specific versions of the Spice runtime and CLI, including with the AI flavor. ```console # Install a specific version spice install v1.8.3 # Install a specific version with AI flavor spice install v1.8.3 ai # Install latest version (existing behavior) spice install spice install ai ``` -------------------------------- ### Rate Control Configuration Example Source: https://github.com/spiceai/docs/blob/trunk/website/docs/components/data-connectors/https/deployment.md Example of configuring rate control limits globally and per dataset. ```yaml runtime: params: http_max_concurrent_requests: 10 http_requests_per_second_limit: 5 datasets: - from: https://api.example.com/v1 name: api_data params: file_format: json allowed_request_paths: '/data/**' max_concurrent_requests: 3 # Override for this dataset requests_per_minute_limit: 60 ``` -------------------------------- ### regexp_instr Example Source: https://github.com/spiceai/docs/blob/trunk/website/docs/reference/sql/scalar_functions.md Example showing how to use regexp_instr to find the starting position of a regular expression match within a string. ```sql > SELECT regexp_instr('ABCDEF', 'C(.)(..)'); +---------------------------------------------------------------+ | regexp_instr(Utf8("ABCDEF"),Utf8("C(.)(..)")) | +---------------------------------------------------------------+ | 3 | +---------------------------------------------------------------+ ``` -------------------------------- ### Example: Adding a Spicepod Source: https://github.com/spiceai/docs/blob/trunk/website/docs/cli/reference/add.md An example of adding the 'spiceai/quickstart' Spicepod from Spicerack. ```shell > spice add spiceai/quickstart ``` -------------------------------- ### Get Recommendation for a Specific Time API Request Source: https://github.com/spiceai/docs/blob/trunk/website/releases/v0.4-alpha.md Example of how to make a GET request to the /recommendation API to fetch recommendations for a specific time. ```http GET http://localhost:8000/api/v0.1/pods/{pod}/recommendation?time={unix_timestamp} ``` ```http GET http://localhost:8000/api/v0.1/pods/trader/recommendation?time=1605729600 ``` -------------------------------- ### Build Source: https://github.com/spiceai/docs/blob/trunk/website/README.md Builds static content for deployment. ```bash npm run build ``` -------------------------------- ### --endpoint Example 1 Source: https://github.com/spiceai/docs/blob/trunk/website/docs/cli/reference/run.md Set the HTTP bind address using scheme-based routing. ```shell spice run --endpoint http://0.0.0.0:8090 ``` -------------------------------- ### Example: Configuring a System Prompt Source: https://github.com/spiceai/docs/blob/trunk/website/docs/components/models/index.md Demonstrates how to configure an additional system prompt for a model. ```yaml models: - name: pirate-haikus from: openai:gpt-4o params: system_prompt: | Write everything in Haiku like a pirate ``` -------------------------------- ### Plain column partitioning SQL example Source: https://github.com/spiceai/docs/blob/trunk/website/docs/features/data-acceleration/partitioning.md SQL example for querying data partitioned by a plain column. ```sql -- One partition read: SELECT * FROM events WHERE region = 'EU'; ``` -------------------------------- ### regexp_count Example Source: https://github.com/spiceai/docs/blob/trunk/website/docs/reference/sql/scalar_functions.md Example demonstrating the usage of the regexp_count function to count occurrences of a pattern within a string, with optional start position and flags. ```sql > select regexp_count('abcAbAbc', 'abc', 2, 'i'); +---------------------------------------------------------------+ | regexp_count(Utf8("abcAbAbc"),Utf8("abc"),Int64(2),Utf8("i")) | +---------------------------------------------------------------+ | 1 | +---------------------------------------------------------------+ ``` -------------------------------- ### ltrim Example (whitespace) Source: https://github.com/spiceai/docs/blob/trunk/website/versioned_docs/version-1.11.x/reference/sql/scalar_functions.md Removes whitespace from the start of a string. ```sql > select ltrim(' datafusion '); +-------------------------------+ | ltrim(Utf8(" datafusion ")) | +-------------------------------+ | datafusion | +-------------------------------+ ``` -------------------------------- ### Identical Configuration Examples Source: https://github.com/spiceai/docs/blob/trunk/website/docs/components/data-connectors/mysql/index.md Demonstrates two identical configuration examples for the 'from' field. ```yaml datasets: - from: mysql:mytable name: my_dataset params: mysql_db: my_database ... ``` ```yaml datasets: - from: mysql:my_database.mytable name: my_dataset params: ... ``` -------------------------------- ### Example values.yaml Source: https://github.com/spiceai/docs/blob/trunk/website/docs/deployment/kubernetes/helm/index.md This YAML file provides example configurations for deploying Spice.ai using a Helm chart, covering aspects like labels, image, replicas, service settings, resource limits, environment variables, stateful storage, monitoring, and Spicepod configurations including datasets. ```yaml additionalLabels: environment: production app: spice image: repository: spiceai/spiceai tag: latest-models replicaCount: 1 service: type: ClusterIP additionalAnnotations: service.beta.kubernetes.io/aws-load-balancer-internal: 'true' resources: limits: # cpu: 1000m # Do not set CPU limits - can cause throttling memory: 2Gi requests: cpu: 500m memory: 1Gi additionalEnv: - name: SPICED_LOG value: 'INFO' - name: SPICE_SECRET_SPICEAI_KEY valueFrom: secretKeyRef: name: spice-secrets key: spiceai-key stateful: enabled: true storageClass: 'standard' size: 5Gi mountPath: /data monitoring: podMonitor: enabled: true additionalLabels: release: prometheus spicepod: name: app version: v1 kind: Spicepod datasets: - from: s3://spiceai-demo-datasets/taxi_trips/2024/ name: taxi_trips description: Demo taxi trips in s3 params: file_format: parquet acceleration: enabled: true engine: duckdb mode: file params: duckdb_file: /data/taxi_trips.db # Uncomment to refresh the acceleration on a schedule # refresh_check_interval: 1h # refresh_mode: full ``` -------------------------------- ### Example: Expanded View Source: https://github.com/spiceai/docs/blob/trunk/website/docs/cli/reference/sql.md Starts the SQL REPL in expanded view for wide tables. ```shell $ spice sql --expanded Welcome to the Spice.ai SQL REPL! Type 'help' for help. sql> SELECT * FROM eth.recent_blocks LIMIT 1; -[ RECORD 1 ]----------+---------------------------------------- number | 18000000 hash | 0x9c2f1e8... timestamp | 2023-08-14T00:00:00Z gas_used | 12500000 ``` -------------------------------- ### Edge → Core Federation Example Source: https://github.com/spiceai/docs/blob/trunk/website/docs/components/data-connectors/spiceai/deployment.md Example configuration showing edge Spice runtimes accelerating local datasets and federating to a core Spice. ```yaml datasets: - from: postgres:public.local_orders # local, accelerated name: local_orders acceleration: enabled: true - from: spice.ai:https://core.example.com:50051 # federated name: historical_orders ``` -------------------------------- ### High-cardinality hash partitioning SQL examples Source: https://github.com/spiceai/docs/blob/trunk/website/docs/features/data-acceleration/partitioning.md SQL examples for querying partitioned data. ```sql -- Reads the single bucket that hashes user_id 42: SELECT COUNT(*) FROM events WHERE user_id = 42; -- Reads at most 4 bucket files: SELECT * FROM events WHERE user_id IN (1, 2, 3, 4); ``` -------------------------------- ### --endpoint Example 2 Source: https://github.com/spiceai/docs/blob/trunk/website/docs/cli/reference/run.md Set the Flight bind address using scheme-based routing. ```shell spice run --endpoint grpc://0.0.0.0:50051 ``` -------------------------------- ### Time-based partitioning SQL example Source: https://github.com/spiceai/docs/blob/trunk/website/docs/features/data-acceleration/partitioning.md SQL example for querying data partitioned by year. ```sql -- Equality on the partition expression prunes: SELECT * FROM lineitem WHERE date_part('year', l_shipdate) = 2026; ``` -------------------------------- ### Get Status Response (Failed) Source: https://github.com/spiceai/docs/blob/trunk/website/docs/features/distributed-query/index.md Example JSON response when a query has failed. ```json { "status": "FAILED", "error": { "error_code": "EXECUTION_FAILED", "message": "Table 'missing_table' not found", "sql_state": null } } ``` -------------------------------- ### 404 Not Found Response Example Source: https://github.com/spiceai/docs/blob/trunk/website/versioned_docs/version-1.11.x/api/HTTP/post.api.mdx Example of a response when the requested tool is not found. ```text Tool no_sql not found ``` -------------------------------- ### Get Query Response Source: https://github.com/spiceai/docs/blob/trunk/website/docs/features/distributed-query/index.md Example JSON response for a successful query retrieval. ```json { "query_id": "01ABC-DEF-456-7890AB", "status": "SUCCEEDED", "error": null, "manifest": { "format": "ARROW_IPC", "schema": { "column_count": 3, "columns": [ { "name": "id", "type_name": "Int64", "nullable": false, "position": 0 }, { "name": "status", "type_name": "Utf8", "nullable": true, "position": 1 }, { "name": "created_at", "type_name": "Timestamp(Microsecond, Some(\"UTC\"))", "nullable": true, "position": 2 } ] }, "total_row_count": 25000, "total_chunk_count": 3 }, "result": { "chunk_index": 0, "row_offset": 0, "row_count": 10000, "next_chunk_index": 1, "next_chunk_url": "/v1/queries/01ABC-DEF-456-7890AB/results/chunks/1", "data_array": [ { "id": 1, "status": "active", "created_at": "2025-06-15T10:30:00Z" } ] }, "created_at": "2026-03-02T12:00:00+00:00", "started_at": "2026-03-02T12:00:00.050+00:00", "completed_at": "2026-03-02T12:00:05.200+00:00", "expires_at": "2026-03-03T00:00:05.200+00:00" } ``` -------------------------------- ### Spicepod YAML Example Source: https://github.com/spiceai/docs/blob/trunk/website/docs/cli/reference/add.md The generated spicepod.yaml file for the 'spiceai/quickstart' Spicepod. ```yaml # File: ./spicepods/spiceai/quickstart/spicepod.yaml version: v1 kind: Spicepod name: quickstart datasets: - from: s3://spiceai-demo-datasets/taxi_trips/2024/ name: taxi_trips description: taxi trips in s3 params: file_format: parquet acceleration: enabled: true ``` -------------------------------- ### Go SDK Example Source: https://github.com/spiceai/docs/blob/trunk/website/releases/v1.11.0-rc.1.md Example of using prepared statements with the gospice SDK in Go, demonstrating parameterized queries with typed parameters. ```go import "github.com/spiceai/gospice/v8" client, _ := spice.NewClient() deferr client.Close() // Parameterized query with typed parameters results, _ := client.SqlWithParams(ctx, "SELECT * FROM products WHERE price > $1 AND category = $2", spice.Float64Param(10.0), spice.StringParam("electronics"), ) ``` -------------------------------- ### Docker Compose Configuration Source: https://github.com/spiceai/docs/blob/trunk/website/versioned_docs/version-1.11.x/deployment/docker/index.md Example Docker Compose configuration to build and start the Spice AI container. ```yaml services: spiced: build: context: . dockerfile: Dockerfile container_name: spiced-container ports: - '50051:50051' - '8090:8090' - '9090:9090' ``` -------------------------------- ### Show Columns Example Source: https://github.com/spiceai/docs/blob/trunk/website/versioned_docs/version-1.11.x/reference/sql/information_schema.md Demonstrates how to use the `SHOW COLUMNS` command to inspect the schema of a table. ```sql SHOW COLUMNS FROM task_history; ``` -------------------------------- ### Query Data with Spice SQL Source: https://github.com/spiceai/docs/blob/trunk/website/docs/deployment/aws/integrations.md Example of querying data using Spice SQL after starting the runtime. ```sql spice sql > SELECT COUNT(*) FROM taxi_trips; ``` -------------------------------- ### Spice Runtime Log Output Source: https://github.com/spiceai/docs/blob/trunk/website/docs/api/odbc/index.md Example log output from the Spice runtime after starting. ```log 2024-10-06T20:06:50.084015Z INFO runtime::flight: Spice Runtime Flight listening on 0.0.0.0:50051 2024-10-06T20:06:50.086948Z INFO runtime::http: Spice Runtime HTTP listening on 127.0.0.1:8090 2024-10-06T20:06:50.297512Z INFO runtime: Initialized results cache; max size: 128.00 MiB, item ttl: 1s 2024-10-06T20:06:50.308775Z INFO runtime: Tool [search] ready to use 2024-10-06T20:06:50.308803Z INFO runtime: Tool [table_schema] ready to use 2024-10-06T20:06:50.308814Z INFO runtime: Tool [sql] ready to use 2024-10-06T20:06:50.308829Z INFO runtime: Tool [list_datasets] ready to use 2024-10-06T20:06:50.921420Z INFO runtime: Dataset taxi_trips registered (s3://spiceai-demo-datasets/taxi_trips/2024/), results cache enabled. ``` -------------------------------- ### json_length Example Source: https://github.com/spiceai/docs/blob/trunk/website/docs/reference/sql/json.md Demonstrates how to get the length of a JSON object or array. ```sql > SELECT json_length('{"a": 1, "b": 2, "c": 3}'); +-----------------------------------------------+ | json_length(Utf8("{\"a\": 1, \"b\": 2, \"c\": 3}")) | +-----------------------------------------------+ | 3 | +-----------------------------------------------+ > SELECT json_length('[1, 2, 3, 4, 5]'); +--------------------------------------+ | json_length(Utf8("[1, 2, 3, 4, 5]")) | +--------------------------------------+ | 5 | +--------------------------------------+ ``` -------------------------------- ### Connect to Spice Runtime (Default) Source: https://github.com/spiceai/docs/blob/trunk/website/docs/sdks/golang/index.md Create a SpiceClient using default configuration. ```go spice := gospice.NewSpiceClient() defer spice.Close() if err := spice.Init(); err != nil { panic(fmt.Errorf("error initializing SpiceClient: %w", err)) } ``` -------------------------------- ### Example 1: List all models Source: https://github.com/spiceai/docs/blob/trunk/website/docs/cli/reference/models.md A simple example showing how to list all available models. ```shell >>> spice models ID OWNED_BY STATUS ERROR modlz local Ready ```