Skip to main content
Use the Python API to configure Chowder, submit SQL, and consume results.

Module functions

For general queries, use the module-level API and materialize before displaying:

Engine

A remote engine without an explicit location requires CHOWDER_API_URL. If the URL is unset or blank, creating the engine raises ValueError. Setting that URL and CHOWDER_API_TOKEN alone does not opt in. The default engine used by chowder.sql() follows CHOWDER_REMOTE when first created. See Connect to remote AI compute for remote selection and authentication.

Automatic cleanup

You can also use an engine as a context manager. The with block closes it automatically when the block exits, including when an exception occurs. Materialize the result before leaving the block:
The materialized result remains usable after the engine closes. Engine construction itself does not load a model. General query construction is not thread-safe. Give each submitting thread its own engine. engine.interrupt() is thread-safe so another thread can stop active work.

Query and lifecycle methods

Pass artifacts=True only when you also want to remove Chowder-owned model weights, runtime bundles, and compiled artifacts. It does not remove the third-party Hugging Face cache.

Source methods

Each method mirrors SELECT * FROM <function>(...) and returns a Relation:

In-scope tables

An unresolved SQL table name can bind to a same-named object in the caller’s scope. Supported inputs include PyArrow tables and datasets, Arrow record-batch readers and C streams, Polars DataFrames, pandas DataFrames, and a same-engine Relation.
The relation keeps a reference to reviews until you close or consume it.

Result types

SqlResult is the type alias Relation | StatementResult.

Relation

A Relation is a lazy, executable query plan for read-only SQL. Iterate over it to stream Arrow batches, or materialize the results as an Arrow table or DataFrame. Displaying or inspecting it does not read a source or load a model. Every consumption starts an independent execution of the same bound plan. A relation over a single-use captured reader is the documented exception and cannot be replayed. Relation implements the Arrow C stream protocol:
Use a Chowder materializer when you need Chowder’s typed exception taxonomy. Arrow C stream consumers carry error text but raise their own Arrow exception type.

StatementResult

A StatementResult represents side-effecting SQL. Its output can be consumed once. It cannot be replayed or explained because rebuilding its plan could repeat the side effect. Like Relation, it supports close() and with blocks.

Inspect query results in a notebook

Use chowder.display() to inspect nested structs, arrays, and supported image columns. Pass a Polars or pandas DataFrame, a PyArrow table, or a PyArrow record batch. If you have a Relation, materialize it first with a method such as to_polars(). The keyword arguments below show the defaults for how many rows and columns to display, how large image previews can be, and the maximum encoded size of a source image.

Additional APIs

Open these sections when you need configuration types, serving, or error handling.
Chowder selects the model for each AI operation; see Models.
serve runs a Chowder Arrow Flight server and blocks the calling thread. location=None binds grpc://127.0.0.1:8816, and protocol=None uses "flight". local_runtime configures server-owned document parsing and transcription runtimes. Remote AI functions use the server’s configured inference routes. reader_config bounds independently admitted sources. Use the same Chowder version on the client and server. See Self-host AI compute for deployment setup.
Closing the parent engine invalidates outstanding results. Consume or close them before leaving the engine context.