Quick Start
Rasyn provides AI-powered retrosynthetic analysis through a REST API. Given a target molecule as a SMILES string, predict synthetic routes — either one step back or a full route to purchasable starting materials.
What is SMILES?
SMILES (Simplified Molecular-Input Line-Entry System) is a compact text representation of chemical structures.
CC(=O)Oc1ccccc1C(=O)OAspirinCC(=O)Nc1ccc(O)cc1Acetaminophenc1ccccc1BenzeneMake your first request
curl -X POST https://api.rasyn.ai/api/v1/retro/single-step \
-H "Content-Type: application/json" \
-H "X-API-Key: YOUR_API_KEY" \
-d '{"smiles": "CC(=O)Oc1ccccc1C(=O)O", "model": "retro", "top_k": 5}'https://api.rasyn.ai— All endpoints are relative to this URL.Authentication
Every API request must include a valid API key. Keys are available in two roles: user (API access) and admin (key management).
X-API-Key HeaderRecommended
POST /api/v1/retro/single-step HTTP/1.1
Host: api.rasyn.ai
Content-Type: application/json
X-API-Key: rsy_your_api_key_here
{"smiles": "CC(=O)Oc1ccccc1C(=O)O"}Authorization Bearer Header
POST /api/v1/retro/single-step HTTP/1.1
Host: api.rasyn.ai
Content-Type: application/json
Authorization: Bearer rsy_your_api_key_here
{"smiles": "CC(=O)Oc1ccccc1C(=O)O"}Query Parameter
GET /api/v1/molecules/image?smiles=c1ccccc1&api_key=rsy_your_api_key_here
Never expose your API key in client-side code. Always call the Rasyn API from your backend server, and store keys in environment variables.
Endpoints
Four endpoints covering retrosynthetic prediction, route planning, and molecular utilities.
/api/v1/retro/single-stepSingle-Step Retrosynthesis
Predict reactants that could produce a given product molecule (one step backwards).
smilesstringrequiredProduct molecule in SMILES notation
modelstringdefault: "llm""retro", "llm", or "both"
top_kintegerdefault: 10Number of predictions (1-50)
use_verificationbooleandefault: trueRun forward-model verification (LLM only)
/api/v1/retro/multi-stepMulti-Step Route Planning
Plan a full synthetic route from target molecule back to purchasable starting materials.
Multi-step is computationally expensive. Typical response times: 10-120 seconds.
smilesstringrequiredTarget molecule SMILES
max_depthintegerdefault: 10Max retrosynthetic steps (1-20)
max_routesintegerdefault: 5Max number of complete routes (1-20)
/api/v1/molecules/validateValidate SMILES
Validate a SMILES string and get molecular information.
smilesstringrequiredSMILES string to validate
/api/v1/molecules/imageMolecule Image
Get a rendered SVG image of a molecule.
smilesstringrequiredURL-encoded SMILES string
Rate Limits
Per-IP rate limiting protects GPU resources. Every response includes rate limit headers.
| Endpoint | Limit | Window | Notes |
|---|---|---|---|
| POST /api/v1/retro/single-step | 20 | 60s | GPU-intensive |
| POST /api/v1/retro/multi-step | 5 | 60s | Very GPU-intensive |
| /api/v1/molecules/* | 60 | 60s | Lightweight |
| All other /api/* | 60 | 60s | Default |
Response Headers
Every response includes these rate limit headers:
X-RateLimit-Limit: 20 X-RateLimit-Remaining: 17 X-RateLimit-Reset: 1739395200
{
"error": "rate_limit_exceeded",
"message": "Rate limit exceeded. Max 20 requests per 60s.",
"retry_after": "45"
}Error Handling
Standard HTTP status codes with detailed JSON error messages.
| Code | Status | Description |
|---|---|---|
| 200 | OK | Request succeeded |
| 400 | Bad Request | Invalid SMILES or malformed JSON |
| 401 | Unauthorized | Missing API key |
| 403 | Forbidden | Invalid or revoked key |
| 422 | Validation Error | Request body doesn't match schema |
| 429 | Too Many Requests | Rate limit exceeded, check retry_after |
| 500 | Internal Error | Model crashed or unexpected bug |
| 502 | Bad Gateway | Backend is down or restarting |
| 504 | Timeout | Request took too long, try faster model |
Example Error Responses
{
"error": "authentication_required",
"message": "API key required. Pass via X-API-Key header,
Authorization: Bearer <key>, or ?api_key= query param."
}{
"error": "invalid_api_key",
"message": "The provided API key is not valid or has been revoked."
}Code Examples
Complete examples for calling the API from different languages.
const response = await fetch('https://api.rasyn.ai/api/v1/retro/single-step', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-API-Key': process.env.RASYN_API_KEY
},
body: JSON.stringify({
smiles: 'CC(=O)Oc1ccccc1C(=O)O',
model: 'retro',
top_k: 10
})
});
const data = await response.json();
console.log(data.predictions);Always store your API key in environment variables. For Next.js, use .env.local and never commit this file to version control.
Models
Two AI models with different speed/quality trade-offs. Choose the right one for your use case.
| Model | ID | Speed | Quality | Description |
|---|---|---|---|---|
| RetroTransformer v2 | retro | Fast (0.2-1s) | Good | Specialized seq2seq model with copy mechanism |
| LLM (RSGPT v6) | llm | Slow (3-200s) | Better | Large language model with round-trip verification |
| Both | both | Slow | Best | Runs both models, merges and re-ranks results |
Recommended by use case
Interactive UI
Fast feedback, live typing
model: "retro"High-Quality Analysis
Better predictions with verification
model: "llm"Research & Comparison
Full results from both models
model: "both"