Python SDK for nxusKit — pure-Python providers with optional SDK-bundle native engines
Project description
nxuskit-py: Python SDK for nxusKit
Pure Python library for the nxusKit polyglot SDK. The public distribution package is nxuskit-py and imports as nxuskit. Pure-Python provider APIs work directly from the package-index wheel; native/FFI engine APIs require an installed compatible nxusKit SDK bundle. Z3 solver and ZEN decision table workflows require nxusKit SDK Pro plus a valid Pro entitlement.
Features
- 11 LLM Providers — Claude, OpenAI, Ollama, xAI Grok, Groq, Mistral, Fireworks, Together, OpenRouter, Perplexity, LM Studio
- Per-Request Model Override — Switch models on any
chat()call:provider.chat(messages, model="gpt-4o-mini") - Tool Calling / Function Calling — Pass tool definitions, receive structured tool call responses
- Streaming — Iterator-based streaming with
is_final()completion detection - Vision / Multimodal — Image input via URL, base64, or file path with auto-detected MIME types
- Model Discovery —
list_models()withsupports_vision(),modalities(),max_images()helpers - Typed Error Handling —
TimeoutError,NetworkError,RateLimitError,AuthenticationError,ProviderError - Retry Utilities —
RetryConfig,retry_with_backoff,AdaptiveRateLimiter - CLIPS / BN / Solver / ZEN — FFI access to nxusKit reasoning engines (native library required; Solver and ZEN require Pro)
Dependencies: requests, cffi (loaded only by FFI paths), keyring (credential storage), PyJWT[crypto] (license tokens)
Installation
Install the pure-Python package from PyPI:
python -m pip install nxuskit-py==1.0.5
python -c "import nxuskit; print(nxuskit.__version__)"
nxuskit-py is the distribution package and nxuskit is the Python import
package. The package-index wheel installs the pure-Python package only; it does
not install native libnxuskit engines, SDK bundles, or Pro command
modules.
The Python package is also shipped inside nxusKit SDK bundles for offline or bundle-local use:
export NXUSKIT_SDK_DIR="$HOME/.nxuskit/sdk/current"
export PYTHONPATH="$NXUSKIT_SDK_DIR/python/src:${PYTHONPATH:-}"
python -c "import nxuskit; print(nxuskit.__version__)"
For FFI-backed features (CLIPS, BN, Solver, ZEN), install the
nxusKit SDK and set
NXUSKIT_SDK_DIR, NXUSKIT_LIB_DIR, or install the SDK at
~/.nxuskit/sdk/current/. CLIPS and Bayesian inference are Community Edition
features where supported by the installed SDK; Solver and ZEN require Pro SDK
features and Pro entitlement.
Quick Start
import nxuskit
# Create a provider (auto-discovers API key from environment)
provider = nxuskit.Provider.claude()
# Simple chat
response = provider.chat([nxuskit.Message.user("What is 2 + 2?")])
print(response.content)
print(f"Tokens: {response.usage.total_tokens}")
Provider is the public factory for concrete provider clients.
LLMProvider is the protocol/type contract implemented by provider clients and
exported for type checking and custom providers; it is intentionally separate
from the Provider factory.
Capability Manifest Preview
The Python package exposes public capability manifest projection types. The public shape carries status values and reviewed-on metadata only; internal evidence records, model overrides, and provider-specific details stay private to the engine registry.
import nxuskit
manifest = nxuskit.PublicCapabilityManifest(
schema_version="capability-manifest-v2-public-preview/1",
posture=nxuskit.ManifestPublicationPosture.SPLIT,
providers=[
nxuskit.PublicProviderCapability(
name="openai",
display_name="OpenAI",
last_reviewed_on="2026-05-09",
provider_status="unknown",
capabilities={
"json_schema_strict": nxuskit.CapabilityStatus.SUPPORTED,
"rerank": nxuskit.CapabilityStatus.FUTURE,
},
)
],
)
print(nxuskit.PUBLIC_CAPABILITY_FIELDS)
print(manifest.to_dict()["providers"][0]["capabilities"]["json_schema_strict"])
Per-Request Model Override
provider = nxuskit.Provider.openai() # default: gpt-4o
# Override model for a single call
response = provider.chat(
[nxuskit.Message.user("Hello")],
model="gpt-4o-mini",
temperature=0.5,
)
Streaming
for chunk in provider.chat_stream([nxuskit.Message.user("Tell me a story")]):
print(chunk.delta, end="", flush=True)
if chunk.is_final():
print(f"\nTokens: {chunk.usage.total_tokens}")
Streaming Logprobs (v0.9.4+)
Per-chunk logprob deltas are now surfaced on streaming responses for
providers that support them (OpenAI). Check the capability flag before
issuing the call; non-supporting providers always emit chunk.logprobs is None
on every chunk (FR-007 — no phantom data).
from nxuskit import Provider, ChatRequest, Role
import asyncio
async def main():
provider = Provider.openai()
if not provider.capabilities().supports_streaming_logprobs:
print("Provider does not support streaming logprobs.")
req = ChatRequest(
model="gpt-5.4",
messages=[{"role": Role.USER, "content": "Say hello."}],
logprobs=True,
top_logprobs=3,
)
async for chunk in provider.chat_stream(req):
print(chunk.delta, end="")
if chunk.logprobs is not None:
for tok in chunk.logprobs.content:
print(f" token={tok.token!r} logprob={tok.logprob:.4f}")
asyncio.run(main())
Tool Calling
weather_tool = nxuskit.ToolDefinition.create(
name="get_weather",
description="Get weather for a location",
parameters={
"type": "object",
"properties": {"location": {"type": "string"}},
"required": ["location"],
},
)
response = provider.chat(
[nxuskit.Message.user("What's the weather in Tokyo?")],
tools=[weather_tool],
tool_choice=nxuskit.tool_choice_auto(),
)
if response.tool_calls:
for call in response.tool_calls:
print(f"Call: {call.function.name}({call.function.arguments})")
Vision
msg = nxuskit.Message.user("What's in this image?").with_image_file("photo.png")
response = provider.chat([msg], model="gpt-4o")
Error Handling
try:
response = provider.chat([nxuskit.Message.user("Hello")])
except nxuskit.TimeoutError:
print("Request timed out — try a faster model")
except nxuskit.NetworkError:
print("Network issue — check connection")
except nxuskit.RateLimitError as e:
print(f"Rate limited — retry after {e.retry_after}s")
except nxuskit.AuthenticationError:
print("Check your API key")
Model Discovery
models = provider.list_models()
for m in models:
vision = "vision" if m.supports_vision() else "text-only"
print(f" {m.name}: {vision}")
Providers
| Provider | Factory | Environment Variable |
|---|---|---|
| Claude | Provider.claude() |
ANTHROPIC_API_KEY |
| OpenAI | Provider.openai() |
OPENAI_API_KEY |
| Ollama | Provider.ollama() |
None (local) |
| xAI Grok | Provider.xai() |
XAI_API_KEY |
| Groq | Provider.groq() |
GROQ_API_KEY |
| Mistral | Provider.mistral() |
MISTRAL_API_KEY |
| Fireworks | Provider.fireworks() |
FIREWORKS_API_KEY |
| Together | Provider.together() |
TOGETHER_API_KEY |
| OpenRouter | Provider.openrouter() |
OPENROUTER_API_KEY |
| Perplexity | Provider.perplexity() |
PERPLEXITY_API_KEY |
| LM Studio | Provider.lmstudio() |
None (local) |
CLIPS Session API
For direct CLIPS rule engine access (requires native library):
from nxuskit.clips import ClipsSession
with ClipsSession() as s:
s.load_json(rules_json)
s.reset()
s.fact_assert_string('(sensor (name "temp") (value 200))')
fired = s.run()
FFI Provider Note
When using FFI-backed features, always use context managers (with statement) for reliable cleanup:
from nxuskit._ffi_provider import create_ffi_provider
with create_ffi_provider({"provider_type": "openai", "api_key": "sk-..."}) as p:
response = p.chat({"model": "gpt-4o", "messages": [...]})
Development
pip install -e ".[dev]"
pytest tests/
ruff check src/ && ruff format --check .
License
Dual-licensed under MIT and Apache 2.0. See the MIT and Apache 2.0 license texts.
See also: nxusKit-examples for runnable examples.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nxuskit_py-1.0.5.tar.gz.
File metadata
- Download URL: nxuskit_py-1.0.5.tar.gz
- Upload date:
- Size: 53.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b567b1e566c6776747f88a2af92bbe93fbec564c436689c4e881acbac45831f7
|
|
| MD5 |
378acf7287c8f94f646448cbe124c3f3
|
|
| BLAKE2b-256 |
b9cbec8a42fb3fd89eb7adb40a0cc7d7d18683cde09e097c1e056bbf13c57936
|
Provenance
The following attestation bundles were made for nxuskit_py-1.0.5.tar.gz:
Publisher:
publish-nxuskit-py-pypi.yml on nxus-SYSTEMS/nxusKit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nxuskit_py-1.0.5.tar.gz -
Subject digest:
b567b1e566c6776747f88a2af92bbe93fbec564c436689c4e881acbac45831f7 - Sigstore transparency entry: 1840358682
- Sigstore integration time:
-
Permalink:
nxus-SYSTEMS/nxusKit@b74f290f1b94b148a4f6b136393e3865f2f3aed6 -
Branch / Tag:
refs/heads/release/sdk-v1.0.5 - Owner: https://github.com/nxus-SYSTEMS
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-nxuskit-py-pypi.yml@b74f290f1b94b148a4f6b136393e3865f2f3aed6 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file nxuskit_py-1.0.5-py3-none-any.whl.
File metadata
- Download URL: nxuskit_py-1.0.5-py3-none-any.whl
- Upload date:
- Size: 74.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
36cd1c8859cf9d1a22965802f448b8517b7af73ecc65d76113a3faeac7b1d592
|
|
| MD5 |
0c260d699d660056e886900acc8a2adf
|
|
| BLAKE2b-256 |
6fa4f4d2466829853edd8cdd1151fce5a11bbb99db0afad2eb564ba6ef7f0363
|
Provenance
The following attestation bundles were made for nxuskit_py-1.0.5-py3-none-any.whl:
Publisher:
publish-nxuskit-py-pypi.yml on nxus-SYSTEMS/nxusKit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nxuskit_py-1.0.5-py3-none-any.whl -
Subject digest:
36cd1c8859cf9d1a22965802f448b8517b7af73ecc65d76113a3faeac7b1d592 - Sigstore transparency entry: 1840358789
- Sigstore integration time:
-
Permalink:
nxus-SYSTEMS/nxusKit@b74f290f1b94b148a4f6b136393e3865f2f3aed6 -
Branch / Tag:
refs/heads/release/sdk-v1.0.5 - Owner: https://github.com/nxus-SYSTEMS
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-nxuskit-py-pypi.yml@b74f290f1b94b148a4f6b136393e3865f2f3aed6 -
Trigger Event:
workflow_dispatch
-
Statement type: