Skip to main content

Official Python client for the Strand Platform API — H&E → multiplex protein inference.

Project description

strand-sdk

Python client for the Strand Platform — H&E → multiplex protein inference.

Agent-friendly docs: The full API reference is published as Markdown at https://app.strandai.com/docs/api.md, and the LLM index lives at https://app.strandai.com/llms.txt.

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

If your environment can't reach PyPI, you can install directly from the repository as a fallback:

pip install "git+https://github.com/Strand-AI/strand-sdk-python.git"

Quickstart

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

from strand import Client

client = Client(api_key="sk-strand-...")
result = client.predict(
    "biopsy.ome.tiff",
    markers=["HER2", "CD8", "PD1"],
    output_dir="./outputs/",
)
print(f"Used {result.credits_used} credits; wrote {len(result.marker_outputs)} markers")

client.predict(...) returns a PredictResult with job_id, status, credits_used, marker_outputs (paths under output_dir), and results (a JobResults handle for selective reads). It raises JobFailedError if the job fails, JobTimeoutError if the deadline elapses, and surfaces InsufficientCreditsError / RateLimitError on submit issues.

Pass on_progress=lambda stage, frac: ... to follow the four stages ("upload", "submit", "wait", "download").

Lower-level primitives

client.predict is also a namespace, so the underlying steps stay available for fine-grained control:

upload = client.uploads.upload_file("slide.svs")
estimate = client.predict.estimate(upload.id, markers=["CD3", "CD8", "Ki67"])
print(f"Will cost ≈ {estimate.estimated_credits} credits")

job = client.predict.submit(upload.id, markers=["CD3", "CD8", "Ki67"])
job.wait()                                    # blocks until terminal status
adata = job.download_results()                # AnnData

Configuration

Source Variable / argument Default
Env STRAND_API_KEY required
Env STRAND_BASE_URL https://app.strandai.com
Arg Client(api_key=..., base_url=..., timeout=..., max_retries=...)

Layout

src/strand/
  __init__.py        public surface re-exports
  _client.py         Client (top-level)
  _uploads.py        uploads namespace (incl. resumable chunked upload helper)
  _predict.py        predict namespace — `client.predict(...)` (full pipeline) + `.estimate` / `.submit`
  _jobs.py           Job (wait / stream_events / download_results)
  _results.py        OME-Zarr v3 download + AnnData conversion
  _models.py         user-facing snake_case dataclasses
  _http.py           internal httpx wrapper with typed error mapping
  _errors.py         typed exceptions
openapi.json         pinned snapshot of the platform spec (drift-check)

Verifying against the platform OpenAPI spec

Transport is hand-written for ergonomic snake_case fields and AnnData integration. To check the SDK against an updated spec:

# regenerate a reference client and diff the request/response surface
uv tool run --from "openapi-python-client>=0.21" --with "click<8.2" \
    openapi-python-client generate \
    --path openapi.json \
    --output-path /tmp/strand-sdk-ref \
    --meta none --overwrite

To refresh openapi.json itself against a live server:

curl https://app.strandai.com/api/v1/openapi.json -o openapi.json
# or against local dev:
# curl http://localhost:3000/api/v1/openapi.json -o openapi.json

Development

uv sync --all-extras
uv run pytest
uv run ruff check src tests
uv run mypy src

Issues & contributing

File bug reports and feature requests at Strand-AI/strand-sdk-python/issues.

We don't accept external pull requests on the SDK at this time. If you'd like to contribute or have ideas you'd like to discuss, email support@strandai.com.

License

Apache 2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

strand_sdk-0.2.0.tar.gz (18.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

strand_sdk-0.2.0-py3-none-any.whl (24.6 kB view details)

Uploaded Python 3

File details

Details for the file strand_sdk-0.2.0.tar.gz.

File metadata

  • Download URL: strand_sdk-0.2.0.tar.gz
  • Upload date:
  • Size: 18.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for strand_sdk-0.2.0.tar.gz
Algorithm Hash digest
SHA256 752aee59702fde5e2ff6ceb17c257e2a26c25f2ac1a21a446cff4500a27e4ef6
MD5 d230593705a949b752960c5a0b21cde6
BLAKE2b-256 ef5e0674a9d9ad81658a9a16214967aa80d00871507f22899afb3efc52bb681a

See more details on using hashes here.

Provenance

The following attestation bundles were made for strand_sdk-0.2.0.tar.gz:

Publisher: sdks-publish.yml on Strand-AI/strand-official

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file strand_sdk-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: strand_sdk-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 24.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for strand_sdk-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 53858061244024dcc25f918cd181dd3c2661f8d0641066129e4b18dfa67f43a6
MD5 2108493928b5f8a75db1b0eb1188fc26
BLAKE2b-256 79d287ca027e5ce26439ae12f14d27949ad35a247267819bc600aa1de3d16336

See more details on using hashes here.

Provenance

The following attestation bundles were made for strand_sdk-0.2.0-py3-none-any.whl:

Publisher: sdks-publish.yml on Strand-AI/strand-official

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page