Learn how to quickly access the ProGen2 models using REST APIs, for rapid and semi-directed protein generation.
ProGen2 API¶
ProGen2, with models up to 6.4B parameters, is adept at generating viable protein sequences and predicting their fitness. It's utilized in protein design, trained on data from genomic and metagenomic sources.
Postman API Docs |
Python SDK Docs |
Github Link |
Paper Link |
Set Your API Token¶
In order to use the BioLM API, you need to have a token. You can get one from the User API Tokens page.
Paste the API token you generated in the cell below, as the value
of the variable BIOLMAI_TOKEN
.
BIOLMAI_TOKEN = " " # !!! YOUR API TOKEN HERE !!!
API Call with Python requests¶
We need to make sure we have the Python requests
module loaded first.
try:
# Install packages to make API requests in JLite
import micropip
await micropip.install('requests')
await micropip.install('pyodide-http')
# Patch requests for in-browser support
import pyodide_http
pyodide_http.patch_all()
except ModuleNotFoundError:
pass # Won't be using micropip outside of JLite
import requests
from IPython.display import JSON # Helpful UI for JSON display
ProGen2 Medium¶
SLUG = 'progen2-medium'
ACTION = 'generate'
url = f"https://biolm.ai/api/v2/{SLUG}/{ACTION}/"
headers = {
"Content-Type": "application/json",
"Authorization": f"Token {BIOLMAI_TOKEN.strip()}",
}
data = {
"params": {
"temperature": 0.1, # Temperature
"top_p": 0.6, # Nucleus sampling probability
"num_samples": 2, # Number of proteins to generate
"max_length": 175 # Max length of generated proteins
},
"items": [
{
"context": "MA" # Starting amino acid(s) for protein
}
]
}
# Make the request
response = requests.post(
url=url,
headers=headers,
json=data,
)
result = response.json()
result
We can view this a bit more easily below:
JSON(result)
ProGen2 OAS¶
import requests
SLUG = 'progen2-oas'
ACTION = 'generate'
url = f"https://biolm.ai/api/v2/{SLUG}/{ACTION}/"
headers = {
"Content-Type": "application/json",
"Authorization": f"Token {BIOLMAI_TOKEN.strip()}",
}
data = {
"params": {
"temperature": 0.7, # Temperature
"top_p": 0.6, # Nucleus sampling probability
"num_samples": 2, # Number of proteins to generate
"max_length": 175 # Max length of generated proteins
},
"items": [
{
"context": "EVQ" # Starting amino acids for Antibody
}
]
}
# Make the POST request
response = requests.post(
url=url,
headers=headers,
json=data,
)
result = response.json()
result
JSON(result)
ProGen2 BFD90¶
import requests
SLUG = 'progen2-bfd90'
ACTION = 'generate'
url = f"https://biolm.ai/api/v2/{SLUG}/{ACTION}/"
headers = {
"Content-Type": "application/json",
"Authorization": f"Token {BIOLMAI_TOKEN.strip()}",
}
data = {
"params": {
"temperature": 0.7, # Temperature
"top_p": 0.6, # Nucleus sampling probability
"num_samples": 2, # Number of proteins to generate
"max_length": 175 # Max length of generated proteins
},
"items": [
{
"context": "M" # Starting amino acid(s) for protein
}
]
}
# Make the request
response = requests.post(
url=url,
headers=headers,
json=data,
)
result = response.json()
result
JSON(result)
Next Steps¶
Check out additional tutorials at jupyter.biolm.ai, or head over to our BioLM Documentation to explore additional models and functionality.
See more use-cases and APIs on your BioLM Console Catalog.¶
BioLM hosts deep learning models and runs inference at scale. You do the science.¶
Enzyme Engineering | Antibody Engineering | Biosecurity |
Single-Cell Genomics | DNA Sequence Modelling | Finetuning |
Contact us to learn more.¶