User Guide
Complete guide for using DeepRetro effectively for retrosynthesis analysis.
Quick Start
Authentication
All API requests require the X-API-KEY
header:
1curl -H "X-API-KEY: your-api-key" \
2 -H "Content-Type: application/json" \
3 http://localhost:5000/api/health
Basic Retrosynthesis
Simple request:
1curl -X POST http://localhost:5000/api/retrosynthesis \
2 -H "X-API-KEY: your-key" \
3 -H "Content-Type: application/json" \
4 -d '{
5 "smiles": "CC(C)(C)OC(=O)N[C@@H](CC1=CC=CC=C1)C(=O)O",
6 "model_type": "claude37",
7 "advanced_prompt": true
8 }'
Python equivalent:
1import requests
2
3response = requests.post(
4 "http://localhost:5000/api/retrosynthesis",
5 headers={"X-API-KEY": "your-key"},
6 json={
7 "smiles": "CC(C)(C)OC(=O)N[C@@H](CC1=CC=CC=C1)C(=O)O",
8 "model_type": "claude37",
9 "advanced_prompt": True
10 }
11)
12
13result = response.json()
14print(f"Found {len(result['data']['pathway'])} synthesis steps")
API Parameters
Request Parameters:
Parameter |
Type |
Required |
Default |
Description |
---|---|---|---|---|
|
string |
✓ |
Target molecule SMILES string |
|
|
string |
|
LLM model: |
|
|
boolean |
|
Enhanced prompting for better results |
|
|
string |
|
AiZynthFinder model version |
|
|
boolean |
|
Enable molecular stability checks |
|
|
boolean |
|
Enable hallucination detection |
Model Configuration
LLM Models
Model |
Identifier |
Best For |
Internal Name |
---|---|---|---|
Claude 3 Opus |
|
High quality results |
|
Claude 3.7 Sonnet |
|
Hybrid reasoning |
|
Claude 4 Opus |
|
High quality results |
|
DeepSeek-R1 |
|
Cost-effective analysis |
|
Note
Claude 3.7 Sonnet is the latest model with hybrid reasoning capabilities, providing both fast responses and deep analytical thinking.
AiZynthFinder Models
Model Version |
Access |
Description |
---|---|---|
|
Free |
Standard USPTO database (default) |
|
Licensed |
25% Pistachio database coverage |
|
Licensed |
50% Pistachio database coverage |
|
Licensed |
100% Pistachio database coverage |
|
Licensed |
Enhanced Pistachio coverage with optimizations |
Advanced Features
Enhanced Prompting
Enable advanced prompting for better results:
1response = requests.post(
2 "http://localhost:5000/api/retrosynthesis",
3 headers={"X-API-KEY": "your-key"},
4 json={
5 "smiles": "CC(C)(C)OC(=O)N[C@@H](CC1=CC=CC=C1)C(=O)O",
6 "model_type": "claude37",
7 "advanced_prompt": True, # Enhanced reasoning
8 "stability_flag": True, # Check stability
9 "hallucination_check": True, # Detect hallucinations
10 "model_version": "Pistachio_50" # Better database
11 }
12)
Partial Rerun
Rerun analysis from a specific step:
1# First, get original analysis
2original = requests.post(
3 "http://localhost:5000/api/retrosynthesis",
4 headers={"X-API-KEY": "your-key"},
5 json={"smiles": "target_molecule"}
6)
7
8# Then rerun from step 2 with different molecule
9rerun = requests.post(
10 "http://localhost:5000/api/partial_rerun",
11 headers={"X-API-KEY": "your-key"},
12 json={
13 "step_id": "step_2",
14 "new_smiles": "CC(C)(C)OC(=O)Cl",
15 "model_type": "claude37",
16 "advanced_prompt": True
17 }
18)
Complete Rerun
Rerun entire analysis with updated parameters:
1response = requests.post(
2 "http://localhost:5000/api/rerun_retrosynthesis",
3 headers={"X-API-KEY": "your-key"},
4 json={
5 "model_type": "claude37", # Switch to different model
6 "advanced_prompt": True, # Enable advanced features
7 "stability_flag": True # Add stability checks
8 }
9)
Response Format
Success Response
1{
2 "status": "success",
3 "data": {
4 "pathway": [
5 {
6 "step": 1,
7 "step_id": "step_1",
8 "smiles": "CC(C)(C)OC(=O)N[C@@H](CC1=CC=CC=C1)C(=O)O",
9 "precursors": [
10 {
11 "smiles": "CC(C)(C)OC(=O)Cl",
12 "confidence": 0.85,
13 "reaction_type": "acylation",
14 "availability": "commercial"
15 },
16 {
17 "smiles": "N[C@@H](CC1=CC=CC=C1)C(=O)O",
18 "confidence": 0.92,
19 "reaction_type": "acylation",
20 "availability": "commercial"
21 }
22 ],
23 "reaction_confidence": 0.88,
24 "feasibility_score": 0.75
25 }
26 ],
27 "metadata": {
28 "model_used": "anthropic/claude-3-7-sonnet-20250219",
29 "processing_time": 2.5,
30 "total_steps": 1,
31 "advanced_prompt": true,
32 "stability_checked": true
33 }
34 }
35}
Error Response
1{
2 "status": "error",
3 "error": {
4 "code": "INVALID_SMILES",
5 "message": "The provided SMILES string is invalid",
6 "details": "Could not parse SMILES: 'CC(C)(C)OC(=O)N[C@@H]'"
7 }
8}
Web Interface
The web interface provides an intuitive way to interact with DeepRetro:
Features
Feature |
Description |
---|---|
Interactive Input |
Enter SMILES strings or paste from clipboard |
Model Selection |
Choose from available LLM models |
Pathway Visualization |
Interactive tree view of synthesis pathways |
Confidence Indicators |
Visual confidence scores for each step |
Step Editing |
Edit and rerun specific pathway steps |
File Management |
Upload/download JSON pathway files |
Export Options |
Export results as JSON, CSV, or images |
Access
Start the web interface:
1# Start backend
2python src/api.py
3
4# Start frontend (in new terminal)
5cd viewer
6python -m http.server 8000
7
8# Open browser
9# http://localhost:8000
Troubleshooting
Common Issues
Invalid SMILES Error: - Validate SMILES strings using RDKit before submission - Check for proper molecular notation format - Ensure SMILES represents valid chemical structures
API Key Issues: - Verify API_KEY environment variable is set - Test with the /api/health endpoint to validate key - Check for unauthorized (401) responses
Model Availability: - Available models: claude3, claude37, deepseek - AiZynthFinder models depend on local installation - Check variables.py for current model list
Performance Optimization
Caching Strategy
Results are automatically cached to improve performance
Use /api/clear_molecule_cache to refresh cached data
Cache persists across server restarts
Rate Limiting
API implements rate limiting to prevent overload
Add delays between requests for batch processing
Handle 429 status codes with retry logic