Skip to main content

Python SDK for Om

Project description

OMTX Python SDK

Lightweight helper for the OM Gateway. Queue diligence jobs, poll for results, and unlock/stream private data sets.

Installation

pip install omtx

Quick start

from omtx import OMTXClient

client = OMTXClient()  # picks up OMTX_API_KEY

# 1) Generate claims (returns 202 + job_id)
claims_job = client.diligence_generate_claims(
    target="BRAF",
    prompt="Summarize known inhibitors"
)

# 2) Check status immediately (returns metadata + payload when ready)
job_record = client.job_status(claims_job["job_id"])
print(job_record["status"])

# 3) Optionally wait for completion (defaults to a 1 hour timeout)
claims_result = client.wait_for_job(
    claims_job["job_id"],
    result_endpoint="/v2/jobs/generateClaims/{job_id}",
)
print("total claims:", claims_result["total_claims"])

# 4) Resynthesize report using a gene_key, auto-waiting for completion
report = client.diligence_synthesize_report(
    gene_key="acad8",
    wait=True,
)
print(report["sections"][0]["title"])

# 5) Deep research with automatic polling
deep = client.diligence_deep_research(
    query="CRISPR applications in cancer therapy",
    wait=True,
)
print(deep["final_report"][:400])

Setup

Get an API key

  1. Sign up at https://omtx.ai
  2. Generate an API key from the dashboard

Provide the API key

export OMTX_API_KEY="your-api-key"

The SDK defaults to the hosted gateway at https://api-gateway-129153908223.us-central1.run.app. If you need a different deployment, pass base_url explicitly (or set OMTX_BASE_URL).

Or pass both API key and base URL when constructing the client:

from omtx import OMTXClient

client = OMTXClient(
    api_key="your-api-key",
    base_url="https://api-gateway-129153908223.us-central1.run.app",
)

Usage examples

Error handling and context manager

from omtx import OMTXClient, InsufficientCreditsError, OMTXError

with OMTXClient() as client:
    try:
        report = client.diligence_synthesize_report(gene_key="acad8", wait=True)
    except InsufficientCreditsError:
        print("Add credits before running resynthesis jobs.")
    except OMTXError as exc:
        print(f"Gateway call failed: {exc}")

Selective data access

from omtx import OMTXClient

client = OMTXClient()

# 1) Unlock a dataset (consumes one Access Credit)
client.access_unlock(protein_uuid="aa11bb22", gene_name="KRAS")

# 2) Stream the private dataset
stream = client.data_access_selective_stream(
    dataset="selectivity",
    protein_uuid="aa11bb22",
    limit=100_000,
    fmt="csv",
)

print("Rows:", stream.headers.get("X-Row-Count"))
with open("kras_selective.csv", "wb") as fh:
    for chunk in stream.iter_bytes():
        fh.write(chunk)
stream.close()

Gene key discovery

from omtx import OMTXClient

client = OMTXClient()
gene_keys = client.diligence_list_gene_keys(min_true=5)
print(gene_keys["items"][:5])

Retries & idempotency

from omtx import OMTXClient

client = OMTXClient()

# Every POST call receives a timestamp-based idempotency key automatically.
# Provide `idempotency_key=` when you need deterministic retries.
claims = client.diligence_generate_claims(
    target="BRAF",
    prompt="Summarize inhibitors",
    idempotency_key="braf-inhibitors-run-1",
)

Available helper methods

  • diligence_generate_claims(target, prompt, wait=False)
  • diligence_synthesize_report(gene_key, wait=False)
  • diligence_deep_research(query, wait=False, …)
  • diligence_list_gene_keys(min_true=1, …)
  • jobs_history(...), job_status(job_id), wait_for_job(job_id, …)
  • wait_for_job uses a 3,600 second default timeout (set timeout=None to wait indefinitely)
  • access_unlock(protein_uuid, gene_name=None), list_access_unlocks()
  • data_access_selective_stream(...), data_access_points_stream(...)
  • data_access_selective_stats(...), data_access_points_stats(...)
  • credits(), health()

Requirements

  • Python 3.9 or higher
  • An OMTX API key

Support

License

MIT License – see LICENSE for details.

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

omtx-0.3.4.tar.gz (12.9 kB view details)

Uploaded Source

Built Distribution

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

omtx-0.3.4-py3-none-any.whl (10.0 kB view details)

Uploaded Python 3

File details

Details for the file omtx-0.3.4.tar.gz.

File metadata

  • Download URL: omtx-0.3.4.tar.gz
  • Upload date:
  • Size: 12.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.13

File hashes

Hashes for omtx-0.3.4.tar.gz
Algorithm Hash digest
SHA256 83c3b7f4692fd2ae608a706771aa2d7a6eafb551a9de393dec7c22b1ed8d948d
MD5 4c861ad377c99ebe358c0bb2680a790b
BLAKE2b-256 fd07744627efd2830aca09eba6e656c4c855c91cdce65f65d2aea15d7eba83ab

See more details on using hashes here.

File details

Details for the file omtx-0.3.4-py3-none-any.whl.

File metadata

  • Download URL: omtx-0.3.4-py3-none-any.whl
  • Upload date:
  • Size: 10.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.13

File hashes

Hashes for omtx-0.3.4-py3-none-any.whl
Algorithm Hash digest
SHA256 7cd0654a7ceabaab54d2eea9ea3df5c50bd8b2d03181d2c49527414e98a84be4
MD5 32c034b66f5fa3bf559ef35acca58552
BLAKE2b-256 e0a5c4224ec4f661ac7f8315c77413abfc242920d2033c36299477d9be70a89b

See more details on using hashes here.

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