Skip to main content

glucoguard — Python SDK

Tiny Python client for the GlucoGuard REST API.

Install

pip install glucoguard

Or vendor it directly — the whole client is one file (glucoguard/client.py) with only requests as a dependency.

Quick start

from glucoguard import GlucoGuard

gg = GlucoGuard(api_key="sk_live_...")

result = gg.predict_diabetes(
    age=55, gender=0, bmi=30,
    systolic_bp=140, diastolic_bp=88,
    hba1c=6.5,
)

print(f"Risk: {result.risk_score}% ({result.risk_category})")
for factor in result.top_factors[:3]:
    print(f"  {factor.feature}: {factor.direction} ({factor.shap_value:+.3f})")

Batch predictions

patients = [
    {"age": 55, "gender": 0, "bmi": 30, "systolic_bp": 140, "diastolic_bp": 88},
    {"age": 35, "gender": 1, "bmi": 22, "systolic_bp": 118, "diastolic_bp": 72},
]
batch = gg.predict_batch(patients)
print(f"Processed {batch.total} patients in {batch.processing_time_ms:.0f}ms")

Webhook batch jobs

For long-running jobs, provide a webhook URL and GlucoGuard will POST the results to your endpoint when the batch completes:

job = gg.predict_batch(patients, webhook_url="https://your-server.com/glucoguard-hook")
print(job["job_id"], job["status"])  # "queued"

The webhook receives JSON with {job_id, status, completed_at, result}. The X-GlucoGuard-Job-Id header is set on the delivery request.

PDF reports

from pathlib import Path

pdf_bytes = gg.generate_pdf_report(
    patient={"age": 55, "gender": 0, "bmi": 30, ...},
    diabetes_result={"risk_score": 52.3, "risk_category": "moderate", ...},
    cvd_result={"risk_score": 38.1, "risk_category": "low", ...},
    patient_name="Jane Smith",
)
Path("report.pdf").write_bytes(pdf_bytes)

Error handling

Every failure raises GlucoGuardError with a status_code attribute.

from glucoguard import GlucoGuard, GlucoGuardError

gg = GlucoGuard(api_key="sk_live_...")
try:
    result = gg.predict_diabetes(age=55, gender=0, bmi=30, systolic_bp=140, diastolic_bp=88)
except GlucoGuardError as exc:
    if exc.status_code == 401:
        print("Bad API key")
    elif exc.status_code == 429:
        print("Rate limited — back off and retry")
    else:
        print(f"API error: {exc}")

Ops endpoints

gg.health()          # liveness probe
gg.status()          # full status with model versions and uptime
gg.model_info("diabetes")
gg.sample_patients()

Links

Built by Analytica Data Science Solutions.

Metadata

Release files for glucoguard 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for glucoguard 0.1.0
File Size Uploaded
glucoguard-0.1.0.tar.gz 5.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for glucoguard 0.1.0
File Interpreter ABI Platform
glucoguard-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 10.7 kB

Release files / glucoguard-0.1.0.tar.gz

Download URL glucoguard-0.1.0.tar.gz
Size 5.1 kB
Tags Source
SHA-256 checksum
How to use checksums
39fddcfbb630ff7cd46ca06ccfdba74f0fb7759fa2a61c94e2b3d38f40cef7af
BLAKE2b-256 checksum
How to use checksums
310e4acc720ea31291fb41c9af105d5de1bd8eec304dde1d56cdd7c1d69ee479
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.3

Release files / glucoguard-0.1.0-py3-none-any.whl

Download URL glucoguard-0.1.0-py3-none-any.whl
Size 5.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a0e6cf97f8c008133fcd1eaffa64531551530feebabe9c41a6802dd51166c43e
BLAKE2b-256 checksum
How to use checksums
55910e6c0d849e331d72817a7ea51b80fa153d1eae28c569aaecc80f0dd125a5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.3

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page