biolm.models package

Recipe builds and the locked BioLM package layout are documented in BioLM Definition Schema Reference and Model finetuning.

Submodules

biolm.models.examples module

Generate SDK usage examples for BioLM models.

class biolm.models.examples.ExampleGenerator(api_key: str | None = None, base_url: str | None = None)

Bases: object

Generate SDK usage examples for BioLM models.

async fetch_community_models() List[Dict[str, Any]]

Fetch list of available models.

Uses biolm-hub OpenAPI when in hub mode, otherwise the platform community-api-models endpoint.

async fetch_model_details(model_slug: str, code_examples: bool = False, exclude_docs_html: bool = True) Dict[str, Any] | None

Fetch detailed information for a specific model from community-api-models endpoint.

Args:

model_slug: Model slug (e.g., ‘esmfold’) code_examples: If True, include code examples in the response exclude_docs_html: If True, exclude HTML documentation

Returns:

Model details dictionary or None if not found

async generate_example(model_name: str, action: str | None = None, format: str = 'python', input_type: str | None = None) str

Generate example for a model and action.

Args:

model_name: Name of the model. action: Action name (encode, predict, generate, lookup). If None, generates for all available actions. format: Output format (‘python’, ‘markdown’, ‘rst’, ‘json’). input_type: Optional input type override.

Returns:

Formatted example string.

async get_model_schema(model_name: str, action: str) Dict[str, Any] | None

Get schema for a model and action.

Args:

model_name: Name of the model. action: Action name (encode, predict, generate, lookup).

Returns:

Schema dictionary or None if not found.

async shutdown()

Close HTTP client connections.

biolm.models.examples.ExampleGeneratorSync

alias of BlockingExampleGeneratorSync

biolm.models.examples.get_example(model_name: str, action: str | None = None, format: str = 'python', api_key: str | None = None, base_url: str | None = None) str

Generate SDK usage example for a model (synchronous).

Args:

model_name: Name of the model. action: Action name (optional, will try to detect). format: Output format (‘python’, ‘markdown’, ‘rst’, ‘json’). api_key: Optional API key. base_url: Optional base URL.

Returns:

Formatted example string.

async biolm.models.examples.get_example_async(model_name: str, action: str | None = None, format: str = 'python', api_key: str | None = None, base_url: str | None = None) str

Generate SDK usage example for a model (async).

Args:

model_name: Name of the model. action: Action name (optional, will try to detect). format: Output format (‘python’, ‘markdown’, ‘rst’, ‘json’). api_key: Optional API key. base_url: Optional base URL.

Returns:

Formatted example string.

biolm.models.examples.get_model_details(model_slug: str, code_examples: bool = False, exclude_docs_html: bool = True, api_key: str | None = None, base_url: str | None = None) Dict[str, Any] | None

Fetch detailed information for a specific model (synchronous).

Args:

model_slug: Model slug (e.g., ‘esmfold’). code_examples: If True, include code examples in the response. exclude_docs_html: If True, exclude HTML documentation. api_key: Optional API key. base_url: Optional base URL.

Returns:

Model details dictionary or None if not found.

biolm.models.examples.list_models(api_key: str | None = None, base_url: str | None = None) List[Dict[str, Any]]

List all available models from community-api-models endpoint (synchronous).

Args:

api_key: Optional API key. base_url: Optional base URL.

Returns:

List of model dictionaries.

async biolm.models.examples.list_models_async(api_key: str | None = None, base_url: str | None = None) List[Dict[str, Any]]

List all available models from community-api-models endpoint (async).

Args:

api_key: Optional API key. base_url: Optional base URL.

Returns:

List of model dictionaries.

Module contents

High-level model interface for BioLM (Model, encode/predict/generate helpers).

exception biolm.models.BuildError

Bases: RuntimeError

BioLM definition build failed.

class biolm.models.BuiltPackage(path: Path, manifest: Dict[str, Any])

Bases: object

Result of a successful build_model.

manifest: Dict[str, Any]
path: Path
class biolm.models.Model(name: str, api_key: str | None = None, **kwargs)

Bases: object

User-friendly model interface for BioLM API.

Args:

name (str): The model name (e.g., ‘esm2-8m’, ‘esmfold’). api_key (Optional[str]): API key for authentication. **kwargs: Additional arguments passed to BioLMApi.

encode(items: Any | List[Any], type: str | None = None, params: dict | None = None, progress: bool = True, progress_callback: Callable[[int, int], None] | None = None, **kwargs)

Encode using the model.

Args:

items: Single item or list of items to encode. type: Type of item (e.g., ‘sequence’). Required if items are not dicts. params: Optional parameters for the encoding. progress: If True (default), show Rich progress bar (multiple items only). progress_callback: Optional (completed, total) callback; overrides progress=True if provided. **kwargs: Additional arguments (stop_on_error, output, file_path, etc.).

Returns:

Encoding results.

generate(items: Any | List[Any], type: str | None = None, params: dict | None = None, progress: bool = True, progress_callback: Callable[[int, int], None] | None = None, **kwargs)

Generate using the model.

Args:

items: Single item or list of items to generate from. type: Type of item (e.g., ‘context’, ‘pdb’). Required if items are not dicts. params: Optional parameters for the generation. progress: If True (default), show Rich progress bar (multiple items only). progress_callback: Optional (completed, total) callback; overrides progress=True if provided. **kwargs: Additional arguments (stop_on_error, output, file_path, etc.).

Returns:

Generation results.

get_example(action: str | None = None, format: str = 'python', **kwargs) str

Get SDK usage example for this model.

Args:

action: Action name (encode, predict, generate, lookup). If None, generates for first available action. format: Output format (‘python’, ‘markdown’, ‘rst’, ‘json’). **kwargs: Additional arguments passed to ExampleGenerator (base_url).

Returns:

Formatted example string.

get_examples(format: str = 'python', **kwargs) str

Get SDK usage examples for all supported actions of this model.

Args:

format: Output format (‘python’, ‘markdown’, ‘rst’, ‘json’). **kwargs: Additional arguments passed to ExampleGenerator (base_url).

Returns:

Formatted examples string with all actions.

lookup(query: dict | List[dict], **kwargs)

Lookup using the model.

Args:

query: Query dict or list of query dicts. **kwargs: Additional arguments (raw, output, file_path).

Returns:

Lookup results.

predict(items: Any | List[Any], type: str | None = None, params: dict | None = None, progress: bool = True, progress_callback: Callable[[int, int], None] | None = None, **kwargs)

Predict using the model.

Args:

items: Single item or list of items to predict. type: Type of item (e.g., ‘sequence’, ‘pdb’). Required if items are not dicts. params: Optional parameters for the prediction. progress: If True (default), show Rich progress bar (multiple items only). progress_callback: Optional (completed, total) callback; overrides progress=True if provided. **kwargs: Additional arguments (stop_on_error, output, file_path, etc.).

Returns:

Prediction results.

exception biolm.models.RecipeError

Bases: ValueError

Invalid or unreadable BioLM definition recipe.

biolm.models.build_model(recipe_path: str | Path, *, tag: str = 'latest', name: str | None = None, api_key: str | None = None, poll_interval: float = 15.0, timeout: float | None = None, bundle: bool = False, artifact: str | None = None) BuiltPackage

Compile a recipe into a locked BioLM package under ~/.biolm/models.

Does not modify the recipe file. Overwrites an existing package dir for the same name/tag.

When bundle=True, requires a resolvable head artifact URI (from the finetune result or artifact= override), downloads into artifacts/, and sets artifact.path with load: preload.

biolm.models.encode(model_name: str, items: Any | List[Any], type: str | None = None, params: dict | None = None, **kwargs)

Quick encoding using a model.

biolm.models.generate(model_name: str, items: Any | List[Any], type: str | None = None, params: dict | None = None, **kwargs)

Quick generation using a model.

biolm.models.load_recipe(path: str | Path) Dict[str, Any]

Load and validate a BioLM definition recipe YAML.

Returns a normalized dict. The single layer includes data_path as an absolute Path to the training CSV.

biolm.models.predict(model_name: str, items: Any | List[Any], type: str | None = None, params: dict | None = None, **kwargs)

Quick prediction using a model.

We speak the language of bio-AI

© 2022 - 2026 BioLM. All Rights Reserved.