Trame LLM
LLM helpers and components for trame
License
This library is OpenSource and follow the Apache Software License
Installation
Install the library with the extra for your client:
pip install "trame-llm[vue]" # Vue apps (Vuetify)
pip install "trame-llm[react]" # React apps (MUI)
Configuration
trame-llm works with any OpenAI-compatible API. Environment variables (or a .env file) choose the provider and model the app starts with:
Variable |
Description |
|---|---|
LLM_PROVIDER |
openai (default), anthropic, gemini, nim, llama or claude-code |
LLM_MODEL |
Model name; each provider has a default (see below) |
LLM_API_KEY |
API key for the chosen provider |
LLM_BASEURL |
API endpoint for the chosen provider, for example a local server |
Each provider also reads its own key variable, so several can be ready at once:
Provider |
Key variable |
Default model |
|---|---|---|
openai |
OPENAI_API_KEY |
gpt-4o |
anthropic |
ANTHROPIC_API_KEY |
claude-opus-4-5 |
gemini |
GEMINI_API_KEY |
gemini-2.0-flash |
nim |
NVIDIA_API_KEY |
meta/llama-3.3-70b-instruct |
llama (Ollama, LM Studio) |
none needed |
llama3 |
Example .env for Ollama:
LLM_PROVIDER=llama LLM_MODEL=qwen3-coder-next:q4_K_M LLM_BASEURL=http://localhost:11434/v1
While the app runs, LLMClient.select(provider=..., model=..., api_key=..., base_url=...) switches provider or model and keeps the conversation, and llm.ModelPicker(llm_client=...) gives users a form for it. The picker never sends API keys to the browser; it only shows whether a key is set.
Conversations
The chat panel keeps several conversations, each with its own model history, and saves each one after every turn as a JSON file in ~/.trame-llm/conversations/<app_name>. Pass conversations_dir to save them elsewhere, or conversations_dir=False to keep them in memory. The list in the panel switches, renames, pins and deletes conversations. A reply always lands in the conversation that asked for it, even if the user has switched to another one meanwhile. Each turn’s steps (tool calls, their results and progress notes) fold into one collapsible block, so the request and the reply stay easy to follow. Apps driving the client directly can do the same with llm_client.process_prompt(prompt, messages=..., progress=...).
MCP servers
An app gives the model tools by registering MCP servers. A controller object with an mcp property runs in the app’s own process; a running server is reached by URL (streamable HTTP, or SSE for URLs ending in /sse):
llm_client.register_mcp(controller)
await llm_client.add_mcp_server("http://localhost:8765/mcp")
llm_client.set_tool_enabled("multiply", False)
llm.McpServers(llm_client=...) lets users do the same: add a server by URL, reconnect or remove it, and turn its tools on or off.
Claude Code
The claude-code provider runs each turn through Claude Code with the Claude login on the machine running the app, so people can use their Claude plan instead of an API key.
Set it up on the machine that runs the app:
Install the extra. It brings the Agent SDK, which bundles Claude Code:
pip install "trame-llm[claude]"Sign in with your Claude account. The command prints a link; over SSH, open it in your local browser and paste the code back. status shows who is signed in.
python -m trame_llm.claude_code login python -m trame_llm.claude_code statusStart the app with LLM_PROVIDER=claude-code (and LLM_MODEL set to sonnet, opus or haiku), or choose “Claude Code” in the model picker.
On a server where an interactive login is awkward, python -m trame_llm.claude_code setup-token creates a long-lived token; give it to the app as CLAUDE_CODE_OAUTH_TOKEN.
Claude Code can only call the app’s MCP tools: its own tools (shell, files, web) are off, the user’s Claude Code settings are not loaded, and tools turned off in the MCP servers panel are denied. Each conversation resumes its Claude Code session. One login serves everyone using the app, so this suits a local app or one process per user. Programmatic use of Claude Code draws on the plan’s Agent SDK allowance; check Anthropic’s current terms.
Message colors
Each message has a tone that names its meaning: user, assistant, info, tool, success, warning or error. The Vue and React panels both color messages from the matching CSS variable, so an app can restyle them in one place:
:root {
--trame-llm-assistant: #d1c4e9;
}
Examples
examples/widgets/app.py shows the chat panel with a sample conversation that covers each message style, and the model picker in the app bar. Run it with the Vue or the React client:
python examples/widgets/app.py
python examples/widgets/app.py --react
From a source checkout, build the React components first with npm ci && npm run build in react-components.
examples/widgets/mcp_server.py is a small MCP server to add by URL (http://localhost:8765/mcp). examples/cone/app.py drives a VTK cone through an MCP server.
Development setup
We recommend using uv for setting up and managing a virtual environment for your development.
# Create venv and install all dependencies
uv sync --all-extras --dev
# Activate environment
source .venv/bin/activate
# Install commit analysis
pre-commit install
pre-commit install --hook-type commit-msg
# Allow live code edit
uv pip install -e .
For running tests and checks, you can run nox.
# run all
nox
# lint
nox -s lint
# tests
nox -s tests
Professional Support
Training: Learn how to confidently use trame from the expert developers at Kitware.
Support: Our experts can assist your team as you build your web application and establish in-house expertise.
Custom Development: Leverage Kitware’s 25+ years of experience to quickly build your web application.
Metadata
Release files for trame-llm 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| trame_llm-1.0.0.tar.gz | 41.1 kB | With provenance | Details for trame_llm-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| trame_llm-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for trame_llm-1.0.0-py3-none-any.whl |
Total release size: 86.9 kB
Release files / trame_llm-1.0.0.tar.gz
| Download URL | trame_llm-1.0.0.tar.gz |
|---|---|
| Size | 41.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
844f0630fb3713023b6390545e9eef5bb5b31b5ab3ca0ea39947a679cde54e75
|
|
BLAKE2b-256 checksum How to use checksums |
a52f2b6ad3eb70cf7a71fc62b9912126ce4264211f19652d7c35d0b2aeea1183
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 4, 2026.
Transparency logRelease files / trame_llm-1.0.0-py3-none-any.whl
| Download URL | trame_llm-1.0.0-py3-none-any.whl |
|---|---|
| Size | 45.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
64aa8fa415186dac7a9fd0264e3a52f460e8f3b8d98c5b0df5413f709fa8a6ad
|
|
BLAKE2b-256 checksum How to use checksums |
502751ed561e5ed033151dcc728a3b0d3cad5a200a2bdf825e157d967838516c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 4, 2026.
Transparency logSecurity for trame-llm 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for trame_llm-1.0.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 4, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.