Skip to main content

Python client

The integration kit ships a single-file Python client, gi_client.py. It wraps the REST API with bearer authentication, the unified {data, meta} / {error} response envelope, and a polling helper for async jobs. Its only dependency is requests.

The client is optional. Every call it makes is a plain HTTP request you can issue yourself (see Getting started). It exists to remove the boilerplate of auth headers, error handling, and async polling.

Get the client

The client lives in the client/ directory of the integration kit:

  • gi_client.py — the client itself.
  • quickstart.py — a runnable script that exercises every task with bundled biological sequences.

Both files are also on GitHub at the client/ directory.

To get the whole kit, including the client, the quickstart, and the bundled sequences/ fixtures:

curl -L https://docs.genomicintelligence.ai/integration-kit.tar.gz | tar -xz
cd integration-kit/

Drop gi_client.py into your project and import it:

from gi_client import Client, GIError

What it gives you

  • Client(api_key, base_url=..., timeout=...) — a session configured with your bearer key.
  • predict(task, sequence, sequence_name, model=None, options=None) — synchronous inference, returns the full {data, meta} body.
  • submit_async(...) — submit with Prefer: respond-async, returns a job_id.
  • wait_for_job(job_id, poll_interval=2.0, on_progress=None) — poll until the job reaches a terminal state.
  • list_models(task), list_jobs(limit=...), health() — supporting calls.
  • GIError — raised on any non-2xx response, carrying the envelope's code, message, request_id, and details so you can branch on code rather than HTTP status alone.

Minimal usage

Set your key and base URL, then call a task:

import os
from gi_client import Client, GIError

client = Client(api_key=os.environ["GI_API_KEY"])

# Synchronous prediction
body = client.predict("promoter", sequence, sequence_name)
meta = body["meta"]
print(meta["model"], meta["inference_time_ms"], "ms")

# Expression takes a cell-type description via options
body = client.predict(
"expression",
sequence=tss_window,
sequence_name="HBB",
options={
"description": (
"assay term name is polyA plus RNA-seq. "
"biosample summary is Homo sapiens K562."
),
},
)
pred = body["data"]["prediction"]
print(pred["expression_log_tpm"], "log(TPM+1)")

For longer-running tasks such as annotation, submit asynchronously and poll:

try:
job_id = client.submit_async("annotation", sequence, sequence_name)
body = client.wait_for_job(job_id, poll_interval=2.0)
transcripts = body["data"].get("transcripts", [])
print(f"done — {len(transcripts)} transcripts")
except GIError as exc:
print(f"[{exc.code}] {exc.message} (request_id={exc.request_id})")

The bundled quickstart.py runs this end to end across every task using the real biological sequences in the kit's sequences/ directory:

pip install -r requirements.txt
export GI_API_KEY=gi_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
python quickstart.py

See Getting started for the request and response shapes, and the reference for error codes and limits.