MedgeClaw: Half-price Claude for bioinformatics analysis.

β€’AI Expert

Repository: https://github.com/xjtulyc/MedgeClaw

Medium difficulty, approximately 30 minutes. Learn how to build a Biomedical AI Assistant using half-price Claude APIs, saving over $500 monthly.

Target Audience

  • Life science researchers looking to use AI to assist in data analysis.
  • Bioinformatics engineers needing to automate scientific workflows.
  • University students interested in AI + Scientific Research.

Core Dependencies and Environment

  • Node.js 22+
  • Docker + docker-compose
  • Git
  • Defapi API Key (The half-price solution, detailed below)

[!TIP]
A GPU with 8GB+ VRAM is not mandatory, but it allows for more local model deployments.

Project Structure

MedgeClaw/
β”œβ”€β”€ .env.example              # Environment configuration template
β”œβ”€β”€ .env                     # Actual configuration (copied from example)
β”œβ”€β”€ setup.sh                 # One-click installation script
β”œβ”€β”€ sync.py                  # OpenClaw configuration sync
β”œβ”€β”€ docker-compose.yml       # Docker environment definition
β”œβ”€β”€ .medgeclaw-sync.yml      # Sync rule configuration
β”œβ”€β”€ docker/
β”‚   β”œβ”€β”€ Dockerfile           # R + Python + RStudio + Jupyter
β”‚   └── entrypoint.sh        # Container startup script
β”œβ”€β”€ skills/                  # MedgeClaw built-in skills
β”‚   β”œβ”€β”€ biomed-dispatch/     # Task router
β”‚   β”œβ”€β”€ dashboard/           # Real-time research dashboard
β”‚   β”œβ”€β”€ cjk-viz/             # Chinese font detection
β”‚   β”œβ”€β”€ svg-ui-templates/    # SVG templates
β”‚   └── feishu-rich-card/    # Feishu rich text cards
β”œβ”€β”€ scientific-skills/       # K-Dense 140 scientific skills (git submodule)
β”œβ”€β”€ data/                    # Data directory (place your input files here)
β”œβ”€β”€ outputs/                 # Output directory (analysis results go here)
└── writing_outputs/         # Scientific writing outputs

Step-by-Step Tutorial

Step 1: Clone the Repository

# Clone the project (including submodules)
git clone --recurse-submodules https://github.com/xjtulyc/MedgeClaw.git
cd MedgeClaw

[!WARNING]
You must include --recurse-submodules, otherwise the scientific-skills directory will be empty.

Step 2: Configure Half-Price Claude API

This is the most critical stepβ€”we are using Defapi to save big!

Defapi is a model aggregation platform compatible with the OpenAI format, offering half-price services for the Claude series. Indeed, while the official price for Claude Sonnet 4.5 is $3.75/M tokens, it is only $1.875 here.

[!TIP]
Suppose you run 1,000 gene analyses per day, each consuming 100k context tokens + 5k output tokens:

  • Official API: Approx. $3.75 Γ— 1000 = $3750/month
  • Defapi: Approx. $1.875 Γ— 1000 = $1875/month
  • Monthly Savings: $1875!

First, copy the configuration template:

cp .env.example .env

Then edit .env and enter your Defapi API Key:

# Defapi Half-Price Configuration
ANTHROPIC_API_KEY=dk-xxxxxxxxxxxxxxxx
ANTHROPIC_BASE_URL=https://api.defapi.org
MODEL=anthropic/claude-sonnet-4.5

# Critical: Claude Code pre-flight requires this configuration
ANTHROPIC_SMALL_FAST_MODEL=anthropic/claude-sonnet-4.5

# Web Interface Passwords
RSTUDIO_PASSWORD=biomed
JUPYTER_TOKEN=biomed

[!WARNING]
Don't have a Defapi API Key? Register at https://defapi.org; new users get free credits. Defapi supports the v1/chat/completions endpoint and is fully compatible with Claude Code.

Step 3: Run the Installation Script

bash setup.sh

This script will automatically:

  • Check for Node.js 22+ and Docker dependencies.
  • Globally install openclaw and claude-code.
  • Generate ~/.claude/settings.json (Claude Code configuration).
  • Build the Docker image (containing R, Python, RStudio, JupyterLab).
  • Configure the OpenClaw workspace.

[!WARNING]
Building the Docker image for the first time takes 10-20 minutes, depending on your network and machine specs.

Step 4: Start the Docker Environment

docker compose up -d

Once started successfully, you can access:

Step 5: Sync Configuration to OpenClaw

python3 sync.py
openclaw gateway restart

sync.py will:

  • Copy MedgeClaw skills to the OpenClaw workspace.
  • Update OpenClaw configuration files.
  • Inject project documentation into the Agent context.

Step 6: Verify Installation

# Quickly verify API connection (should return "hello" within 30 seconds)
claude --dangerously-skip-permissions -p 'run: echo hello'

If you see hello, the configuration is correct.

[!WARNING]
If it hangs for more than 30 seconds, ANTHROPIC_SMALL_FAST_MODEL is likely configured incorrectlyβ€”your proxy might not support that model. Defapi works fine as it supports the full Claude model list.


Troubleshooting

Q1: Docker Build Failed

Symptoms: docker compose build hangs or throws an error.

Solution:

# Clean Docker cache and retry
docker system prune -a
docker compose build --no-cache

Q2: Claude Code Pre-flight Hangs

Symptoms: Any command hangs, showing "Pre-flight check is taking longer than expected".

Solution: Third-party proxies may not support the default Haiku model; you must set ANTHROPIC_SMALL_FAST_MODEL:

# Add to .env (or modify to a model supported by your proxy)
ANTHROPIC_SMALL_FAST_MODEL=anthropic/claude-sonnet-4.5

Defapi fully supports this configuration.

Q3: scientific-skills directory is empty

Symptoms: The skills/ directory exists but has no content.

Solution:

git submodule update --init --recursive

Q4: Port Occupied

Symptoms: Port 8787 or 8888 is already in use.

Solution:

# Find the process using the port
lsof -i :8787
lsof -i :8888

# Or change the port mapping in docker-compose.yml

Q5: OpenClaw cannot find MedgeClaw skills

Symptoms: Agent does not recognize skills like biomed-dispatch.

Solution:

# Re-sync
python3 sync.py
openclaw gateway restart

Q6: R/Python Package Installation Failed

Symptoms: Analysis script errors with "package not found".

Solution:

# Python package
docker exec medgeclaw pip install <package-name>

# R package
docker exec medgeclaw Rscript -e 'install.packages("<package-name>", repos="https://cran.r-project.org")'

Further Reading / Advanced Directions

1. K-Dense Scientific Skills

MedgeClaw integrates 140 scientific skills covering:

  • Omics Analysis: DESeq2, edgeR, Scanpy, Seurat
  • Drug Discovery: ChEMBL, DeepChem, DiffDock
  • Literature Search: PubMed, bioRxiv, Semantic Scholar
  • Pathway Analysis: gseapy, clusterProfiler

For detailed usage, refer to the SKILL.md files in the scientific-skills/scientific-skills/ directory.

2. Custom Skill Development

Want to add new skills to MedgeClaw? Create a directory following the AgentSkills specification:

skills/
└── your-custom-skill/
    └── SKILL.md   # Skill definition file

SKILL.md Template:

# Your Custom Skill

## When to use
Describe the scenarios in which this skill should be called.

## How it works
The specific implementation logic of the skill.

## Examples
Provide a few usage examples.

3. Multi-Model Comparison

Real-world comparison of different models:

ModelSpeedQualityPriceSuitable Scenario
claude-sonnet-4.5 (Defapi)MediumHighMediumDaily Analysis (Recommended)
claude-opus-4.5 (Defapi)SlowHighestHighComplex Reasoning Tasks
claude-haiku-4.5 (Defapi)FastMediumLowSimple Tasks
qwen2.5:14b (Local)LocalMediumFreeFully Offline Scenarios

[!TIP]
If you want to save even more, Defapi supports Claude Haiku 4.5 at a lower price point, suitable for simple tasks.

4. Feishu Integration

To let MedgeClaw work within Feishu groups, configure the FEISHU_DEFAULT_CHAT_ID environment variable, then use the feishu-rich-card skill to send rich media reports.

5. Research Dashboard

Every analysis task automatically generates a real-time dashboard. Access data/<task_name>/dashboard/dashboard.html to view progress, code, and output previews.

MedgeClaw: Half-price Claude for bioinformatics analysis.