> ## Documentation Index
> Fetch the complete documentation index at: https://docs.thinkplatform.ai/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Choose User guide for browser tasks, Developers for CLI, SDK and external agents, and Administration for organization management.
> Confirm identity and organization/project context before operations. Documentation access does not grant ThinkPlatform permissions.
> Review side effects, verify changes with a read, and do not blindly retry an operation with an uncertain outcome.
> Use documented UI steps for the web app and documented public CLI or SDK interfaces for automation. Follow each page’s prerequisites and authentication requirements.

# Lakehouse AI commands

> Discover AI functions, run SQL, validate notebooks, and save recurring work as jobs.

These examples assume an authenticated active saved profile with the intended organization and project. Confirm it with `tp context show` before running commands. Add root `--json` before the command when machine parsing needs JSON output; use root `--profile <name>` only to override the active profile.

## Discover functions

```bash theme={"system"}
tp lakehouse ai-functions list --surface python_notebook
tp lakehouse ai-functions describe ai_summarize
tp lakehouse ai-functions describe ai_query --no-probe-workspace
```

The list is the managed Registry. `describe` normally overlays target-workspace availability from `DESCRIBE FUNCTION EXTENDED` without running inference.

## Inspect source data

```bash theme={"system"}
tp lakehouse catalog show
tp lakehouse tables get silver.reviews
tp lakehouse tables preview silver.reviews --limit 10

tp datalake list --path project/raw/reviews
tp datalake preview --path project/raw/reviews/reviews.jsonl
tp datalake resolve-uri --path project/raw/reviews
```

`project/raw/...` is a ThinkPlatform logical path, not a Unity Catalog Volume path. Use the URI returned by `datalake resolve-uri` as the notebook or Job `input_path`; do not construct `/Volumes/<catalog>/project/...` or an ABFSS URI yourself.

## Run and monitor a SQL statement

```bash theme={"system"}
tp lakehouse statements execute \
  --statement "SELECT ai_summarize(:text) AS summary" \
  --parameter "text=A short representative review" \
  --parameter-type "text=STRING" \
  --wait-timeout 0s \
  --on-wait-timeout CONTINUE

tp lakehouse statements get <statement-id>
tp lakehouse statements result-chunk <statement-id> 1
tp lakehouse statements cancel <statement-id>
```

For advanced options, provide a JSON request in the format accepted by Databricks:

```bash theme={"system"}
tp lakehouse statements execute --body @request.json --dry-run
```

## Import and validate notebooks

```bash theme={"system"}
tp lakehouse notebooks upsert notebooks/ai/review_enrichment \
  --file review_enrichment.sql \
  --language SQL

tp lakehouse notebooks run notebooks/ai/review_enrichment \
  --compute serverless \
  --environment-version <supported-version> \
  --dependency 'pydantic==2.12.5' \
  --param sample_limit=10 \
  --wait
```

Omit environment options to inherit the notebook/workspace default. Never combine `--serverless` and `--cluster-id`.

## Save production work as a job

```bash theme={"system"}
tp lakehouse jobs upsert-notebook \
  --name review-ai-enrichment \
  --notebook-path notebooks/ai/review_enrichment \
  --compute serverless \
  --environment-version <supported-version> \
  --param sample_limit=0 \
  --dry-run

tp lakehouse jobs run <job-id> --wait
tp lakehouse runs output <run-id> --mode compact
```

One-time Serverless runs are for validation. Use a saved Job for repeatable or production processing.

`--wait` resolves the latest retry attempt automatically when a run has repeated entries for one task key. For a genuine multi-task Job, inspect the parent with `tp lakehouse runs get <run-id>`, then request each task run's output explicitly.

SQL notebook compact output may contain only run metadata. Use an independent `tp lakehouse statements execute` query against the materialized project-catalog table for row-level acceptance checks. A raw-only `read_files` Statement can be rejected by the project-catalog guard; perform raw inspection in the bounded notebook and keep the independent Statement focused on the resulting project table.

Use no more than 10 representative rows for the default validation. Materialize the AI expression once, then perform all acceptance queries against that output. Keep preview caching enabled; add `--fresh` only for the first read after the materialization commit.

## CLI and MCP execution routes

| Intent | Local Agent / Codex | ThinkPlatform Agent |
| - | - | - |
| Discover function | `tp lakehouse ai-functions list/describe` | AI Function registry MCP system tools |
| Preview | `tp lakehouse sql preview` | SQL preview system tool, `fresh=false` |
| Validation run | `tp lakehouse notebooks run --compute serverless` | Notebook run system tool, `compute_mode=serverless` |
| Saved run | `tp lakehouse jobs upsert-* --compute serverless` | Job upsert system tool, `compute_mode=serverless` |
| Cost evidence | `tp lakehouse costs overview` | `databricks_get_cost_overview` |

If Serverless is unsupported, use `job-cluster`/`job_cluster` with the organization policy. Use existing compute only with explicit approval and an explicit cluster ID.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.