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) Wait for the job and fetch the final payload
claims_result = client.wait_for_job(
    claims_job["job_id"],
    result_endpoint="/v2/jobs/generateClaims/{job_id}",
)
print("total claims:", claims_result["total_claims"])

# 3) 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"])

# 4) 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="private",
    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])

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, …)
  • 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.2.tar.gz (10.8 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.2-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for omtx-0.3.2.tar.gz
Algorithm Hash digest
SHA256 32cf3ff2ac51d514fbcb7d987f3ed30844d26c3c582119e039f30df6be2b6237
MD5 23ac7f9fbe17bbdb6920f6d39207310a
BLAKE2b-256 65a9ae4a731594674feceac7e91332d0c4e455e58001fce145fbec61ced33252

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for omtx-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 6061d7956b3318abd7c90f28923a82e987dcb4994f80ba9ecb52e02d6b3fea34
MD5 84b88c34e8007bd2284e3f2e16e4ec4e
BLAKE2b-256 a97514fb4d502c8e2a9e7bba18a2cae8741219db530cc22280616f15309c1aee

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