cognichem-client is the official Python client for the CogniChem API: jobs, workflows, artifacts, events, the wallet, science lookups, reference papers, utilities, inference, and the Assistant. It needs Python 3.10 or later. Source and examples: cognichem-client-python (Apache 2.0).
pip install cognichem-clientVersion 1.1 or later covers the whole current API; the samples in these docs assume it.
Authenticate
from cognichem_client import CogniChem
client = CogniChem.from_env() # reads COGNICHEM_API_KEY (and COGNICHEM_ACCESS_TOKEN, COGNICHEM_BASE_URL)
client = CogniChem(api_key="...") # or pass a key directlyAPI key management and the Assistant need an access token instead of a key (Authentication):
client = CogniChem()
client.auth.login_email("[email protected]", "your-password") # stores the token on the clientWhat's in it
| Resource | Methods |
|---|---|
client.jobs | estimate, submit, submit_many, status, info, list, wait, run, result, result_many, cancel, delete |
client.workflows | validate, estimate, templates, template, node_ports |
client.workflows.runs | create, list, get, artifacts, resume, cancel, delete, wait, run |
client.workflows.definitions | create, list, get, update, delete, download, share, unshare, get_shared, fork_shared, versions, get_version, restore_version |
client.artifacts | list, usage, upload, get, download, delete |
client.events | list, listen |
client.wallet | balance |
client.lookup | pubchem, chembl, targets, uniprot, pdb, properties |
client.reference | search, get, neighborhood |
client.utils | submit, status, result, wait, run, list, cancel, delete |
client.inference | submit, submit_batch, status, result, wait, run, list, cancel, delete |
client.inference.models.mpnn | public, user, delete |
client.usage | limits |
client.chat (access token) | estimate, send, stream, stop, spend_cap, continue_spend_cap, sessions.*, proposals.* |
client.auth, client.api_keys | login, check, refresh, logout; list, create, get, update, rotate, delete keys |
AsyncCogniChem has the same methods for asyncio. Every operation in the API reference shows its SDK call in the Python tab.
Helpers
run(jobs, utilities, inference, workflow runs) submits and waits in one call;waitpolls with backoff until the work stops.artifact_ref(id, port)builds an{"$artifact": …}reference for job payloads and workflow params.events.listen()long-polls completion events and drops repeats.- Idempotency: writes send a fresh
Idempotency-Keyautomatically. Passidempotency_key=to reuse one across your own retries (Retry safely).
Errors
Failed calls raise subclasses of CogniChemError (BadRequestError, AuthenticationError, PaymentRequiredError, ForbiddenError, NotFoundError, ConflictError, GoneError, PayloadTooLargeError, ValidationError, RateLimitError, ServerError) carrying the problem detail's fields, including code (the problem type, such as insufficient-scope) and retryability. wait and run raise PollTimeoutError, ProcessFailedError, or ProcessCancelledError. See Handle errors.
Notes
client.auth.refreshuses the deprecatedGET /auth/refresh, which may be removed after 2027-01-01 (Versioning).- Workflow template objects don't include the newer
titleandfamilyfields yet; useid,name, andsummary.