codon-ai
Python client for Codon AI Services: around 150 biomedical AI models — structure prediction, embeddings, co-folding, inverse folding, genomics scoring — behind one API, run on shared GPU hardware.
pip install codon-ai
Python 3.10 or newer, and two dependencies, pydantic and httpx. No model weights, no ML stack.
You need a Codon account — Codon is Karolinska Institutet's research AI
platform — and an API key from it. Without one you can still build and
validate inputs locally, since the models ship in the package, but nothing
reaches the service, not even the catalog. New tools arrive with new releases, so
pip install -U codon-ai from time to time.
Using it
from codon.ai_services import ESMFold2, ESMFold2Config
fold = ESMFold2(ESMFold2Config(model_checkpoint="esmfold2-fast"))
output, stats = fold.run(complexes=[["MKTAYIAKQRQISFVKSHFSRQ"]])
output.structures[0]
stats.price_usd, stats.runtime_seconds
The config goes in the constructor and the input goes to run, so one
configured tool serves a whole batch:
for sequence in sequences:
output, stats = fold.run(complexes=[[sequence]])
run blocks. To start many jobs at once, submit them and collect later:
jobs = [fold.submit(complexes=[[s]]) for s in sequences]
for job in jobs:
output, stats = job.result()
An input model can be passed positionally instead, for reusing one or building it from a dict:
from codon.ai_services import ESMFold2Input
data = ESMFold2Input(complexes=[["MKTAYIAKQRQISFVKSHFSRQ"]])
output, stats = fold.run(data)
Pointing it at Codon
Two environment variables, and no credential in your code:
export CODON_AI_SERVICES_URL="https://codon.mbb.ki.se/ai-services-api"
export CODON_AI_SERVICES_KEY="codon-ais-..." # API Keys → Codon AI Services
Inside a Codon capsule the URL is already set and there is no key to set: the sandbox holds the credential on your behalf. The same script therefore runs unchanged on your laptop and inside Codon.
What a call costs
Tools are priced by the memory a job holds and how long it holds it. stats
carries what you were actually charged, alongside max_price_usd, the
ceiling reserved when the job was submitted. Failed and timed-out jobs are
never charged.
timeout_s is the real cost ceiling, because the charge cannot exceed the
rate times the memory times the deadline:
fold = ESMFold2(config, timeout_s=600)
It sits on the tool rather than on the call because run and submit take
the tool's own field names, and a parameter of the client's own beside them
would share that namespace.
When something goes wrong
Every failure raises something you can act on, carrying the server's own message:
| Exception | What to do |
|---|---|
BudgetExceeded |
The message names which cap and where to raise it |
NoWorkerAvailable |
Retry later; nothing about the request is wrong |
TooLargeForAnyWorker |
Choose a smaller checkpoint |
ToolTimeout |
Retry with a larger timeout_s, not the same one |
ToolFailed |
The tool itself raised; the message is its error |
TooManyJobs |
Too many in flight; wait for some to finish |
A job whose worker died mid-run is retried once automatically, since nothing about the request caused it. Nothing else is retried: the same input would fail the same way and only spend another queue slot.
Browsing what is available
from codon.ai_services import list_tools, describe
for tool in list_tools():
print(tool["tool_key"], tool["price_usd_per_gb_hour"])
describe("esmfold2-prediction")["readme"]
Entries with kind == "llm" are local language models rather than tools.
They have no input or config classes here: call them with the Anthropic SDK
against <codon>/ai-services-api/llm, as their catalog page shows.
Where the models come from
The input, config and output models are generated from the service folders
under containers/ai_services_worker/services/, which are what Codon's AI
Services workers actually run. The version is the date of the snapshot.
This package does not run tools locally. It submits jobs to Codon AI Services and reads the results back; the models are here so mistakes are caught before a job is submitted.
Licence
MIT.
Metadata
Release files for codon-ai 2026.9.11
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| codon_ai-2026.9.11.tar.gz | 462.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| codon_ai-2026.9.11-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 583.2 kB
Release files / codon_ai-2026.9.11.tar.gz
| Download URL | codon_ai-2026.9.11.tar.gz |
|---|---|
| Size | 462.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
66d2540a31a92312ee50e07f5cb614d25072204a9e7ae55180349b096de5afd6
|
|
BLAKE2b-256 checksum How to use checksums |
7567c6a909d1a9dbb1d13e56650e4e728f84870b30425c312ad7e5bbdfc3e755
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 11, 2026.
Transparency logRelease files / codon_ai-2026.9.11-py3-none-any.whl
| Download URL | codon_ai-2026.9.11-py3-none-any.whl |
|---|---|
| Size | 121.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
667c4c58b451b53bdb9a45d936b95e3a0a737b5987a961d594f30417d97fb08a
|
|
BLAKE2b-256 checksum How to use checksums |
3b158af87b1ae4b89e8c65522e6053c9a209a6fce2e8bcd2f0f7a171da0d741b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 11, 2026.
Transparency log