Skip to main content

Prism

PyPI License: MIT Python 3.11+

Combine local and cloud models behind one OpenAI-compatible API. Define connections once in models/, combine them in profiles/, and start a profile. Your application receives one assistant response.

Prism can send a small model's notes to a stronger model, have a vision model interpret an image before text synthesis, or draft and review an answer. Use the same OpenAI client for every workflow. Prism is part of MirrorNeuron and also runs independently.

Quick start: get your first answer

Profile commands require version 0.4.0 or later. Install this checkout from source with Python 3.11+; version 0.3.1 has the older serve --config interface.

git clone https://github.com/homerquan/mirrorneuron-prism.git
cd mirrorneuron-prism
python -m pip install .
export OPENROUTER_API_KEY='your-openrouter-key'
export PRISM_API_KEY='your-prism-client-secret'
prism start --profile prism-balanced

The repository already includes the model and profile files. First startup prepares Laya's CPU routing checkpoint and may download weights. The server is ready at http://127.0.0.1:8080 after startup completes. This profile uses OpenRouter models with explicit :free IDs; upstream availability and quotas apply.

In another terminal, set the same PRISM_API_KEY and send a request:

curl --fail-with-body http://127.0.0.1:8080/v1/chat/completions \
  -H "Authorization: Bearer $PRISM_API_KEY" -H 'Content-Type: application/json' \
  -d '{"model":"prism-balanced","messages":[{"role":"user","content":"Explain Python decorators in three sentences."}],"max_completion_tokens":4096}'

To create a separate deployment directory after installation:

mkdir prism-demo && cd prism-demo
prism init --preset openrouter
prism start --profile prism-balanced

init writes models/ and profiles/ and never overwrites existing files. Use --preset openai, claude, gemini, local, or providers for other samples. Cloud keys are read from environment variables.

Choose your provider and workflow

Set PRISM_API_KEY plus the upstream key, then start one of these included profiles:

Profile Work performed Upstream key
prism-openai-direct One OpenAI Luna call OPENAI_API_KEY
prism-openai OpenAI Luna extracts evidence; Astra finishes when needed OPENAI_API_KEY
prism-claude-direct / prism-claude Haiku alone / Haiku evidence → Opus ANTHROPIC_API_KEY
prism-gemini-direct / prism-gemini Flash-Lite alone / Flash-Lite evidence → Flash GEMINI_API_KEY
nano-openai Free Nano text preparation → OpenAI Astra OPENROUTER_API_KEY + OPENAI_API_KEY
prism-openai-reviewed Luna draft → Astra review → Astra answer OPENAI_API_KEY
prism-vision-reasoning Free Nano image observations → free Super answer OPENROUTER_API_KEY
prism-local-direct Docker Model Runner Gemma4 at localhost:12434 None upstream
prism Local Gemma preparation → Spark Nemotron when needed; zero token rates None upstream
prism-openrouter Free Super evidence → free Ultra when needed OPENROUTER_API_KEY
export OPENAI_API_KEY='your-openai-key'
prism start --profile prism-openai --show-cost

The request's model must match the started profile's id. Only that profile is served, and only its referenced models are loaded. Other providers' keys are unnecessary. auto prefers a fitting direct request; evidence routing needs explicit source blocks. See usage and sources.

Native provider examples use real SDK transports and documented model IDs. They have configuration and local protocol-fixture coverage; live paid-provider qualification remains account specific. Provider samples and sources.

Define once, combine freely

Each models/MODEL_ID.json holds its physical name, provider, endpoint, environment key, timeouts, inference defaults, capabilities, token bounds, concurrency, and optional prices. Each profiles/NAME.json holds model references and workflow limits. Connection settings stay in the model file.

models/
  openai-small.json
  openai-strong.json
  claude-small.json
  gemini-small.json
profiles/
  prism-openai-direct.json
  prism-openai.json
  prism-openai-reviewed.json

Copy a profile, change its id and stage model IDs, then start it by name or path:

prism profiles
prism models --profile prism-openai
prism validate --profile profiles/prism-openai.json
prism start --profile profiles/prism-openai.json

Copyable model and profile definitions. Existing combined configurations still work through prism serve --config PATH.

See token spend and estimated savings

In a model definition, set both prices in USD per million tokens:

"input_cost_per_million": "$1/m",
"output_cost_per_million": "$5/m"

Numbers such as 1 and 5 also work. prism start --profile NAME --show-cost opens a full-screen terminal dashboard with cumulative spend, estimated savings in dollars and percent, input/output tokens, and usage per model. It refreshes while requests run; Ctrl+C stops the server, restores the terminal, and prints a final summary. --json or redirected output keeps ordinary JSON reports. Spend uses each physical call's provider-reported input and output tokens and that model's configured rates, including all mixing stages and server-side capacity probes. Missing prices or usage keep the total visibly incomplete.

Savings compare completed, fully priced requests with the profile's final/direct model (or cost_baseline_model). Mixed routes estimate the original text input with a shared tokenizer and reuse the final reported output count. Identical direct routes show zero savings; higher mixing cost shows negative savings. Image requests and requests that cannot fit the baseline are excluded from estimates. Free profiles retain zero rates. These are token-cost estimates, without provider discounts or a claim of equal answer quality. Calculation and API details.

To try the dashboard with real OpenRouter calls and hypothetical prices:

prism start --profile prism-mock-cost --show-cost --no-auth
# In another terminal, from this checkout:
python examples/standalone/cost_demo.py --no-auth

Set OPENROUTER_API_KEY before starting Prism. The demo uses OpenRouter's free Nemotron Super worker and Ultra final model with separate, explicitly hypothetical rates. Only the prices are simulated; responses and reported tokens are real. Regular OpenRouter model definitions retain zero rates, and prism remains the local Gemma/Spark profile. The demo ships with prism init --preset openrouter; rates and a copyable request.

Keep your OpenAI client

import os
from openai import OpenAI

client = OpenAI(base_url="http://127.0.0.1:8080/v1", api_key=os.environ["PRISM_API_KEY"])
answer = client.chat.completions.create(
    model="prism-balanced",
    messages=[{"role": "user", "content": "Return JSON with ok=true."}],
    response_format={"type": "json_object"},
    max_completion_tokens=4096,
)
print(answer.choices[0].message.content)

Install the client with python -m pip install openai. Prism supports Chat Completions, text, image understanding, direct tool calls, JSON validation, and SSE. Multi-stage and JSON-constrained streams are buffered until validation. Responses, image generation, audio, and video are not implemented. Preparation can lose information; evaluate your workload before relying on a combination.

Run with Docker

docker build -t mirrorneuron-prism:dev .
docker run --rm -p 127.0.0.1:8080:8080 \
  -e OPENROUTER_API_KEY -e PRISM_API_KEY \
  -v prism-huggingface:/home/prism/.cache/huggingface \
  mirrorneuron-prism:dev

Or use docker compose up --build. The image starts prism-balanced. Custom profiles, caching, and auth.

Inspect and develop

prism doctor --profile prism-balanced --probe-backends
prism capacity --profile prism-balanced
prism trace show prism-REQUEST_ID

Doctor/capacity make real upstream calls. Capabilities in model JSON are declarations; capacity reports live observations. Terminal output uses tables; redirected output is JSON. Use --json or NO_COLOR=1 explicitly.

Usage · Execution policies · Cost tracking · Benchmarking · Implemented contract · Contributing

python -m pip install '.[dev]'
ruff check src tests examples
python -m pytest -q
python -m pytest tests/standalone -q -m integration -o addopts=''
python -m build
python -m twine check dist/*

Deterministic HTTP and decision fixtures are confined to tests. Production backends call the configured provider; upstream failures remain visible. See the live pilot for measured quality, cost, and latency tradeoffs. Prism is alpha software, licensed under MIT.

Metadata

Release files for mirrorneuron-prism 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mirrorneuron-prism 0.4.0
File Size Uploaded
mirrorneuron_prism-0.4.0.tar.gz 528.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mirrorneuron-prism 0.4.0
File Interpreter ABI Platform
mirrorneuron_prism-0.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 681.6 kB

Release files / mirrorneuron_prism-0.4.0.tar.gz

Download URL mirrorneuron_prism-0.4.0.tar.gz
Size 528.3 kB
Tags Source
SHA-256 checksum
How to use checksums
332489088c6de0740e77ed26a5394a91a6ee0cd67d3c6b4ba4fb791149daa2b8
BLAKE2b-256 checksum
How to use checksums
223b8b4b9315fa215d87e5a171505a92aa980d022647d276846976622d6c66d0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 5, 2026.

Transparency log

Release files / mirrorneuron_prism-0.4.0-py3-none-any.whl

Download URL mirrorneuron_prism-0.4.0-py3-none-any.whl
Size 153.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6bc93bf65c84ab6fd31b162ba88889ce8d9efbd79d63b447aa789b37a257600e
BLAKE2b-256 checksum
How to use checksums
3de6e587b025832e0b83f0c940e991b0c46880a2eadd3d4cdd5a2ab72a290caf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 5, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.4.0 This release

2 release files

0.3.1

2 release files

0.3.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page