This guide is for coding agents and assistant workflows that need to install and configure PyMolAI for end users.
PyMolAI is an AI assistant layer integrated into the PyMOL Qt desktop UI.
Core points:
- OpenRouter key enables AI agent turns.
- OpenBio key is optional and only enables OpenBio gateway tools.
- Internal PyMOL tools (
run_pymol_command,capture_viewer_snapshot) are always available.
- Install project in a virtual environment.
- Launch PyMOL GUI.
- Open
Display -> PyMolAI Settings -> OpenRouter API Key...and save/test key. - For OpenBio access, sign up at https://openbio.tech/ and create an OpenBio API key.
- Optionally open
Display -> PyMolAI Settings -> OpenBio API Key...and save/test key. - Optionally set the model from
Display -> PyMolAI Settings -> Model.
The C++ extension requires native libraries not bundled in the Python package. Install them before the pip/uv install step:
brew install netcdf glew glm
# libxml2, freetype, and libpng are typically already present;
# install them too if the build fails looking for those headers.git clone https://github.com/ravishar313/PyMolAI
cd PyMolAI
# Create venv with uv (Python 3.10+ for full claude-agent-sdk support)
uv venv .venv
source .venv/bin/activate
# Build and install — include netcdf in PREFIX_PATH alongside homebrew paths
PREFIX_PATH=/opt/homebrew:/opt/homebrew/opt/libxml2:/opt/homebrew/opt/netcdf \
uv pip install --python .venv/bin/python --reinstall .
# PyQt5 must be installed explicitly. PyQt6 is also detected by PyMOL's Qt
# loader but has incompatible enum namespacing with this codebase.
uv pip install --python .venv/bin/python PyQt5
# Verify
.venv/bin/python -c "import keyring, openai; print('ok: keyring/openai')"
.venv/bin/python -c "import claude_agent_sdk; print('ok: claude-agent-sdk')"
.venv/bin/python -c "from PyQt5 import QtWidgets; print('ok: PyQt5')"git clone https://github.com/ravishar313/PyMolAI
cd PyMolAI
uv venv .venv --python 3.10
.\.venv\Scripts\Activate.ps1
$env:PREFIX_PATH = "C:\path\to\deps"
uv pip install --python .venv\Scripts\python.exe --reinstall .
uv pip install --python .venv\Scripts\python.exe PyQt5
python -c "import keyring, openai; print('ok: keyring/openai')"
python -c "import claude_agent_sdk; print('ok: claude-agent-sdk')"
python -c "from PyQt5 import QtWidgets; print('ok: PyQt5')"Environment variables:
OPENROUTER_API_KEYANTHROPIC_AUTH_TOKENOPENBIO_API_KEYOPENBIO_BASE_URLPYMOL_AI_OPENROUTER_KEY_SOURCEPYMOL_AI_OPENBIO_KEY_SOURCE
Behavior contract:
- Without OpenRouter key (or Anthropic auth token mapping), AI mode is disabled.
- Without OpenBio key, OpenBio tools are not registered, but the app still works.
- Model selector in settings is strict to supported models;
/ai model <id>remains flexible. - Changing model while busy applies to the next turn and should show a user-facing notice.
Key storage:
- UI save uses
keyringand system keychain. - Runtime can load saved keys into process environment at startup.
- Env key takes precedence when explicitly set.
- Runtime bootstraps keys from env/keyring.
- Claude SDK loop maps OpenRouter env and builds tool server.
- Tool registration:
- Always:
run_pymol_command,capture_viewer_snapshot - Conditional:
openbio_api_*gateway tools only when OpenBio key is present
- Always:
- OpenBio API base defaults to
https://api.openbio.techunless overridden byOPENBIO_BASE_URL.
- Check
OPENROUTER_API_KEY(orANTHROPIC_AUTH_TOKEN) exists. - Check
PYMOL_AI_DISABLEis not1. - Re-test via OpenRouter key dialog.
- Ensure Python is 3.10+.
- Verify
claude-agent-sdkimport succeeds.
- Confirm provider/key pairing (OpenRouter vs OpenBio keys are not interchangeable).
- Check network/proxy restrictions.
- Retry with known-good key.
- Confirm
OPENBIO_API_KEYis set. - Confirm base URL (
OPENBIO_BASE_URL, if overridden). - Check firewall/proxy/edge restrictions for
api.openbio.tech.
- Install/configure OS keychain backend for
keyring. - If unavailable, use env vars as temporary fallback.
- Run:
brew install netcdf - Add
/opt/homebrew/opt/netcdftoPREFIX_PATHin the install command.
- Run:
brew install glew glm /opt/homebrewinPREFIX_PATHcovers these; ensure it is present.
- Cause: PyQt6 is installed but PyQt5 is not. PyMOL falls back to PyQt6 when PyQt5 is absent, but the chat UI code uses PyQt5-style flat enum access which is incompatible with PyQt6's namespaced enums.
- Fix:
uv pip install --python .venv/bin/python PyQt5 - PyMOL's Qt loader tries PyQt5 first; once installed it will be selected automatically.
- Never log or commit plaintext API keys.
- Never hardcode keys into scripts.
- Prefer UI save flow and keychain storage for end users.
- Use masked key displays for status messaging.
Check Python and AI deps:
python -c "import sys; print(sys.version)"
python -c "import keyring, openai; print('deps ok')"
python -c "import claude_agent_sdk; print('claude sdk ok')"Check environment visibility:
python - <<'PY'
import os
for k in [
'OPENROUTER_API_KEY',
'ANTHROPIC_AUTH_TOKEN',
'OPENBIO_API_KEY',
'OPENBIO_BASE_URL',
'PYMOL_AI_OPENROUTER_KEY_SOURCE',
'PYMOL_AI_OPENBIO_KEY_SOURCE',
]:
v = os.getenv(k)
print(k, 'set' if v else 'unset')
PYExpected outcomes:
- OpenRouter key set -> AI can run.
- OpenBio key set -> OpenBio gateway tools become available.
- OpenBio key unset -> only OpenBio tools are unavailable; core behavior remains.
- Upstream open-source PyMOL rights and trademark notices remain with Schrodinger, LLC.
- PyMolAI fork-specific integration/packaging documentation is maintained in this fork with explicit attribution in
LICENSE,AUTHORS, andDEVELOPERS. - Maintainer contact:
- Website: https://proteinlanguagemodel.com/
- X/Twitter: https://x.com/ravishar313