Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.strandai.com/llms.txt

Use this file to discover all available pages before exploring further.

The R SDK (strandai) provides the same surface as the Python SDK with idiomatic R conventions: all functions are prefixed strand_* and results can be returned as a SpatialExperiment for downstream Bioconductor pipelines.
The package is named strandai to avoid a CRAN clash with the unrelated strand package.

Install

# From r-universe (when published):
install.packages(
  "strandai",
  repos = c("https://strand-ai.r-universe.dev", "https://cloud.r-project.org")
)

# Or directly from the monorepo (development):
remotes::install_local("sdks/r/strandai")
To get results as a SpatialExperiment (recommended) you’ll also need:
BiocManager::install("SpatialExperiment")

Configuration

SourceArgument / variableDefault
Argstrand_client(api_key = ...)reads env
EnvSTRAND_API_KEYrequired
EnvSTRAND_BASE_URLhttps://app.strandai.com
library(strandai)
client <- strand_client()                       # reads STRAND_API_KEY
client <- strand_client(api_key = "sk-strand-…") # explicit

End-to-end

upload <- strand_upload_file(client, "biopsy.svs", progress = TRUE)

est <- strand_estimate(client, upload$id, c("CD8", "PanCK", "Ki67"))
message("will cost ~", est$estimated_credits, " credits")

job <- strand_predict(client, upload$id, c("CD8", "PanCK", "Ki67"))
status <- strand_job_wait(job, progress = TRUE)

spe <- strand_download_results(job)   # SpatialExperiment

Function reference

FunctionWhat it does
strand_client(api_key, base_url)Construct a client handle.
strand_upload_file(client, path, progress)Resumable chunked upload of a WSI to GCS.
strand_estimate(client, upload_id, markers)Compute credit cost without reserving.
strand_predict(client, upload_id, markers)Submit a prediction; reserves credits.
strand_job_get(client, job_id)Refetch a job snapshot.
strand_job_wait(job, progress, timeout)Block until terminal status.
strand_download_results(job)Return results as SpatialExperiment.

Error handling

Documented HTTP error codes map to typed conditions you can dispatch on:
HTTPCondition class
400strand_bad_request_error
401strand_auth_error
402strand_insufficient_credits_error (carries required)
404strand_not_found_error
429strand_rate_limit_error (carries retry_after)
tryCatch(
  strand_predict(client, upload$id, markers),
  strand_insufficient_credits_error = function(e) {
    message("need ", e$required, " credits; top up the org first.")
  },
  strand_rate_limit_error = function(e) {
    message("wait ", e$retry_after, "s before retrying.")
  }
)

See also