Skip to main content

Dymium SDK for secure data and AI interactions

Project description

Python SDK (Reference)

This is the reference implementation. All other language SDKs must conform to the behavior defined here and in sdk/spec.

Package layout:

  • dymium/core/ Contracts and shared utilities
  • dymium/runtime/ SecureRuntime orchestration loop
  • dymium/adapters/ Provider adapters (LLM, PII, MCP)
  • dymium/tools/ Tool registry and execution boundaries
  • dymium/types/ Generated types from sdk/spec

Hugging Face local PII detector (optional deps):

  • dymium/adapters/pii/huggingface.py (HuggingFacePIIDetector)
  • install extras: pip install "dymium[hf]"

Quick start (factory-based)

from dymium import SecureRuntime, RuntimeConfig

config = RuntimeConfig(
    model="openai:gpt-5",
    pii="dymium_hf",
    model_config={"api_key": "..."},
    pii_config={"model_id": "dymium/Dymium-NER-v1"},
    mcp={"base_url": "http://localhost:7000"},
)

runtime = SecureRuntime.from_config(config)

# Optional: stateful multi-turn session
session = runtime.session()
result = session.run("Hello! My SSN is 123-45-6789.")

Multiple MCP servers

from dymium import SecureRuntime, RuntimeConfig

config = RuntimeConfig(
    model="openai:gpt-5",
    pii="dymium_hf",
    model_config={"api_key": "..."},
    pii_config={"model_id": "dymium/Dymium-NER-v1"},
    mcp={
        "servers": [
            {"name": "ghost", "adapter": "mcp", "base_url": "http://ghostmcp.local", "api_key": "..."},
            {"name": "ext", "adapter": "mcp", "base_url": "http://localhost:7001"},
        ],
        "prefix_tools": True,
        "separator": "::",
    },
)

runtime = SecureRuntime.from_config(config)

Multi-turn (session)

from dymium import SecureRuntime, RuntimeConfig

runtime = SecureRuntime.from_config(RuntimeConfig(
    model="openai:gpt-5",
    pii="dymium_hf",
    model_config={"api_key": "..."},
    pii_config={"model_id": "dymium/Dymium-NER-v1"},
    mcp={"base_url": "http://localhost:7000"},
))

session = runtime.session()
session.run("My email is me@example.com.")
session.run("Can you summarize what I told you?")

Tool types (direct vs delegated)

Every tool must declare tool_type.

direct tools are non-agentic boundaries (local functions, DB/API calls, deterministic services).
direct tools must also declare input_mode:

  • resolve: materialize originals only at execution time. Common resolve cases: identity/account lookups, order/ticket retrieval APIs, and parameterized DB queries keyed by sensitive identifiers.
  • protect: keep placeholders in direct tool args.

delegated tools are agentic handoffs to another runtime (sub-agent or remote agent). Unlike direct, delegated handoffs cross into another LLM/tool loop outside the parent loop. Dymium keeps inputs protected and forwards runtime context instead of resolving originals at the parent boundary.

Policy location:

  • SecureRuntime: set tool_type (and input_mode for direct tools) on each tool definition.
  • Framework integrations: set tool.metadata["dymium"]["tool_type"] and tool.metadata["dymium"]["input_mode"] (required for direct tools).

Delegated handoffs use transport-managed delegation (delegated_transport / DelegatedTransport). Delegated context is runtime-managed by Dymium.

For SecureRuntime, delegated cross-instance calls can be automatic with delegated_transport on a local delegated tool (no custom handler needed). The runtime forwards dymium_context, including placeholderMap.

Remote delegated targets must also run Dymium security (another SecureRuntime instance or an integration path using Dymium sanitizer/middleware) to stay in the same security plane.

For integration-managed tools (LangChain/LangGraph/LlamaIndex), use DelegatedTransport. Keep tool signatures business-only; Dymium owns delegated context propagation internally. DelegatedTransport.as_tool_handler() is the simplest path for remote delegated calls without manual context plumbing.

Install (local dev)

From SDK/python:

pip install -e .

Examples

The examples/ directory includes four runnable demos:

  • examples/secure_runtime_demo.py
  • examples/langchain_demo.py
  • examples/langgraph_demo.py
  • examples/llamaindex_demo.py

All four examples use Dymium's Hugging Face detector with model id default:

  • dymium/Dymium-NER-v1 (override with DYMIUM_PII_MODEL)

Example focus:

  • secure_runtime_demo.py: runtime-config path with direct protect/resolve tools and a local delegated specialist tool.
  • langchain_demo.py: middleware integration with direct protect/resolve tools and a local delegated specialist tool.
  • langgraph_demo.py: graph integration with direct protect/resolve tools and a local delegated specialist tool.
  • llamaindex_demo.py: workflow integration with direct protect/resolve tools and a local delegated specialist tool.

Run from SDK/python:

python examples/secure_runtime_demo.py
python examples/langchain_demo.py
python examples/langgraph_demo.py
python examples/llamaindex_demo.py

Publish (PyPI)

python -m build
twine upload dist/*

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dymium-0.1.3.tar.gz (62.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dymium-0.1.3-py3-none-any.whl (93.8 kB view details)

Uploaded Python 3

File details

Details for the file dymium-0.1.3.tar.gz.

File metadata

  • Download URL: dymium-0.1.3.tar.gz
  • Upload date:
  • Size: 62.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for dymium-0.1.3.tar.gz
Algorithm Hash digest
SHA256 1bd4a37d59ab467e3a3aff2064d0c974442dee72141a6edf2bda3610bb60bee1
MD5 8bb42086c020e8fc5c8707747c4e1965
BLAKE2b-256 3adea3777e15ac7e2432e6845649fe3d6f4e41cebd0439eed56947f94924c16f

See more details on using hashes here.

Provenance

The following attestation bundles were made for dymium-0.1.3.tar.gz:

Publisher: release-python.yml on dymium-io/Dymium-SDK

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dymium-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: dymium-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 93.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for dymium-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 9d0853ccd641ef26707e32e69e4ee8a5f6dcfea8bb5dd297721c77af60255dd9
MD5 0781dc1624ab46512e04d9582534df73
BLAKE2b-256 a4a2010124d698e785583431e27cd05bca3ddd78085f4ae4c0bda80faebb8f8b

See more details on using hashes here.

Provenance

The following attestation bundles were made for dymium-0.1.3-py3-none-any.whl:

Publisher: release-python.yml on dymium-io/Dymium-SDK

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page