Skip to main content

Ginkgo's AI model API client

Work in progress: this repo was just made public and we are still working on integration

A python client for Ginkgo's AI model API, to run inference on public and Ginkgo-proprietary models. Learn more in the Model API announcement.

Prerequisites

Register at https://models.ginkgobioworks.ai/ to get credits and an API KEY (of the form xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx). Store the API KEY in the GINKGOAI_API_KEY environment variable.

Installation

Install the python client with pip:

pip install ginkgo-ai-client

Usage:

Note: This is an alpha version of the client and its interface may vary in the future.

Example : masked inference with Ginkgo's AA0 model

The client requires an API key (and defaults to os.environ.get("GINKGOAI_API_KEY") if none is explicitly provided)

from ginkgo_ai_client import GinkgoAIClient, MaskedInferenceQuery

client = GinkgoAIClient()
model = "ginkgo-aa0-650M"

query = MaskedInferenceQuery(sequence="MPK<mask><mask>RRL", model=model)
prediction = client.send_request(query)
# prediction.sequence == "MPKRRRRL"

It is also possible to send multiple queries at once, and even recommended in most cases as these will be processed in parallel, with appropriate scaling from our servers. The send_batch_request method returns a list of results in the same order as the queries:

sequences = ["MPK<mask><mask>RRL", "M<mask>RL", "MLLM<mask><mask>R"]
queries = [MaskedInferenceQuery(sequence=seq, model=model) for seq in sequences]
predictions = client.send_batch_request(queries)
# predictions[0].sequence == "MPKRRRRL"

For large datasets (say, 100,000 queries), one can also send multiple batches of requests, then iterate over the results as they are ready. Note that the order in which the results are returned is not guaranteed to be the same as the order of the queries, therefore you should make sure the queries have a query_name attribute that will be used to identify the results.

from ginkgo_ai_client import MeanEmbeddingQuery
queries = MeanEmbeddingQuery.iter_from_fasta("sequences.fasta", model=model)
for batch_results in client.send_requests_by_batches(queries, batch_size=1000):
    for result in batch_results:
        print(result.query_name, result.embedding)

Changing the model parameter to esm2-650M or esm2-3b in this example will perform masked inference with the ESM2 model.

Example : embedding computation with Ginkgo's 3'UTR language model

from ginkgo_ai_client import GinkgoAIClient, MeanEmbeddingQuery

client = GinkgoAIClient()
model = "ginkgo-maskedlm-3utr-v1"

# SINGLE QUERY

query = MeanEmbeddingQuery(sequence="ATTGCG", model=model)
prediction = client.send_request(query)
# prediction.embedding == [1.05, -2.34, ...]

# BATCH QUERY

sequences = ["ATTGCG", "CAATGC", "GCGCACATGT"]
queries = [MeanEmbeddingQuery(sequence=seq, model=model) for seq in sequences]
predictions = client.send_batch_request(queries)
# predictions[0].embedding == [1.05, -2.34, ...]

Available models

See the example folder and reference docs for more details on usage and parameters.

Model Description Reference Supported queries Versions
ESM2 Large Protein language model from Meta Github Embeddings, masked inference 3B, 650M
AA0 Ginkgo's protein language model Announcement Embeddings, masked inference 650M
3UTR Ginkgo's 3'UTR language model Preprint Embeddings, masked inference v1
Promoter-0 Ginkgo's promoter activity model Coming soon Promoter activity accross tissues v1
ABdiffusion Antibody diffusion model Coming soon Unmasking v1
LCDNA Long-context DNA diffusion model Coming soon Unmasking v1

License

This project is licensed under the MIT License. See the LICENSE file for details.

Releases

To release a new version to PyPI:

  • Make sure the changelog is up to date and the top section reads Unreleased.
  • Increment the version with the bumpversion workflow in Actions - it will update the version everywhere in the repo and create a tag.
  • If all looks good, create a release for the tag, it will automatically publish to PyPI.

Release files for ginkgo-ai-client 0.9.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 ginkgo-ai-client 0.9.0
File Size Uploaded
ginkgo_ai_client-0.9.0.tar.gz 19.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ginkgo-ai-client 0.9.0
File Interpreter ABI Platform
ginkgo_ai_client-0.9.0-py3-none-any.whl Python 3 none any Details

Total release size: 35.1 kB

Release files / ginkgo_ai_client-0.9.0.tar.gz

Download URL ginkgo_ai_client-0.9.0.tar.gz
Size 19.1 kB
Tags Source
SHA-256 checksum
How to use checksums
b81754142a72c9b2b99d4d75664fc3e47c3c34dc4139bcce184abf28f6d0b1c7
BLAKE2b-256 checksum
How to use checksums
2ba19ccc3a23b19e6913037529bd85723e5c2062c565a8a71f2bac41f1574869
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

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 Mar 10, 2025.

Transparency log

Release files / ginkgo_ai_client-0.9.0-py3-none-any.whl

Download URL ginkgo_ai_client-0.9.0-py3-none-any.whl
Size 16.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b97188318b312926e0d6db8236eec31e2d9fa8e7f0fbfd6b5baef0ee54b64de3
BLAKE2b-256 checksum
How to use checksums
91673a0922fda7c7d62886c04564685021ab3ef1cbcc621cc24b94f9c65b3a22
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

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 Mar 10, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

0.9.0 This release

2 release files

0.8.0

2 release files

0.7.0

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.2.0

2 release files

0.1.0

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