Skip to main content
Import the client, credentials, factories, and response models from thinkplatform.sdk. Follow Installation to install the SDK. This reference describes the synchronous SDK. For runnable examples, start with resource workflows and database tables. Response fields, aliases, and defaults are listed separately in models and results.

Reading signatures

Signatures omit self. A * makes every following parameter keyword-only. Parameters without a default are required. Optional[T] means T or None; Mapping and Iterable are standard Python typing interfaces. Any means the SDK does not impose a more specific result schema. The signature blocks show how to call each method; use the workflow guides for executable examples. Where present, org_id=None and project_id=None fall back independently to the client’s context. Project-scoped methods require both values and raise MissingContextError when they are absent. Organization-scoped methods require org_id. Context selects a scope; the credential and server still determine access. Methods whose signatures omit these keywords do not accept them. A Mapping[str, Any] payload is an endpoint-specific request object. Returned models describe responses. Before using their data to create or update a resource, check the deployed endpoint schema for required write fields. Mapping results use key access; models use attributes.

Create and close a client

base_url is your API endpoint and credential supplies tokens. timeout_seconds configures HTTP request timeouts. audience identifies the API token audience where required by the credential. Use with ThinkPlatformClient(...) as client: to close the client on exit, or call close() in finally. with_context() returns a client with the supplied context; None preserves the existing value, so it cannot clear a context value. Context clients share the original HTTP connection pool. Keep the original client open until every context client has finished, then close the original.

Factories

client_from_env and client_from_profile are available from thinkplatform.sdk. Pass an explicit endpoint or configure THINKPLATFORM_API_BASE_URL. Do not rely on a development endpoint default. env=None reads the process environment; an explicit mapping provides the environment source for the factory.
client_from_env() resolves supplied settings before environment settings and defaults its authentication mode to azure-cli when none is selected. client_from_profile() resolves a saved CLI profile and explicit overrides; see authentication for configuration. Both return clients with the same lifecycle as the constructor. Import the token convenience factory from the client submodule: from thinkplatform.sdk.client import client_from_token. It is not exported from thinkplatform.sdk itself.

Credentials

All classes below are exported from thinkplatform.sdk. Credentials are used by the client; creating one does not verify token acquisition or API permissions. Token acquisition may fail when a request first needs it. See authentication and errors.

StaticTokenCredential

AzureCliCredential

DeviceCodeCredential

InteractiveBrowserCredential

WorkspaceDelegationCredential

StaticTokenCredential returns the supplied token information; cache invalidation does not refresh a static token. Replace it with a current token when needed. expires_on is an optional expiry timestamp in Unix seconds; source and claims describe token metadata. AzureCliCredential uses an existing Azure CLI login. DeviceCodeCredential and InteractiveBrowserCredential require an appropriate application client ID and may require a user to sign in. Their env, tenant_id, and client_id parameters select configuration; refresh_buffer_seconds controls cached-token refresh timing. WorkspaceDelegationCredential is for a configured managed workspace. Supply workspace configuration through its supported parameters or the environment provided to that workspace. requested_scopes specifies the scopes to request; it does not grant additional permissions. Consult your deployment’s workspace setup before choosing this credential.

Custom credentials

Implement the exported ThinkPlatformCredential protocol. Return an AccessTokenInfo from get_token_info(). invalidate_cache() lets the client invalidate cached token state before a refresh attempt.

Low-level requests and uploads

Use these methods when you already know the API contract. path is an API request path. They do not discover payload schemas. request_json() and request_multipart() decode JSON; an empty body becomes None, and a non-JSON body becomes text. request_raw() preserves bytes in RawResponse. MultipartFieldItems means a mapping of field names to values or an iterable of (name, value) pairs. MultipartFileItems means the same structure with MultipartFile values; pairs permit repeated field names. MultipartFile(filename, content, content_type=None) takes bytes; MultipartFile.from_text(filename, content, *, content_type=None, encoding="utf-8") encodes text.
Authenticated requests accept relative paths or absolute URLs whose HTTP(S) origin exactly matches the configured API origin (scheme, normalized host, and effective port). Explicitly configured HTTP deployments are supported; a request cannot downgrade an HTTPS API. Invalid or ambiguous URLs and origin mismatches are rejected before credential acquisition. Redirects are not followed. Injected HTTP-client default headers, cookies, query parameters, and authentication are not inherited; explicit request headers and parameters still apply. request_raw() raises ValueError if a JSON body is combined with nonempty multipart fields or files. upload_to_url() sends bytes directly to a signed storage URL without API credentials. It preserves ordinary explicitly supplied storage headers and signed query parameters, but rejects Authorization, Proxy-Authorization, Cookie, and X-TP-* headers. Authorization-based storage transfers are unsupported; use the storage provider’s client for those schemes.

Resource namespaces

Use namespace attributes on the client; do not construct resource implementation classes. The top-level namespaces are auth, home, organizations, projects, mlops, datalake, skills, modules, flows, devices, db, agents, tasks, apps, hosted_apps, lakehouse, hooks, and webhooks. dashboard and canvas are aliases of home. The nested containers are home.pages, home.dashboard, home.visualizations, home.dynamic_ui; db.tables, db.rows; agents.tasks, agents.teams, agents.workspaces, agents.memories; apps.cycle, apps.ui; lakehouse.statements; and mlops.models, mlops.jobs, mlops.data, mlops.environments, mlops.hyperparameters. Containers such as db, apps, and mlops have no create, read, update, or delete methods of their own.

Authenticated user

Namespace: client.auth. whoami() identifies the authenticated user. It has no context arguments.

Home

Namespace: client.home. data() returns dashboard data for the selected project. client.dashboard and client.canvas refer to this same namespace.

Home pages

Namespace: client.home.pages. Page results are mappings. create, update, and delete write to the server. update() sends your payload without automatically fetching an updated_at value or adding an optimistic concurrency condition. A separate read and write are not atomic.

Home dashboard

Namespace: client.home.dashboard. lint() validates a supplied dashboard definition. query_dataset() requests data for one dataset; limit=500 bounds that request and use_cache=True permits caching. inspect_schema() requests its schema. These return mappings rather than typed dataset models.

Home visualizations

Namespace: client.home.visualizations. Read visualization collections and individual visualization records. list() returns a mapping, not a Python list.

Home dynamic UI

Namespace: client.home.dynamic_ui. Read and write dynamic UI records. list() can filter by thread or canvas page and omits payloads by default (include_payload=False).

Organizations

Namespace: client.organizations. List accessible organizations. No pagination parameters are accepted.

Projects

Namespace: client.projects. List accessible projects in an organization. org_id falls back to client context; no pagination parameters are accepted.

Database tables

Namespace: client.db.tables. Discover existing tables and retrieve their schema, columns, access metadata, and schema version. See the database workflow. Table creation and schema mutation are not exposed by this namespace.

Database rows

Namespace: client.db.rows. Read, query, create, and update rows in an existing table. data is a mapping of column keys to values; the SDK wraps it in a data envelope. For create_many, pass an iterable of these plain column-value mappings. Only create_many() accepts expected_schema_version. There is no row delete method.

Agents

Namespace: client.agents. List and maintain agents, discover available models and system tools, and request workspace upload metadata. list() uses limit and offset. create() and update() reject nonempty legacy knowledge_store attachments with ValueError before writing. You can still read this field in historical records. issue_workspace_upload() requests upload metadata; it does not itself transfer file bytes.

Agent tasks

Namespace: client.agents.tasks. Create and list tasks for agents or teams. Listing uses limit and offset. checkpoints() takes a thread ID and a direction, and returns messages and count metadata; it has no offset or continuation-token argument. Prefer the top-level tasks namespace for task status, messages, follow-ups, and goals.

Agent teams

Namespace: client.agents.teams. List, create, update, or delete agent teams. Team.agents and Team.subteams contain numeric IDs.

Agent workspaces

Namespace: client.agents.workspaces. List and maintain managed agent workspaces. rollout_image() requests an image rollout; track completion using the returned workspace status and the monitoring process for your deployment.

Agent memories

Namespace: client.agents.memories. Search and maintain an agent’s memories, or import and export memory items. context defaults to "all"; search and export limits apply to a single response. These methods expose no continuation token or offset. import_items() returns counts of imported and failed items, along with any errors.

Tasks

Namespace: client.tasks. list() supports filters and offset pagination; status can be a string or iterable of strings. create() creates a task, and prepare_runtime() requests runtime preparation. Methods for a known task ID such as get, update, status, messages, and goal operations do not accept context override keywords. post_message() sends a prompt and/or event; it does not return a typed completion stream. Follow-up methods return mappings; include_inactive=False is the default. Goal methods return a wrapper whose goal may be absent.

Cycle apps

Namespace: client.apps.cycle. Maintain cycle apps, change status, and retrieve logs. log() requires device_id; agent_log() supports a time range and limit. Your deployed API determines accepted status strings and validates payloads.

UI apps

Namespace: client.apps.ui. Maintain UI apps and load or save their layout. save_layout() takes an iterable of layout mappings; load_layout() returns a list of dictionaries.

Inbound hooks

Namespace: client.hooks. Manage inbound hook apps, rotate secrets, and inspect recent deliveries. invoke() addresses an endpoint key with a body and optional headers and query parameters; it does not accept organization/project override keywords. The hook configuration determines endpoint authorization. Delivery listing accepts a limit but no cursor.

Outbound webhooks

Namespace: client.webhooks. Manage outbound webhook subscriptions, discover event types, inspect deliveries, send tests, or retry one delivery. send_test() and retry_delivery() can cause outbound requests. Delivery listing accepts a limit but no cursor.

MLOps models

Namespace: client.mlops.models. Discover model assets and versions, inspect or download artifacts, request upload and download metadata, and register an asset. download() returns bytes and headers in RawResponse; file_name=None leaves file selection to the endpoint. Organization-scoped methods have no project_id parameter. Registration returns asset metadata; it does not upload model bytes.

MLOps jobs

Namespace: client.mlops.jobs. Job listing returns jobs plus a continuation token. get() and metrics() preserve the decoded endpoint result as Any. Individual job reads are organization-scoped.

MLOps data

Namespace: client.mlops.data. List data assets and versions, page through asset files, discover datastores, and request folder access metadata. files() returns items, continuation_token, and root_prefix; preserve the asset name, version, and path when following a token.

MLOps environments

Namespace: client.mlops.environments. List project MLOps environments. No pagination parameters are accepted.

MLOps hyperparameters

Namespace: client.mlops.hyperparameters. Discover architecture names and the schema for one architecture. These methods have no organization/project override parameters; schema() preserves the decoded response as Any.

Data lake

Namespace: client.datalake. Resolve paths; list a tree or one file-list page; preview, download, or upload content; and request signed access metadata. list() returns items plus a continuation token. preview_text() returns a preview model, while download_text() decodes downloaded bytes using encoding and errors. upload_text() encodes text first. Upload methods write content and return the storage response as RawResponse. Requested access durations are in minutes.

Skills

Namespace: client.skills. List, inspect, download, upload, or delete skills. download() returns RawResponse; read the downloaded bytes from its body attribute. upload() accepts multipart fields and files in the format required by your deployed API and returns SkillMetadata.

Modules

Namespace: client.modules. List or search modules, retrieve details, resolve tool schemas, and invoke tools. search() filters the fetched module list locally and truncates it to limit; it is not a server paginator. describe() resolves an ID or name and raises ValueError for missing or ambiguous identifiers. resolve() may require tool_name when a module has multiple tools. invoke_tool() resolves an identifier before invocation, preserves its original result in raw_result, and normalizes result. invoke() returns the endpoint response without that additional normalization. Invocation returns ModuleInvocationResult; use result, raw_result, or the computed normalized_result according to the endpoint response.

Flows

Namespace: client.flows. List or create flows, save a flow definition, or run a flow with inputs and optional execution settings. save() and run() return dictionaries. timeout_seconds is an optional run request parameter, separate from the client HTTP timeout.

Devices

Namespace: client.devices. List devices and modules, read module status and twins, and retrieve device tags. Status and twin results are untyped decoded values. The SDK exposes no device mutation methods here.

Pagination

Pagination settings vary by method and must be supplied explicitly. The SDK does not provide a universal paginator or automatically fetch all pages. Methods with only a limit parameter do not accept an offset or continuation token. Other lists and mapping responses have only the arguments shown in their signatures. Use bounded loops and, for token pagination, guard against repeated tokens.

CodeFlow entrypoints

These helpers are exported from thinkplatform.sdk for Python Code Flow entrypoints. They attach and inspect metadata; decorating a function does not deploy, register, or execute it.
codeflow() accepts optional JSON-schema dictionaries and a name, and returns a decorator that preserves the original function. A non-dictionary schema raises TypeError. get_codeflow_definition() returns CodeFlowDefinition for a decorated function, or None. CodeFlowContext(org_id=None, project_id=None, workspace_url=None, metadata=...) provides a lazily created client and a tools helper. Its organization and project fields are optional strings. The metadata mapping defaults to a fresh dictionary. The lazily created client uses SDK environment configuration; close ctx.client when your code owns that client’s lifecycle. CodeFlowTools(ctx) describes the tools selected for the entrypoint:
list() returns selected tool metadata; get(alias) raises KeyError when the alias is unavailable. invoke() calls the selected module tool and returns ModuleInvocationResult, preserving the original result in raw_result and normalizing result. It can raise ValueError when selected tool metadata lacks a module identifier.

Errors and retry behavior

Resource methods use the same SDK exceptions: MissingContextError for absent required context, TokenAcquisitionError for credential failures, and ThinkPlatformApiError for HTTP or transport failures. HTTP errors expose status_code and response_body; transport errors may have no status. Unexpected response structures can raise ValueError or Pydantic validation errors. Local validation and identifier resolution can raise errors before any request. The API request path retries once after an HTTP 401 by asking the credential to refresh. A static token remains the same token. There is no general retry policy for rate limits, server errors, or failed writes; check whether the endpoint can safely repeat an operation before adding retries. Direct signed-URL transfers do not refresh API credentials.

Hosted Apps

Namespace: client.hosted_apps. Available since client 0.6.133. Management calls require an authorized developer client and an enabled deployment. These methods use the client’s organization/project context; they do not accept per-call context overrides.
request_id is a UUID. publish_source() accepts a gzip context of at most 50 MiB; use source=None to advance a build that already has its source, retaining the same options and request ID. Retain the expected previous release for updates. A returned deployment is not confirmation of readiness; read publication state. See Publish a web app.

Request-bound client factory

Import from thinkplatform.sdk. The factory validates current invocation information and the configured gateway before creating a project-bound client with a 20-second request timeout. It raises TokenAcquisitionError for missing or invalid invocation configuration. Close it within the current app request; method availability does not establish delegated API permission. See Hosted App authentication.

Lakehouse statements

Namespace: client.lakehouse.statements. Available since client 0.6.133. Methods use the client’s organization/project context and the configured warehouse.
The chunk index must be nonnegative. Submission, completion and cancellation are distinct observations; inspect status and retain the statement ID when polling times out. Results can include further chunks and numeric strings. See Lakehouse statements for a complete submission/status example and the result models.