> ## 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.

# Python SDK

> Read and update ThinkPlatform resources from synchronous Python applications.

Use the `thinkplatform.sdk` client to read and update project resources from Python. See [Installation](https://docs.thinkplatform.ai/cli/get-started/installation.md) to install the CLI and SDK.

## List your projects

Sign in using a `work` profile as described in [CLI authentication](https://docs.thinkplatform.ai/cli/get-started/authentication.md), then load that profile in Python. The SDK acquires credentials through the configured provider. This example only reads resources.

```python theme={"system"}
from thinkplatform.sdk import client_from_profile

with client_from_profile("work") as client:
    for organization in client.organizations.list():
        if organization.id is not None:
            projects = client.projects.list(org_id=organization.id)
            print(organization.name, [(p.id, p.name) for p in projects])
```

`client_from_profile()` explicitly reads local CLI configuration. `client_from_env()` and direct `ThinkPlatformClient(...)` construction do not load profiles automatically. See [SDK authentication](https://docs.thinkplatform.ai/python-sdk/authentication.md) for environment configuration and explicit bearer-token credentials.

## Context and lifecycle

Set `org_id` and `project_id` when constructing the client, or pass them to resource methods that accept those keywords. Missing required context raises `MissingContextError` before a request. See [organization and project context](https://docs.thinkplatform.ai/cli/guides/context.md) for the corresponding CLI settings.

`client.with_context(org_id=..., project_id=...)` returns another client sharing the credential and HTTP connection pool. It preserves an existing context value when the corresponding argument is `None`; it does not clear it. Keep the original client open while using derived clients.

The SDK is synchronous: calls block and there is no public async client. Use `with ThinkPlatformClient(...)` or call `close()` to release its HTTP connections. The default request timeout is 30 seconds; set `timeout_seconds` at construction to change it.

## Choose a workflow

Continue with [authentication](https://docs.thinkplatform.ai/python-sdk/authentication.md), [resource methods and examples](https://docs.thinkplatform.ai/python-sdk/resources.md), [database workflows](https://docs.thinkplatform.ai/python-sdk/database.md), and [error handling](https://docs.thinkplatform.ai/python-sdk/errors.md). Use the [API reference](https://docs.thinkplatform.ai/python-sdk/api-reference.md) to look up exact method signatures and the [models reference](https://docs.thinkplatform.ai/python-sdk/models.md) to interpret typed results. The SDK and CLI support different sets of operations; some CLI commands have no equivalent SDK method.

In client 0.6.133 and later, use [Hosted Apps](https://docs.thinkplatform.ai/python-sdk/hosted-apps.md) for current-request data access and [Lakehouse statements](https://docs.thinkplatform.ai/python-sdk/lakehouse.md) for SQL submission, status and chunks. See [Upgrade and migration](https://docs.thinkplatform.ai/cli/guides/upgrading.md) for compatibility with earlier clients.


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