Skip to main content

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=[{"chains": [{"sequence": "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=[{"chains": [{"sequence": sequence}]}])

run blocks. To start many jobs at once, submit them and collect later:

jobs = [fold.submit(complexes=[{"chains": [{"sequence": 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=[{"chains": [{"sequence": "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/apiproxy/ai-services"
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>/apiproxy/ai-services/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.11.11

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

Source distribution (sdist)

Source distribution for codon-ai 2026.11.11
File Size Uploaded Provenance Actions
codon_ai-2026.11.11.tar.gz 490.5 kB With provenance Details for codon_ai-2026.11.11.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for codon-ai 2026.11.11
File Interpreter ABI Platform Actions
codon_ai-2026.11.11-py3-none-any.whl Python 3 none any Details for codon_ai-2026.11.11-py3-none-any.whl

Total release size: 626.1 kB

Release files / codon_ai-2026.11.11.tar.gz

Download URL codon_ai-2026.11.11.tar.gz
Size 490.5 kB
Tags Source
SHA-256 checksum
How to use checksums
97dea91e4b2bfa8e39aa8dbb4db39938f0e781086b10014505c3471076ddb825
BLAKE2b-256 checksum
How to use checksums
e1e5bd371aa7857a2584c909077b007cc41d8e7021e2f0db059a3ee0c8b1f5b0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 13, 2026.

Transparency log

Release files / codon_ai-2026.11.11-py3-none-any.whl

Download URL codon_ai-2026.11.11-py3-none-any.whl
Size 135.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7d8f1123d6b5339f8a86625d11f75e01e17313b34a98e1100bb3588af358dcc0
BLAKE2b-256 checksum
How to use checksums
775c6ce342704827b972ef1f5821b53cce9e44bec4b2e2f68eb233c7f1b573c0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 13, 2026.

Transparency log

Security for codon-ai 2026.11.11

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for codon_ai-2026.11.11.tar.gz

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 Nov 13, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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