Benchling integration

From aipoch/medical-research-skills · View interactive version

Benchling integration is an AI agent skill from the GitHub repository aipoch/medical-research-skills. Integrate with the Benchling R&D platform when you need to programmatically manage registry entities, inventory, ELN entries, workflows, events, or data warehouse analytics via API/SDK.

How to use this skill

Skill file

Source: https://github.com/aipoch/medical-research-skills

Benchling Integration

When to Use

Key Features

Dependencies

Example Usage

Skill directory: 20260316/scientific-skills/Others/benchling-integration
No packaged executable script was detected.
Use the documented workflow in SKILL.md together with the references/assets in this folder.

Example run plan:

  1. Read the skill instructions and collect the required inputs.
  2. Follow the documented workflow exactly.
  3. Use packaged references/assets from this folder when the task needs templates or rules.
  4. Return a structured result tied to the requested deliverable.

Implementation Details

1. When to Use

Use this skill when you need to:

2. Key Features

Additional reference docs may exist in references/ (e.g., references/authentication.md, references/sdk_reference.md, references/api_endpoints.md) for deeper guidance.

3. Dependencies

4. Example Usage

A minimal, runnable example that authenticates with an API key, creates a DNA sequence, lists sequences (paginated), and creates an ELN entry.

import os

from benchling_sdk.benchling import Benchling
from benchling_sdk.auth.api_key_auth import ApiKeyAuth
from benchling_sdk.models import DnaSequenceCreate, EntryCreate

def main():
    tenant_url = os.environ["BENCHLING_TENANT_URL"]  # e.g. https://your-tenant.benchling.com
    api_key = os.environ["BENCHLING_API_KEY"]
    folder_id = os.environ["BENCHLING_FOLDER_ID"]    # e.g. fld_abc123

    benchling = Benchling(
        url=tenant_url,
        auth_method=ApiKeyAuth(api_key),
    )

    # 1) Create a DNA sequence in the Registry (unregistered unless entity_registry_id is provided)
    created_seq = benchling.dna_sequences.create(
        DnaSequenceCreate(
            name="Example Plasmid",
            bases="ATCGATCG",
            is_circular=True,
            folder_id=folder_id,
        )
    )
    print("Created DNA sequence:", created_seq.id, created_seq.name)

    # 2) List DNA sequences (generator yields pages)
    print("\nListing DNA sequences (first page):")
    pages = benchling.dna_sequences.list()
    first_page = next(iter(pages))
    for seq in first_page:
        print("-", seq.id, seq.name)

    # 3) Create an ELN entry
    entry = benchling.entries.create(
        EntryCreate(
            name="Example Experiment Entry",
            folder_id=folder_id,
        )
    )
    print("\nCreated ELN entry:", entry.id, entry.name)

if __name__ == "__main__":
    main()

Run:

export BENCHLING_TENANT_URL="https://your-tenant.benchling.com"
export BENCHLING_API_KEY="your_api_key"
export BENCHLING_FOLDER_ID="fld_abc123"

python benchling_example.py

5. Implementation Details

Authentication

from benchling_sdk.benchling import Benchling
from benchling_sdk.auth.api_key_auth import ApiKeyAuth

benchling = Benchling(
    url="https://your-tenant.benchling.com",
    auth_method=ApiKeyAuth("your_api_key"),
)
from benchling_sdk.benchling import Benchling
from benchling_sdk.auth.client_credentials_oauth2 import ClientCredentialsOAuth2

auth_method = ClientCredentialsOAuth2(
    client_id="your_client_id",
    client_secret="your_client_secret",
)

benchling = Benchling(
    url="https://your-tenant.benchling.com",
    auth_method=auth_method,
)

Registry entities and schema fields

from benchling_sdk.models import DnaSequenceCreate

sequence = benchling.dna_sequences.create(
    DnaSequenceCreate(
        name="My Plasmid",
        bases="ATCGATCG",
        is_circular=True,
        folder_id="fld_abc123",
        schema_id="ts_abc123",  # optional
        fields=benchling.models.fields({"gene_name": "GFP"}),
    )
)
sequence = benchling.dna_sequences.create(
    DnaSequenceCreate(
        name="My Plasmid",
        bases="ATCGATCG",
        is_circular=True,
        folder_id="fld_abc123",
        entity_registry_id="src_abc123",
        naming_strategy="NEW_IDS",  # do not combine with entity_registry_id per source note
    )
)

Partial updates

from benchling_sdk.models import DnaSequenceUpdate

updated = benchling.dna_sequences.update(
    sequence_id="seq_abc123",
    dna_sequence=DnaSequenceUpdate(
        name="Updated Plasmid Name",
        fields=benchling.models.fields({"gene_name": "mCherry"}),
    ),
)

Pagination

sequences = benchling.dna_sequences.list()
for page in sequences:
    for seq in page:
        print(seq.name, seq.id)

total = sequences.estimated_count()

Inventory operations (containers/boxes/transfers)

from benchling_sdk.models import ContainerCreate, BoxCreate

box = benchling.boxes.create(
    BoxCreate(
        name="Freezer Box A1",
        schema_id="box_schema_abc123",
        parent_storage_id="loc_abc123",
    )
)

container = benchling.containers.create(
    ContainerCreate(
        name="Sample Tube 001",
        schema_id="cont_schema_abc123",
        parent_storage_id=box.id,
        fields=benchling.models.fields({"concentration": "100 ng/μL"}),
    )
)

benchling.containers.transfer(
    container_id=container.id,
    destination_id="box_xyz789",
)

Workflows and async tasks

from benchling_sdk.helpers.tasks import wait_for_task

result = wait_for_task(
    benchling,
    task_id="task_abc123",
    interval_wait_seconds=2,
    max_wait_seconds=300,
)

Retry strategy (error handling)

from benchling_sdk.benchling import Benchling
from benchling_sdk.auth.api_key_auth import ApiKeyAuth
from benchling_sdk.retry import RetryStrategy

benchling = Benchling(
    url="https://your-tenant.benchling.com",
    auth_method=ApiKeyAuth("your_api_key"),
    retry_strategy=RetryStrategy(max_retries=3),
)

Events and Data Warehouse

When Not to Use

Required Inputs

Recommended Workflow

  1. Validate the request against the skill boundary and confirm all required inputs are present.
  2. Select the documented execution path and prefer the simplest supported command or procedure.
  3. Produce the expected output using the documented file format, schema, or narrative structure.
  4. Run a final validation pass for completeness, consistency, and safety before returning the result.

Output Contract

Validation and Safety Rules

Failure Handling

Quick Validation

Run this minimal verification path before full execution when possible:

No local script validation step is required for this skill.

Expected output format:

Result file: benchling_integration_result.md
Validation summary: PASS/FAIL with brief notes
Assumptions: explicit list if any
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.