brymol Documentation
brymol embeds PyMOL in a single window and converts natural language into PyMOL commands. Covers install, OpenRouter setup, architecture, the command pipeline, selection syntax, data flow, safety, and troubleshooting.
Introduction
brymol embeds an open source PyMOL instance and exposes it through a chat interface and a 3D viewport in one window. You write a request in natural language. A model converts it into PyMOL commands. brymol classifies each command, previews it, and runs it against the embedded session.
Because PyMOL runs in the same process, brymol reads the live session (objects, chains, ligands, selections) and sends that state to the model as context, and it can render the viewport to an image for vision models. Tasks it handles: loading by PDB id or name, selections, representations and colouring, measurements, alignment, mutagenesis, scenes, and ray-traced figures.
Bring your own key. brymol ships no API key and runs no backend. You connect your own OpenRouter key, so model spend is yours and capped by your own credit.
Requirements
| Item | Requirement |
|---|---|
| Operating system | macOS 12 or newer, Apple Silicon (arm64) or Intel (x86_64). |
| Disk | Around 2 GB free. The installer downloads Miniforge and PyMOL. |
| Network | Internet during install, and when fetching structures or calling the model. |
| Graphics | A GPU that supports OpenGL 2.1 or newer (standard on any modern Mac). |
| Account | An OpenRouter account and a small amount of credit to use the AI features. |
No separate PyMOL install is needed. The installer provisions an isolated PyMOL build so it will not touch or conflict with any existing PyMOL on your machine.
Installation
The macOS download is a DMG containing a standard installer package. It installs brymol.app into Applications and support files into Application Support. On first launch, brymol provisions Miniforge (a minimal conda distribution), creates an isolated environment with Python 3.11 and the open source build of PyMOL, and installs brymol's Python dependencies. The runtime setup is idempotent, so running it again is safe and only fills in what is missing.
Standard install
- Download the macOS DMG, then open it.
- Right-click brymol-installer.pkg, choose Open, then confirm Open if macOS asks.
- If macOS blocks it, open System Settings, go to Privacy & Security, then choose Open Anyway.
- On first launch, wait for the runtime setup to finish. It can take a few minutes while PyMOL downloads.
- Launch brymol from Spotlight (Command-Space, then type "brymol") or from the Applications folder.
Terminal alternative
open downloads/brymol-macos.dmg
First launch. Because the app is not signed by an Apple developer account, macOS Gatekeeper may block it the first time. Right-click the app, choose Open, then Open again. You only need to do this once. To clear the quarantine flag from the terminal instead, run xattr -dr com.apple.quarantine /Applications/brymol.app.
What the installer does
| Step | Action |
|---|---|
| 1 | Installs Miniforge to ~/miniforge3 if conda is not present. |
| 2 | Creates the pymol environment with Python 3.11 and pymol-open-source. |
| 3 | Installs PySide6, httpx, pydantic, openai, keyring, and pillow into that environment. |
| 4 | Builds brymol.app (icon, launcher, metadata) from scratch. |
| 5 | Copies the app to /Applications (or ~/Applications) and clears the quarantine flag. |
OpenRouter Setup
brymol calls models through OpenRouter: one key, one billing account, many providers. It uses the OpenAI-compatible chat completions endpoint at https://openrouter.ai/api/v1.
Step by step
- Sign up at openrouter.ai.
- Open Settings, Credits, and add a balance. Five dollars is plenty to start.
- Open Settings, Keys, Create Key. Optionally set a credit limit on the key as a hard spend cap.
- Copy the key (it starts with sk-or-).
- In brymol, open Settings, paste the key, pick a model, and save.
Key storage
The key is written to the macOS Keychain through the system keyring, never to a plain text file. brymol also reads it from an environment variable. Lookup order: environment variable, then Keychain, then any legacy value in settings.
Environment variable
export OPENROUTER_API_KEY="sk-or-..."
Models
Agent mode and Explain send a rendered image, so they need a vision capable model. The default is vision capable. Any OpenRouter model id can be typed into the model field. The HTTP client uses a request timeout and retries on transient failures.
| Use case | Model id |
|---|---|
| Default, agent and vision | anthropic/claude-sonnet-4.6 |
| Hardest reasoning | anthropic/claude-opus-4.8 |
| Fast and cheap | anthropic/claude-haiku-4.5 |
| Low cost vision | google/gemini-3-flash-preview |
Cost control
- Spend is yours and visible in the OpenRouter dashboard, capped by the credit you load.
- brymol caps output tokens per call (chat and agent steps around 1500, Explain around 900) to avoid reserving large amounts of credit per request.
- A chat request on a cheap model costs a fraction of a cent. An agent run with vision is a few cents because it sends images over several steps.
- Set a per-key credit limit in OpenRouter as a hard backstop.
How It Works
Process model
When PyMOL is importable, brymol hosts the PyMOL OpenGL viewport widget in the same process and drives the command layer directly. No second window, no network bridge. If PyMOL cannot be imported, it falls back to a local HTTP bridge against an external PyMOL. Both expose the same engine interface (run commands, read session, snapshot, render).
Request pipeline (chat)
brymol sends your text plus a session summary. The model must return JSON in this schema. brymol validates it, classifies each command, and shows a preview. Commands run on confirm, or immediately for SAFE commands in Bypass mode.
Response schema
{
"intent": "short label",
"explanation": "what the commands do",
"requires_confirmation": true,
"commands": ["fetch 1ubq", "show cartoon", "color marine"]
}
If the model replies with prose instead of JSON, brymol surfaces that text as a chat message rather than failing.
Session context sent to the model
| Field | Contents |
|---|---|
| objects | Loaded object names and which are enabled. |
| chains | Chain identifiers per object. |
| ligands | Residue names of non-polymer entities. |
| selections | Active selection names with atom counts and a small capped atom sample. |
Coordinate files are not uploaded. The model sees this summary, and in vision modes a rendered image.
Load by name
A fetch by name (for example fetch hemoglobin) is resolved to a PDB id with an RCSB text search before it runs. If the name spans more than one source organism, brymol groups hits by organism and asks which species, then re-runs with the chosen id. PDB ids and UniProt accessions are detected and passed through unchanged.
Agent mode
Agent mode is an iterative tool-calling loop. The model calls two tools: run_pymol_command and look_at_structure, which auto-frames the view, ray-traces it to a PNG, and returns it as a vision input. The loop runs to a fixed step cap, and a repetition detector aborts it if it stalls or oscillates. Safety classification applies to every command, and BLOCK is refused inside the loop.
Undo and history
brymol snapshots the full session (get_session) before each change and restores it (set_session) on undo, so Undo and Redo recover the entire scene rather than reversing a single command. Conversations persist locally and are reachable from the Recent menu.
Features
| Feature | What it does |
|---|---|
| Chat to commands | Natural language turned into reviewable PyMOL commands, with name to PDB resolution. |
| Agent mode | Autonomous loop that runs commands and inspects the rendered view until the goal is met. |
| Explain | Sends the current view to a vision model and returns a description of the structure. |
| Search | RCSB search by text or ID and AlphaFold lookup by UniProt, with one click loading. |
| Show and Colour | Common representation and colouring presets from the viewport toolbar. |
| Analyze | Active site around a ligand, chain interface, and colouring by hydrophobicity, charge, secondary structure, or B-factor. |
| Measure | Distance between two picked atoms and polar contacts within a selection. |
| Modify | Align two structures and report the RMSD, or mutate a residue to another amino acid. |
| Scenes | Save the current view as a numbered scene, recall it, or play through all scenes. |
| Save figure | Ray-traced PNG export at high resolution for figures. |
| Raw commands | Type a slash followed by any PyMOL command to run it directly, bypassing the model. |
Drag and drop a structure file (.pdb, .cif, .sdf, .mol2, .pse and others) onto the 3D view to load it. Every toolbar action snapshots first, so anything can be undone.
Selections & Syntax
brymol generates standard PyMOL selection algebra. Knowing it helps you phrase requests precisely and read the previewed commands. Selectors below combine with the operators and, or, not, and parentheses.
| Selector | Matches |
|---|---|
| polymer | Protein and nucleic acid chains. |
| organic | Small-molecule ligands. |
| solvent | Water and solvent molecules. |
| hetatm, metals | Heteroatoms, and metal ions. |
| chain A | A specific chain. |
| resi 50-60 | Residues by number or range. |
| resn HIS | Residues by name. |
| name CA, elem Zn | Atoms by atom name, or by element. |
| ss H, ss S | Helix, and sheet (run dss first to assign). |
Proximity operators
| Operator | Meaning |
|---|---|
| X within 5 of Y | Atoms of X within 5 Angstrom of Y. |
| byres (...) | Expands an atom selection to whole residues. |
| X around 5 | Atoms near X, excluding X itself. |
Example selections
select site, byres (polymer within 5 of organic)
select iface, byres (chain A within 5 of chain B)
select pocket_polar, site and (resn ASP+GLU+LYS+ARG+HIS)
select bb, name C+N+CA+O
Commands brymol emits
Common verbs in generated and toolbar commands: fetch, load, show and hide, color with the util.cbc / cbag / cbay / cbao / cbac helpers, spectrum, select, zoom and orient, distance, align / super / cealign, dss, cartoon putty, set, scene, and png for ray-traced output. Mutagenesis is run through the PyMOL mutagenesis wizard rather than a single command.
Privacy & Data
brymol runs locally. The only time data leaves your machine is when you call the model, fetch a structure, or run a search. This section states exactly what is sent and where.
What is sent to the model
When you send a chat or agent request, brymol transmits your text, a compact text summary of the current session (object names, chains, ligand residue names, enabled objects, and a small sample of atoms from active selections), and the model id, to OpenRouter and the provider you selected. In Agent mode and the Explain feature, brymol also renders the current viewport to a PNG image and sends that image so the model can see the structure. Full atomic coordinate files are not uploaded. The model sees the text summary and, where vision is used, the rendered picture.
What is fetched from public databases
Loading a structure by id or name downloads coordinates from RCSB, and AlphaFold lookups query the EBI AlphaFold service. These are standard requests to public scientific databases, made directly from your machine.
What stays on your machine
Your API key is stored in the macOS Keychain. Conversation history, recently loaded structures, application logs, and the structured error log are all written under ~/.pymol_ai_companion and are never transmitted. Downloaded structures are cached locally in that same directory.
No analytics. This version of brymol sends no usage analytics or telemetry of any kind. The only outbound traffic is to your model provider through OpenRouter and to the structure databases you query.
Third party handling
Prompts and images you send are received by OpenRouter and the underlying model provider, and are subject to their data and retention policies. If you work with confidential or unpublished structures, review those policies and use your OpenRouter account settings to control routing and retention. Do not send anything you are not permitted to share with a third party service.
| Data | Location |
|---|---|
| API key | macOS Keychain |
| Settings | ~/.pymol_ai_companion/settings.json |
| Conversation history | ~/.pymol_ai_companion/chats.json |
| Application log | ~/.pymol_ai_companion/brymol.log |
| Error log | ~/.pymol_ai_companion/errors.jsonl |
Command Safety
A language model can produce any text, including commands that would run code or touch the file system. brymol does not trust model output. Every command, whether from chat, from the agent, or resolved from a name, is classified before it can run. There are three outcomes.
| Class | Behaviour |
|---|---|
| SAFE | Visualisation and selection commands. Run after preview, or immediately in Bypass mode. |
| WARN | Commands that write files or are destructive (save, delete, remove, reinitialize). Always shown for confirmation. |
| BLOCK | Anything that can execute code or scripts. Refused outright, including in Agent and Bypass modes. |
What is blocked
The classifier rejects line prefixes that escape into a shell or the Python layer, the command verbs that run or load code (such as python, run, spawn, system, exec, eval, import, alias, and extend), dotted calls into the PyMOL or command internals, dangerous tokens that appear anywhere in a line (such as os., eval(, exec(, system(, and double underscores), and loading or running script files with extensions like .py, .pml, .sh, or .bash. The intent is defence in depth, so that even an unusual phrasing that slips past one rule is caught by another.
Preview by default. Commands are shown before they run. Bypass mode only auto-runs commands that are classified SAFE. A blocked command is never run, regardless of mode.
Troubleshooting
macOS blocks the app on first launch
The app is unsigned, so Gatekeeper warns once. Right-click the app, choose Open, then Open. Alternatively clear the quarantine flag with xattr -dr com.apple.quarantine /Applications/brymol.app.
The AI says to add a key
No API key is configured. Add your OpenRouter key in Settings, or set the OPENROUTER_API_KEY environment variable before launching.
The 3D view is black
The viewport needs the real time renderer. Launch through brymol.app or brymol.sh rather than a headless Python invocation. If you start from source, the launcher sets the correct graphics and Qt plugin paths for you.
An authentication, credit, or rate error appears
A 401 means the key is missing or wrong, a 402 means the OpenRouter account needs more credit, and a 429 means you hit a rate limit. brymol translates these into plain messages. Check your key and balance in the OpenRouter dashboard, or switch to a cheaper model.
A command reports an error
PyMOL's own error text is surfaced in the chat and recorded in the error log at ~/.pymol_ai_companion/errors.jsonl, along with the request and any console output. That file is the first place to look when something behaves unexpectedly.
Reinstalling or repairing
Re-run the installer. It detects what already exists and only repairs the missing pieces, so it will not duplicate the environment or lose your settings.
Reference
Keyboard and input
| Input | Action |
|---|---|
| Command-Z | Undo the last change (restores the full scene). |
| Shift-Command-Z | Redo. |
| /command | Run a raw PyMOL command directly, for example /show cartoon. |
| Control-click two atoms | Pick atoms before using Measure, Distance. |
Run from source
Developer commands
./brymol.sh # launch the app
./build_app.sh # rebuild brymol.app
ruff check app # lint
QT_QPA_PLATFORM=offscreen python3 -m pytest app/tests -q # run tests
Example prompts
fetch 3HTB
colour key binding residues
show the protein as cartoon and the ligand as sticks
colour by chain and hide waters
align this onto 1ubq
make a publication quality view of the active site
brymol is free and runs on your own key. Support keeps it free and funds the next feature.
© 2026 Raillard