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.2.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.2-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: omtx-0.4.2.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.2.tar.gz
Algorithm Hash digest
SHA256 118bb24324c33e1f61caa65f35855366040baafd8b9fcf5490bc9c041ab8e120
MD5 c041ff53d4b3b6d58290493dcf9ff093
BLAKE2b-256 b62b82519d5429b956ee7243737f4b332ba6cc518a52724420adbf5f918a3c76

See more details on using hashes here.

File details

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

File metadata

  • Download URL: omtx-0.4.2-py3-none-any.whl
  • Upload date:
  • Size: 10.8 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e5e5a866e84a333f83e8eac5ac931a0798eca786ca99d214cd7d54f7a1c5cd6b
MD5 91021945eed26f3042c6230c5f7f3197
BLAKE2b-256 ea7f804c7f7396f038daf439638c6476745d094015d930e9dff7993a03c90330

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