# Scientific Diagram Generation
AI-powered scientific illustration generation using Gemini Image models. Creates publication-quality mechanism diagrams, pathway illustrations, and scientific figures.
| Parameter | Value |
|---|---|
| Provider | Google Gemini via yunwu.ai relay |
| Model | gemini-3.1-flash-image-preview |
| Base URL | https://yunwu.ai/v1beta/models |
| Full Endpoint | https://yunwu.ai/v1beta/models/gemini-3.1-flash-image-preview:generateContent |
| Auth | Authorization: Bearer <LLM_API_KEY> |
| API Key env var | LLM_API_KEY (Gemini series key) |
| Response | Image in candidates[].content.parts[].inlineData.data (base64 PNG) |
curl -X POST "https://yunwu.ai/v1beta/models/gemini-3.1-flash-image-preview:generateContent" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $LLM_API_KEY" \
-d '{
"contents": [{"role": "user", "parts": [{"text": "YOUR_PROMPT_HERE"}]}],
"generationConfig": {
"responseModalities": ["TEXT", "IMAGE"]
}
}'
import httpx, base64
API_KEY = "your-gemini-key"
MODEL = "gemini-3.1-flash-image-preview"
URL = f"https://yunwu.ai/v1beta/models/{MODEL}:generateContent"
async def generate(prompt: str) -> bytes:
payload = {
"contents": [{"role": "user", "parts": [{"text": prompt}]}],
"generationConfig": {"responseModalities": ["TEXT", "IMAGE"]}
}
async with httpx.AsyncClient(timeout=120) as c:
r = await c.post(URL, json=payload,
headers={"Content-Type": "application/json",
"Authorization": f"Bearer {API_KEY}"})
r.raise_for_status()
for cand in r.json().get("candidates", []):
for part in cand["content"]["parts"]:
if "inlineData" in part:
return base64.b64decode(part["inlineData"]["data"])
return b""
Cell/Nature/Science publication style. Realistic cell morphology with smooth
membranes. Activation arrows: solid black. Inhibition: red T-bar. Secretion:
dashed arrow. Proteins as colored ovals. Receptors as Y-shapes on membranes.
Clean, professional, suitable for journal figures.
Flat vector style with clean outlines and solid color fills. No gradients,
textures, or noise. High contrast. Easy to edit in Adobe Illustrator or Inkscape.
Modern infographic style with grid layout. Rounded rectangles for cells.
Circles for molecules. 3-5 accent colors maximum. Clean geometric shapes.
CRITICAL RULES FOR SCIENTIFIC DIAGRAM GENERATION:
1. BIOLOGICAL COMPLETENESS: Name all cell types, receptors, ligands, molecules,
transcription factors. Include activation, inhibition, binding, phosphorylation,
secretion, translocation.
2. VISUAL COMPOSITION: Describe spatial layout (top/bottom/left/right). Define
compartments (membrane, cytoplasm, nucleus, extracellular). Choose layout flow.
3. FONT: Use Arial or clean sans-serif for ALL labels. Never decorative fonts.
4. TEXT LABELS: Title Case for all labels. Never ALL CAPS. Gene/protein
abbreviations kept as-is (PD-L1, IFN-γ, JAK).
5. BACKGROUND: Pure white #FFFFFF. No gradients, textures, or vignettes.
6. EDITABILITY: Elements clearly separated with sharp edges. No overlapping.
Easy post-editing.
cell, protein, receptor, mRNA, DNA, complex, small_molecule, vesicle, exosome, antibody, other
activate, inhibit, bind, phosphorylate, secrete, recruit, translocate, transcribe, degrade, upregulate, downregulate
membrane, cytoplasm, nucleus, extracellular_space, mitochondria, endoplasmic_reticulum, golgi
Generate a scientific mechanism diagram:
[DESCRIPTION OF THE MECHANISM]
STYLE: [publication / vector_friendly / infographic]
[CORE_PROMPT_RULES]
EXACT TEXT LABELS to render (use these exact strings, do NOT change
capitalization): ["Label1", "Label2", ...]
Generate a signaling pathway diagram showing:
- Ligand: [name] binding to receptor: [name] on [cell type]
- Intracellular cascade: [kinase1] → [kinase2] → [transcription factor]
- Downstream effects: [gene expression changes]
- Compartments: extracellular, membrane, cytoplasm, nucleus
STYLE: publication
[CORE_PROMPT_RULES]
Generate a tumor microenvironment diagram showing:
- Central: tumor cells (irregular shape, dark)
- Surrounding: [immune cells, fibroblasts, endothelial cells]
- Key interactions: [list of interactions with arrow types]
- Secreted factors: [cytokines, chemokines with dashed arrows]
Layout: radial, tumor at center
STYLE: publication
[CORE_PROMPT_RULES]
Generate a cell biology diagram showing:
- Cell with organelles: nucleus, mitochondria, ER, Golgi, lysosomes
- Process: [e.g., autophagy, apoptosis, protein trafficking]
- Key molecules at each step: [list]
- Arrows showing process flow
STYLE: publication
[CORE_PROMPT_RULES]
Generate a scientific diagram (bypassing SketchGraph, direct prompting):
[DESCRIPTION — can be circuit diagram, chemical reaction scheme,
geological cross-section, physics experiment setup, etc.]
STYLE RULES:
- White background #FFFFFF
- Arial font for all labels
- Title Case for labels
- Clean, professional, publication quality
- No decorative elements
The API may return 429 (rate limit) or 5xx errors. Recommended retry:
~/.scienceclaw/workspace/diagrams/diagram_{uuid}.png