Skip to main content

strand-sdk

Python client for Lattice spatial proteomics from H&E. Upload H&E whole-slide images, predict spatially resolved protein-marker maps, and download the virtual mIF channels as AnnData or OME-Zarr/OME-TIFF.

📚 Full documentation: https://docs.strandai.com/sdks/python

Agent-readable API reference: https://app.strandai.com/docs/api.md · LLM index: https://app.strandai.com/llms.txt

Requires Python 3.12+.

Install

pip install strand-sdk
# or with bioinformatics extras (AnnData / zarr):
pip install "strand-sdk[anndata]"

The package also installs the strand command. It supports the same sample and run lifecycle without renaming the SDK-native verbs:

sample_id=$(strand upload biopsy.svs --mpp 0.26 | jq -r .id)
while :; do
  status=$(strand samples get "$sample_id" | jq -r .status)
  case "$status" in ready) break ;; *failed) exit 1 ;; esac
  sleep 2
done
strand predict "$sample_id" -m CD4,PanCK --dry-run
job_id=$(strand predict "$sample_id" -m CD4,PanCK | jq -r .job_id)
strand wait "$job_id" --timeout 1800
strand export "$job_id" --format ome-tiff --out result.ome.tiff --timeout 1800

Use strand cancel "$job_id" for an eligible in-flight run and strand results "$job_id" --out ./results/ for the OME-Zarr tree.

Quickstart

One blocking call runs the full pipeline: upload, submit, wait, and download.

from uuid import uuid4

from strand import Client, SampleFieldFilter

client = Client()  # reads STRAND_API_KEY; mint one at https://app.strandai.com/settings/api-keys
result = client.predict(
    "biopsy.ome.tiff",
    markers=["PanCK", "CD4", "CD45"],
    output_dir="./outputs/",
)
print(f"Used {result.credits_used} credits; wrote {len(result.marker_outputs)} markers")

Scoped sample reads and updates use one namespace:

cohort = client.samples.create_field(
    "Study cohort", "single_select",
    options=["Discovery", "Validation"],
    description="Study arm used for analysis",
)
print(cohort.key, cohort.description)
definitions = client.samples.fields()
tags_id = next(field.id for field in definitions if field.key == "tags")
page = client.samples.list(
    scope="mine",
    field=SampleFieldFilter(tags_id, "eq", "trial-042"),
)
sample_id = page.items[0].id
sample = client.samples.get(sample_id)
client.samples.patch(
    sample_id,
    name="Baseline",
    fields={"tags": ["trial-042"]},
    mpp=0.26,
)

estimate = client.predict.submit(sample_id, ["CD4", "PanCK"], dry_run=True)
job = client.predict.submit(
    sample_id,
    ["CD4", "PanCK"],
    expected_estimate=estimate,
    idempotency_key=str(uuid4()),
)

The expected_estimate/idempotency_key example requires the matching REST release and idempotency migration. This local integration candidate does not attest that the current production endpoint is upgraded. Coordinate API rollout before enabling modern MCP paid confirmation; native forms are an MCP host workflow, not a new SDK prompt or a change to legacy direct SDK submission. Uploads still stream directly to GCS, never through ChatGPT or MCP.

Persist an idempotency key until its submission response is safely recorded, and reuse it only for that exact request. Exact retries return the original job without another reservation while the job remains stored. Hard deletion of the job, its sample, organization, or account removes the mapping and ends that replay guarantee.

Uploads, model selection, async jobs, public OME-Zarr reads, OME-TIFF export, and error handling are covered in the hosted docs.

Signed whole-object results

With the matching REST endpoint deployed, whole stored objects can use an opt-in version-pinned transport; the authenticated proxy remains the default:

results = job.results()
plan = results.get_signed_files(paths, max_download_bytes=64 * 1024**2)
print(plan.total_bytes)  # complete payload preflight, no storage download
raw_files = plan.download()  # or get_files_batch(paths, transport="signed", ...)

Signed mode is raw-only. It validates every manifest before payload I/O, enforces the complete byte budget, uses a fresh unauthenticated storage client, and checks expiry, version, length and available MD5/CRC32C checksums. It does not refresh URLs or return silent partial results. Capability URLs stay in memory: never persist manifest bodies or provider error bodies. Instrument both API and storage transports when metering requests/bytes; see the hosted Python docs for the storage_client_factory guard seam and logging boundaries.

Issues & support

File bug reports and feature requests at Strand-AI/strand-sdk-python/issues, or email support@strandai.com. This repository is a generated, read-only mirror of Strand's monorepo. Pull requests opened here are overwritten by the next sync.

License

Apache 2.0

Metadata

Release files for strand-sdk 0.18.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for strand-sdk 0.18.0
File Size Uploaded Provenance Actions
strand_sdk-0.18.0.tar.gz 63.2 kB With provenance Details for strand_sdk-0.18.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for strand-sdk 0.18.0
File Interpreter ABI Platform Actions
strand_sdk-0.18.0-py3-none-any.whl Python 3 none any Details for strand_sdk-0.18.0-py3-none-any.whl

Total release size: 136.1 kB

Release files / strand_sdk-0.18.0.tar.gz

Download URL strand_sdk-0.18.0.tar.gz
Size 63.2 kB
Tags Source
SHA-256 checksum
How to use checksums
e3a63140594a446ff74ce05a88874bad286ad1f3c1663e198bbb0521a2a5254a
BLAKE2b-256 checksum
How to use checksums
ef7b5de702323e897e723aa4fd0406f087628c1963763c507f8e0f4dcbfb3c33
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.

Transparency log

Release files / strand_sdk-0.18.0-py3-none-any.whl

Download URL strand_sdk-0.18.0-py3-none-any.whl
Size 72.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e07cda03aa7b643b3e33517b76c246ed7a0e540ad8b5f7d47709bb100af89e56
BLAKE2b-256 checksum
How to use checksums
5c2a0c02c9651ac63ea5f450a43b388c9d554ebf24e603ab31c14590ddbc2941
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.

Transparency log

Security for strand-sdk 0.18.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for strand_sdk-0.18.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page