Python SDK API
Install the SDK and any data-source extras by following Installation Guide for Kumo Relational. This reference documents the public sdm_client interfaces used by the Kumo Relational workflow.
What is public is defined precisely: everything named in sdm_client.__all__, sdm_api.__all__, sdm_connectors.__all__, and sdm_connectors.databricks.__all__. Anything beginning with _, and every submodule not re-exported at the top level (sdm_client.core, .adapters, .materializers, .wire), is an implementation detail that can change in any release. sdm_relational_engine is reached only through sdm_client. Importing it directly is at your own risk. Refer to the stability contract for the full rules and the deprecation policy.
Import the supported public interfaces from sdm_client:
SDMClient
The client constructor has the following signature:
A connection to one NIM, serving every model it can reach. Use it as a context manager for a scoped sequence of requests. For an application or notebook that makes multiple requests, create one client, reuse it, and call close() when finished. Calling close() retires the client permanently. Construct a new client instead of attempting to reuse a closed one.
The client exposes the following methods:
Several clients can target different endpoints or tenants concurrently, including from multiple threads. Each prediction remains bound to the endpoint and credential of the client that started it.
Connecting Through Databricks Model Serving
The client constructor for Databricks Model Serving has the following signature:
The following example predicts through a Databricks Model Serving endpoint:
endpoint is the model’s name on the serving endpoint, not a URL. There is no key, because the call authenticates through the Databricks SDK with workspace_client’s identity (the notebook’s own, when omitted). Requires pip install "structured-data-models-client[relational,databricks-serving]" for the Kumo Relational workflow. fit() is refused there: a serving endpoint answers one request at a time and has no session to pin a context in. There is no for_snowflake_serving.
KumoRelational
The following example passes the relational model handle to a prediction:
A thin, stateless handle naming the relational model. Requires the structured-data-models-client[relational] extra, which pulls in the native structured-data-models-relational-engine (CPython 3.10 through 3.13 only).
The following table summarizes the handle’s task kinds, output fields, and request requirements:
Schema
The two schema constructors have the following signatures:
from_data() builds a schema from DataFrames already in memory, inferring dtype, semantic type, primary key, time column, and relationships for every table. from_source() describes tables that stay where they are (a warehouse or database) without reading any table in full. Building the schema still queries the source for column metadata, a row preview per table, and (unless check_keys=False) a key-uniqueness scan. Only materialize() samples the rows a prediction actually needs, with SQL. Refer to Build a Schema.
The following example builds a schema from DataFrames and sets a primary key and a time column:
Index it by table name, and index a table by column name. There is no visualize(), print_metadata(), or print_links(). Inspect a schema with print(schema), schema.tables, and schema.relationships. Call schema.check_consistent() to validate. schema.conversion_notes records what a semantic-model conversion resolved, for reading. Its wording is not part of the contract.
Relationship
A relationship has the following signature:
A foreign key pointing at a table’s primary key, directed from the many side to the one side. Refer to Define Relationships.
PredictiveQuery
The query constructor and its materialize() method have the following signatures:
Resolves and validates the query when materialize() builds a request. For a relational schema, indices selects existing entities by key. The direct-row form (predict=) is tabular-only. candidates= is required for a RANK TOP K query. Refer to Configuration for every option and its default, and to Limits for size caps.
Request
The wire envelope minus the two things that are predict() arguments: which model answers it, and which output fields you want back. For Kumo Relational, build it only through PredictiveQuery(...).materialize(...).
The read-only properties are is_relational, context_rows, predict_rows, and nothing_to_score. request.task is a Task(kind, target, entity_table, options). request.task.target is a Target(column_name, dtype, table_name). request.context/request.predict are each a Split(instance_table, related_tables). These are read-only descriptions of a request, not something you construct by hand.
SourceTable
What schema["table"] returns for a table built with Schema.from_source(), in place of a Table. Holds column metadata and keys but no rows. Sampling reads the rows from the source when a query is materialized. You correct keys, time columns, and semantic types the same way as on a Table.
ModelCapabilities
What client.capabilities(model) returns: model, tasks, outputs, single_table, multiple_tables, relationships, explanation_formats, and sessions. Describes this client, not the endpoint. Refer to Prediction Types.
PredictionResult
A prediction result carries the following attributes and methods:
FittedModel
Returned by SDMClient.fit(). predict(request) scores rows against the pinned context. close() releases it. Use it as a context manager or call close() explicitly. The constructor is not public, so call client.fit().
Errors
Import the public error classes from sdm_client:
Every call on SDMClient raises StructuredDataError or a subclass, so except StructuredDataError catches anything the client reports. Every error carries a stable code. Branch on it and on the exception type, never on the message text, because message wording is not part of the public contract.
The following table lists the error classes and their codes:
A call that fails partway through a batched request carries what it already answered on the error’s details: answered/rows_answered for entities, parts_answered for a forecast’s completed steps.
Typed relational connection and graph-construction failures are translated to StructuredDataError when they cross the client boundary. sdm_relational_engine’s own exception types are not public API.
sdm_connectors
Import the connector interfaces from sdm_connectors:
read()/read_table() load a table into a DataFrame for Schema.from_data(). Each *Source class describes tables that stay in their backend for Schema.from_source(), built from that backend’s own driver connection. DatabricksSource and SnowflakeSource also offer .semantic_model(name) for a metric view or semantic view. Refer to the connector pages under Connect Data Sources.