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.jobs.status(claims_job["job_id"])
print(job_record["status"])

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

# 4) Kick off report synthesis (returns job metadata)
report_job = client.diligence.synthesize_report(gene_key="acad8")
report = client.jobs.wait(
    report_job["job_id"],
    result_endpoint="/v2/jobs/synthesizeReport/{job_id}",
)
print(report["sections"][0]["title"])

# 5) Deep research job (poll with jobs.wait when ready)
deep_job = client.diligence.deep_research(
    query="CRISPR applications in cancer therapy",
)
deep = client.jobs.wait(
    deep_job["job_id"],
    result_endpoint="/v2/jobs/deep-research/{job_id}",
)
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:
        job = client.diligence.synthesize_report(gene_key="acad8")
        report = client.jobs.wait(
            job["job_id"], result_endpoint="/v2/jobs/synthesizeReport/{job_id}"
        )
    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.binders.unlock(protein_uuid="aa11bb22", gene_name="KRAS")

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

df = stream.to_dataframe()
print("Rows:", len(df))

Gene key discovery

from omtx import OMTXClient

client = OMTXClient()
gene_keys = client.diligence.list_gene_keys()
print(gene_keys["items"][:5])

Retries & idempotency

from omtx import OMTXClient

client = OMTXClient()

# Every POST call receives a timestamp-based idempotency key automatically.
claims = client.diligence.generate_claims(
    target="BRAF",
    prompt="Summarize inhibitors",
)

Available helper methods

  • diligence.generate_claims(target, prompt)
  • diligence.synthesize_report(gene_key)
  • diligence.deep_research(query)
  • diligence.list_gene_keys() (fetches all keys)
  • jobs.history(...), jobs.status(job_id), jobs.wait(job_id, …)
  • binders.unlock(protein_uuid, gene_name=None), binders.list_unlocks()
  • binders.selectivity.stream|stats|cost_estimate(...)
  • binders.public/private/community/decoys.stream|cost_estimate(...)
  • pricing.manifest(), pricing.cost_estimate(...)
  • gateway.status()
  • users.profile()

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.4.1.tar.gz (14.2 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.4.1-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for omtx-0.4.1.tar.gz
Algorithm Hash digest
SHA256 35ab2198fc59e701861a8370d0448424635b973856d1dbb84004a43840294cf7
MD5 6eaa3532a79adb68511abefe27c78e8e
BLAKE2b-256 60f1056bb131d6a2c24dd70ea48983aea09d4ac2a13eb8b5c93e5ca35e60dfc7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: omtx-0.4.1-py3-none-any.whl
  • Upload date:
  • Size: 10.7 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.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 69459f39ec2a94d913777481bb1939a4441bae4d3d8484cea70fb8f91ae4b148
MD5 516e9e78d0d99d7021967e55d5c6807f
BLAKE2b-256 c8a62a41a318130af13a11dac18e8b17bfa7896c398edb5510003cc01f1194a2

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