nxuskit-py 1.0.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. nxuskit_py-1.0.3/.gitignore +73 -0
  2. nxuskit_py-1.0.3/LICENSE +14 -0
  3. nxuskit_py-1.0.3/NOTICE +10 -0
  4. nxuskit_py-1.0.3/PKG-INFO +302 -0
  5. nxuskit_py-1.0.3/README.md +266 -0
  6. nxuskit_py-1.0.3/pyproject.toml +91 -0
  7. nxuskit_py-1.0.3/src/nxuskit/__init__.py +287 -0
  8. nxuskit_py-1.0.3/src/nxuskit/__init__.pyi +248 -0
  9. nxuskit_py-1.0.3/src/nxuskit/_bn_ffi.py +64 -0
  10. nxuskit_py-1.0.3/src/nxuskit/_clips_ffi.py +61 -0
  11. nxuskit_py-1.0.3/src/nxuskit/_ffi.py +431 -0
  12. nxuskit_py-1.0.3/src/nxuskit/_ffi_errors.py +79 -0
  13. nxuskit_py-1.0.3/src/nxuskit/_ffi_provider.py +263 -0
  14. nxuskit_py-1.0.3/src/nxuskit/_ffi_types.py +124 -0
  15. nxuskit_py-1.0.3/src/nxuskit/_solver_ffi.py +61 -0
  16. nxuskit_py-1.0.3/src/nxuskit/_version.py +5 -0
  17. nxuskit_py-1.0.3/src/nxuskit/_zen_ffi.py +61 -0
  18. nxuskit_py-1.0.3/src/nxuskit/auth.py +323 -0
  19. nxuskit_py-1.0.3/src/nxuskit/auth_oauth.py +125 -0
  20. nxuskit_py-1.0.3/src/nxuskit/bn.py +485 -0
  21. nxuskit_py-1.0.3/src/nxuskit/clips.py +547 -0
  22. nxuskit_py-1.0.3/src/nxuskit/errors.py +85 -0
  23. nxuskit_py-1.0.3/src/nxuskit/libs/README.md +37 -0
  24. nxuskit_py-1.0.3/src/nxuskit/license.py +308 -0
  25. nxuskit_py-1.0.3/src/nxuskit/message.py +45 -0
  26. nxuskit_py-1.0.3/src/nxuskit/mock.py +84 -0
  27. nxuskit_py-1.0.3/src/nxuskit/plugin_trust.py +127 -0
  28. nxuskit_py-1.0.3/src/nxuskit/provider.py +97 -0
  29. nxuskit_py-1.0.3/src/nxuskit/providers/__init__.py +5 -0
  30. nxuskit_py-1.0.3/src/nxuskit/providers/base.py +209 -0
  31. nxuskit_py-1.0.3/src/nxuskit/providers/claude.py +378 -0
  32. nxuskit_py-1.0.3/src/nxuskit/providers/factory.py +329 -0
  33. nxuskit_py-1.0.3/src/nxuskit/providers/fireworks.py +41 -0
  34. nxuskit_py-1.0.3/src/nxuskit/providers/groq.py +41 -0
  35. nxuskit_py-1.0.3/src/nxuskit/providers/lmstudio.py +48 -0
  36. nxuskit_py-1.0.3/src/nxuskit/providers/mistral.py +41 -0
  37. nxuskit_py-1.0.3/src/nxuskit/providers/ollama.py +288 -0
  38. nxuskit_py-1.0.3/src/nxuskit/providers/openai.py +41 -0
  39. nxuskit_py-1.0.3/src/nxuskit/providers/openai_compatible.py +310 -0
  40. nxuskit_py-1.0.3/src/nxuskit/providers/openrouter.py +44 -0
  41. nxuskit_py-1.0.3/src/nxuskit/providers/perplexity.py +41 -0
  42. nxuskit_py-1.0.3/src/nxuskit/providers/together.py +41 -0
  43. nxuskit_py-1.0.3/src/nxuskit/providers/xai.py +41 -0
  44. nxuskit_py-1.0.3/src/nxuskit/py.typed +0 -0
  45. nxuskit_py-1.0.3/src/nxuskit/retry.py +308 -0
  46. nxuskit_py-1.0.3/src/nxuskit/security.py +144 -0
  47. nxuskit_py-1.0.3/src/nxuskit/solver.py +407 -0
  48. nxuskit_py-1.0.3/src/nxuskit/solver_types.py +396 -0
  49. nxuskit_py-1.0.3/src/nxuskit/streaming.py +218 -0
  50. nxuskit_py-1.0.3/src/nxuskit/tools.py +124 -0
  51. nxuskit_py-1.0.3/src/nxuskit/types.py +548 -0
  52. nxuskit_py-1.0.3/src/nxuskit/vision.py +259 -0
  53. nxuskit_py-1.0.3/src/nxuskit/zen.py +91 -0
@@ -0,0 +1,73 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ *.so
6
+ .Python
7
+ build/
8
+ develop-eggs/
9
+ dist/
10
+ downloads/
11
+ eggs/
12
+ .eggs/
13
+ lib/
14
+ lib64/
15
+ parts/
16
+ sdist/
17
+ var/
18
+ wheels/
19
+ pip-wheel-metadata/
20
+ share/python-wheels/
21
+ *.egg-info/
22
+ .installed.cfg
23
+ *.egg
24
+ MANIFEST
25
+ .venv/
26
+ venv/
27
+ ENV/
28
+ env/
29
+ .venv*
30
+ *.venv
31
+
32
+ # Virtual environment directories
33
+ .venv/
34
+ venv/
35
+ ENV/
36
+ env/
37
+
38
+ # PyCharm
39
+ .idea/
40
+ *.iml
41
+
42
+ # mypy
43
+ .mypy_cache/
44
+ .dmypy.json
45
+ dmypy.json
46
+
47
+ # Pytest
48
+ .pytest_cache/
49
+ .coverage
50
+ htmlcov/
51
+ .coverage.*
52
+ coverage.xml
53
+
54
+ # Testing
55
+ .tox/
56
+ .nox/
57
+
58
+ # IDE
59
+ .vscode/
60
+ *.swp
61
+ *.swo
62
+
63
+ # OS
64
+ .DS_Store
65
+ Thumbs.db
66
+
67
+ # Environment
68
+ .env
69
+ .env.local
70
+ .env.*.local
71
+
72
+ # Build artifacts
73
+ *.dist-info/
@@ -0,0 +1,14 @@
1
+ nxuskit Python package license
2
+
3
+ The nxuskit Python package is distributed under either of:
4
+
5
+ - MIT License
6
+ - Apache License, Version 2.0
7
+
8
+ At the user's option, the package may be used under either license. The full
9
+ license texts for the nxusKit project are available in the source repository:
10
+
11
+ - MIT: https://github.com/nxus-SYSTEMS/nxusKit/blob/sdk-v1.0.3/LICENSE-MIT
12
+ - Apache 2.0: https://github.com/nxus-SYSTEMS/nxusKit/blob/sdk-v1.0.3/LICENSE-APACHE
13
+
14
+ Copyright (c) 2026 nxus.SYSTEMS LLC.
@@ -0,0 +1,10 @@
1
+ nxuskit Python package
2
+ Copyright 2026 nxus.SYSTEMS LLC
3
+
4
+ This Python distribution contains the pure-Python nxuskit package. It does not
5
+ include native libnxuskit binaries or Pro engine binaries. Native/FFI engine
6
+ features require an installed nxusKit SDK bundle, which carries its own license
7
+ and notice material.
8
+
9
+ Runtime dependencies are declared in pyproject.toml and are installed as their
10
+ own Python distributions with their own license metadata.
@@ -0,0 +1,302 @@
1
+ Metadata-Version: 2.4
2
+ Name: nxuskit-py
3
+ Version: 1.0.3
4
+ Summary: Python SDK for nxusKit — pure-Python providers with optional SDK-bundle native engines
5
+ Project-URL: Homepage, https://github.com/nxus-SYSTEMS/nxusKit
6
+ Project-URL: Documentation, https://github.com/nxus-SYSTEMS/nxusKit
7
+ Project-URL: Repository, https://github.com/nxus-SYSTEMS/nxusKit
8
+ Project-URL: Issues, https://github.com/nxus-SYSTEMS/nxusKit/issues
9
+ Author: nxusKit Contributors
10
+ License-Expression: MIT OR Apache-2.0
11
+ License-File: LICENSE
12
+ License-File: NOTICE
13
+ Keywords: api,bayesian,claude,clips,fireworks,function-calling,grok,groq,llm,mistral,ollama,openai,perplexity,solver,streaming,together,tool-calling,vision,xai
14
+ Classifier: Development Status :: 4 - Beta
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: License :: OSI Approved :: Apache Software License
17
+ Classifier: License :: OSI Approved :: MIT License
18
+ Classifier: Operating System :: OS Independent
19
+ Classifier: Programming Language :: Python :: 3
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Programming Language :: Python :: 3.13
23
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
24
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
25
+ Requires-Python: >=3.11
26
+ Requires-Dist: cffi>=2.0.0
27
+ Requires-Dist: keyring>=25.7.0
28
+ Requires-Dist: pyjwt[crypto]>=2.12.0
29
+ Requires-Dist: requests>=2.32.0
30
+ Provides-Extra: dev
31
+ Requires-Dist: pytest-cov>=7.0.0; extra == 'dev'
32
+ Requires-Dist: pytest-httpserver>=1.0.0; extra == 'dev'
33
+ Requires-Dist: pytest>=9.0.0; extra == 'dev'
34
+ Requires-Dist: ruff>=0.15.0; extra == 'dev'
35
+ Description-Content-Type: text/markdown
36
+
37
+ # nxuskit-py: Python SDK for nxusKit
38
+
39
+ [![SDK bundle](https://img.shields.io/badge/distribution-SDK%20bundle-blue.svg)](https://github.com/nxus-SYSTEMS/nxusKit/releases)
40
+ [![Python 3.11+](https://img.shields.io/badge/python-3.11+-blue.svg)](https://www.python.org/downloads/)
41
+ [![License: MIT OR Apache-2.0](https://img.shields.io/badge/license-MIT%20OR%20Apache--2.0-blue.svg)](https://github.com/nxus-SYSTEMS/nxusKit/blob/sdk-v1.0.3/LICENSE)
42
+
43
+ Pure Python library for the [nxusKit](https://github.com/nxus-SYSTEMS/nxusKit) polyglot SDK. The public distribution package is `nxuskit-py` and imports as `nxuskit`. Pure-Python provider APIs work from the Python package; native/FFI engine APIs require an installed nxusKit SDK bundle. Z3 solver and ZEN decision table workflows require nxusKit SDK Pro.
44
+
45
+ ## Features
46
+
47
+ - **11 LLM Providers** — Claude, OpenAI, Ollama, xAI Grok, Groq, Mistral, Fireworks, Together, OpenRouter, Perplexity, LM Studio
48
+ - **Per-Request Model Override** — Switch models on any `chat()` call: `provider.chat(messages, model="gpt-4o-mini")`
49
+ - **Tool Calling / Function Calling** — Pass tool definitions, receive structured tool call responses
50
+ - **Streaming** — Iterator-based streaming with `is_final()` completion detection
51
+ - **Vision / Multimodal** — Image input via URL, base64, or file path with auto-detected MIME types
52
+ - **Model Discovery** — `list_models()` with `supports_vision()`, `modalities()`, `max_images()` helpers
53
+ - **Typed Error Handling** — `TimeoutError`, `NetworkError`, `RateLimitError`, `AuthenticationError`, `ProviderError`
54
+ - **Retry Utilities** — `RetryConfig`, `retry_with_backoff`, `AdaptiveRateLimiter`
55
+ - **CLIPS / BN / Solver / ZEN** — FFI access to nxusKit reasoning engines (native library required; Solver and ZEN require Pro)
56
+
57
+ **Dependencies**: `requests`, `cffi` (FFI), `keyring` (credential storage), `PyJWT[crypto]` (license tokens)
58
+
59
+ ## Installation
60
+
61
+ Until package-index publication is complete and smoke-verified, use the Python
62
+ package shipped inside an extracted nxusKit SDK bundle:
63
+
64
+ ```bash
65
+ export NXUSKIT_SDK_DIR="$HOME/.nxuskit/sdk/current"
66
+ export PYTHONPATH="$NXUSKIT_SDK_DIR/python/src:${PYTHONPATH:-}"
67
+ python -c "import nxuskit; print(nxuskit.__version__)"
68
+ ```
69
+
70
+ `nxuskit-py` is the TestPyPI/PyPI distribution target and `nxuskit` is the
71
+ Python import package. TestPyPI verification uses the package index explicitly:
72
+
73
+ ```bash
74
+ python -m pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ nxuskit-py==1.0.3
75
+ python -c "import nxuskit; print(nxuskit.__version__)"
76
+ ```
77
+
78
+ After the production PyPI package is published and smoke-verified, installing
79
+ from PyPI becomes the recommended package-index path. The package-index wheel
80
+ installs the Python package only; it does **not** install native `libnxuskit`
81
+ engines.
82
+
83
+ For FFI features (CLIPS, BN, Solver, ZEN), install the
84
+ [nxusKit SDK](https://github.com/nxus-SYSTEMS/nxusKit/releases) and set
85
+ `NXUSKIT_SDK_DIR`, `NXUSKIT_LIB_DIR`, or install the SDK at
86
+ `~/.nxuskit/sdk/current/`. CLIPS and Bayesian inference are Community Edition
87
+ features where supported by the installed SDK; Solver and ZEN require Pro SDK
88
+ features and Pro entitlement.
89
+
90
+ ## Quick Start
91
+
92
+ ```python
93
+ import nxuskit
94
+
95
+ # Create a provider (auto-discovers API key from environment)
96
+ provider = nxuskit.Provider.claude()
97
+
98
+ # Simple chat
99
+ response = provider.chat([nxuskit.Message.user("What is 2 + 2?")])
100
+ print(response.content)
101
+ print(f"Tokens: {response.usage.total_tokens}")
102
+ ```
103
+
104
+ ## Capability Manifest Public Preview
105
+
106
+ The Python package exposes the stable public Capability Manifest v2 projection
107
+ types. The public shape carries status values and reviewed-on metadata only;
108
+ internal evidence records, model overrides, and provider-specific details stay
109
+ private to the engine registry.
110
+
111
+ ```python
112
+ import nxuskit
113
+
114
+ manifest = nxuskit.PublicCapabilityManifest(
115
+ schema_version="capability-manifest-v2-public-preview/1",
116
+ posture=nxuskit.ManifestPublicationPosture.SPLIT,
117
+ providers=[
118
+ nxuskit.PublicProviderCapability(
119
+ name="openai",
120
+ display_name="OpenAI",
121
+ last_reviewed_on="2026-05-09",
122
+ provider_status="unknown",
123
+ capabilities={
124
+ "json_schema_strict": nxuskit.CapabilityStatus.SUPPORTED,
125
+ "rerank": nxuskit.CapabilityStatus.FUTURE,
126
+ },
127
+ )
128
+ ],
129
+ )
130
+
131
+ print(nxuskit.PUBLIC_CAPABILITY_FIELDS)
132
+ print(manifest.to_dict()["providers"][0]["capabilities"]["json_schema_strict"])
133
+ ```
134
+
135
+ ## Per-Request Model Override
136
+
137
+ ```python
138
+ provider = nxuskit.Provider.openai() # default: gpt-4o
139
+
140
+ # Override model for a single call
141
+ response = provider.chat(
142
+ [nxuskit.Message.user("Hello")],
143
+ model="gpt-4o-mini",
144
+ temperature=0.5,
145
+ )
146
+ ```
147
+
148
+ ## Streaming
149
+
150
+ ```python
151
+ for chunk in provider.chat_stream([nxuskit.Message.user("Tell me a story")]):
152
+ print(chunk.delta, end="", flush=True)
153
+ if chunk.is_final():
154
+ print(f"\nTokens: {chunk.usage.total_tokens}")
155
+ ```
156
+
157
+ ### Streaming Logprobs (v0.9.4+)
158
+
159
+ Per-chunk logprob deltas are now surfaced on streaming responses for
160
+ providers that support them (OpenAI). Check the capability flag before
161
+ issuing the call; non-supporting providers always emit `chunk.logprobs is None`
162
+ on every chunk (FR-007 — no phantom data).
163
+
164
+ ```python
165
+ from nxuskit import Provider, ChatRequest, Role
166
+ import asyncio
167
+
168
+ async def main():
169
+ provider = Provider.openai()
170
+
171
+ if not provider.capabilities().supports_streaming_logprobs:
172
+ print("Provider does not support streaming logprobs.")
173
+
174
+ req = ChatRequest(
175
+ model="gpt-5.4",
176
+ messages=[{"role": Role.USER, "content": "Say hello."}],
177
+ logprobs=True,
178
+ top_logprobs=3,
179
+ )
180
+
181
+ async for chunk in provider.chat_stream(req):
182
+ print(chunk.delta, end="")
183
+ if chunk.logprobs is not None:
184
+ for tok in chunk.logprobs.content:
185
+ print(f" token={tok.token!r} logprob={tok.logprob:.4f}")
186
+
187
+ asyncio.run(main())
188
+ ```
189
+
190
+ ## Tool Calling
191
+
192
+ ```python
193
+ weather_tool = nxuskit.ToolDefinition.create(
194
+ name="get_weather",
195
+ description="Get weather for a location",
196
+ parameters={
197
+ "type": "object",
198
+ "properties": {"location": {"type": "string"}},
199
+ "required": ["location"],
200
+ },
201
+ )
202
+
203
+ response = provider.chat(
204
+ [nxuskit.Message.user("What's the weather in Tokyo?")],
205
+ tools=[weather_tool],
206
+ tool_choice=nxuskit.tool_choice_auto(),
207
+ )
208
+
209
+ if response.tool_calls:
210
+ for call in response.tool_calls:
211
+ print(f"Call: {call.function.name}({call.function.arguments})")
212
+ ```
213
+
214
+ ## Vision
215
+
216
+ ```python
217
+ msg = nxuskit.Message.user("What's in this image?").with_image_file("photo.png")
218
+ response = provider.chat([msg], model="gpt-4o")
219
+ ```
220
+
221
+ ## Error Handling
222
+
223
+ ```python
224
+ try:
225
+ response = provider.chat([nxuskit.Message.user("Hello")])
226
+ except nxuskit.TimeoutError:
227
+ print("Request timed out — try a faster model")
228
+ except nxuskit.NetworkError:
229
+ print("Network issue — check connection")
230
+ except nxuskit.RateLimitError as e:
231
+ print(f"Rate limited — retry after {e.retry_after}s")
232
+ except nxuskit.AuthenticationError:
233
+ print("Check your API key")
234
+ ```
235
+
236
+ ## Model Discovery
237
+
238
+ ```python
239
+ models = provider.list_models()
240
+ for m in models:
241
+ vision = "vision" if m.supports_vision() else "text-only"
242
+ print(f" {m.name}: {vision}")
243
+ ```
244
+
245
+ ## Providers
246
+
247
+ | Provider | Factory | Environment Variable |
248
+ |----------|---------|---------------------|
249
+ | Claude | `Provider.claude()` | `ANTHROPIC_API_KEY` |
250
+ | OpenAI | `Provider.openai()` | `OPENAI_API_KEY` |
251
+ | Ollama | `Provider.ollama()` | None (local) |
252
+ | xAI Grok | `Provider.xai()` | `XAI_API_KEY` |
253
+ | Groq | `Provider.groq()` | `GROQ_API_KEY` |
254
+ | Mistral | `Provider.mistral()` | `MISTRAL_API_KEY` |
255
+ | Fireworks | `Provider.fireworks()` | `FIREWORKS_API_KEY` |
256
+ | Together | `Provider.together()` | `TOGETHER_API_KEY` |
257
+ | OpenRouter | `Provider.openrouter()` | `OPENROUTER_API_KEY` |
258
+ | Perplexity | `Provider.perplexity()` | `PERPLEXITY_API_KEY` |
259
+ | LM Studio | `Provider.lmstudio()` | None (local) |
260
+
261
+ ## CLIPS Session API
262
+
263
+ For direct CLIPS rule engine access (requires native library):
264
+
265
+ ```python
266
+ from nxuskit.clips import ClipsSession
267
+
268
+ with ClipsSession() as s:
269
+ s.load_json(rules_json)
270
+ s.reset()
271
+ s.fact_assert_string('(sensor (name "temp") (value 200))')
272
+ fired = s.run()
273
+ ```
274
+
275
+ ## FFI Provider Note
276
+
277
+ When using FFI-backed features, always use context managers (`with` statement) for reliable cleanup:
278
+
279
+ ```python
280
+ from nxuskit._ffi_provider import create_ffi_provider
281
+
282
+ with create_ffi_provider({"provider_type": "openai", "api_key": "sk-..."}) as p:
283
+ response = p.chat({"model": "gpt-4o", "messages": [...]})
284
+ ```
285
+
286
+ ## Development
287
+
288
+ ```bash
289
+ pip install -e ".[dev]"
290
+ pytest tests/
291
+ ruff check src/ && ruff format --check .
292
+ ```
293
+
294
+ ## License
295
+
296
+ Dual-licensed under MIT and Apache 2.0. See the
297
+ [MIT](https://github.com/nxus-SYSTEMS/nxusKit/blob/sdk-v1.0.3/LICENSE-MIT)
298
+ and
299
+ [Apache 2.0](https://github.com/nxus-SYSTEMS/nxusKit/blob/sdk-v1.0.3/LICENSE-APACHE)
300
+ license texts.
301
+
302
+ See also: [nxusKit-examples](https://github.com/nxus-SYSTEMS/nxusKit-examples) for runnable examples.
@@ -0,0 +1,266 @@
1
+ # nxuskit-py: Python SDK for nxusKit
2
+
3
+ [![SDK bundle](https://img.shields.io/badge/distribution-SDK%20bundle-blue.svg)](https://github.com/nxus-SYSTEMS/nxusKit/releases)
4
+ [![Python 3.11+](https://img.shields.io/badge/python-3.11+-blue.svg)](https://www.python.org/downloads/)
5
+ [![License: MIT OR Apache-2.0](https://img.shields.io/badge/license-MIT%20OR%20Apache--2.0-blue.svg)](https://github.com/nxus-SYSTEMS/nxusKit/blob/sdk-v1.0.3/LICENSE)
6
+
7
+ Pure Python library for the [nxusKit](https://github.com/nxus-SYSTEMS/nxusKit) polyglot SDK. The public distribution package is `nxuskit-py` and imports as `nxuskit`. Pure-Python provider APIs work from the Python package; native/FFI engine APIs require an installed nxusKit SDK bundle. Z3 solver and ZEN decision table workflows require nxusKit SDK Pro.
8
+
9
+ ## Features
10
+
11
+ - **11 LLM Providers** — Claude, OpenAI, Ollama, xAI Grok, Groq, Mistral, Fireworks, Together, OpenRouter, Perplexity, LM Studio
12
+ - **Per-Request Model Override** — Switch models on any `chat()` call: `provider.chat(messages, model="gpt-4o-mini")`
13
+ - **Tool Calling / Function Calling** — Pass tool definitions, receive structured tool call responses
14
+ - **Streaming** — Iterator-based streaming with `is_final()` completion detection
15
+ - **Vision / Multimodal** — Image input via URL, base64, or file path with auto-detected MIME types
16
+ - **Model Discovery** — `list_models()` with `supports_vision()`, `modalities()`, `max_images()` helpers
17
+ - **Typed Error Handling** — `TimeoutError`, `NetworkError`, `RateLimitError`, `AuthenticationError`, `ProviderError`
18
+ - **Retry Utilities** — `RetryConfig`, `retry_with_backoff`, `AdaptiveRateLimiter`
19
+ - **CLIPS / BN / Solver / ZEN** — FFI access to nxusKit reasoning engines (native library required; Solver and ZEN require Pro)
20
+
21
+ **Dependencies**: `requests`, `cffi` (FFI), `keyring` (credential storage), `PyJWT[crypto]` (license tokens)
22
+
23
+ ## Installation
24
+
25
+ Until package-index publication is complete and smoke-verified, use the Python
26
+ package shipped inside an extracted nxusKit SDK bundle:
27
+
28
+ ```bash
29
+ export NXUSKIT_SDK_DIR="$HOME/.nxuskit/sdk/current"
30
+ export PYTHONPATH="$NXUSKIT_SDK_DIR/python/src:${PYTHONPATH:-}"
31
+ python -c "import nxuskit; print(nxuskit.__version__)"
32
+ ```
33
+
34
+ `nxuskit-py` is the TestPyPI/PyPI distribution target and `nxuskit` is the
35
+ Python import package. TestPyPI verification uses the package index explicitly:
36
+
37
+ ```bash
38
+ python -m pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ nxuskit-py==1.0.3
39
+ python -c "import nxuskit; print(nxuskit.__version__)"
40
+ ```
41
+
42
+ After the production PyPI package is published and smoke-verified, installing
43
+ from PyPI becomes the recommended package-index path. The package-index wheel
44
+ installs the Python package only; it does **not** install native `libnxuskit`
45
+ engines.
46
+
47
+ For FFI features (CLIPS, BN, Solver, ZEN), install the
48
+ [nxusKit SDK](https://github.com/nxus-SYSTEMS/nxusKit/releases) and set
49
+ `NXUSKIT_SDK_DIR`, `NXUSKIT_LIB_DIR`, or install the SDK at
50
+ `~/.nxuskit/sdk/current/`. CLIPS and Bayesian inference are Community Edition
51
+ features where supported by the installed SDK; Solver and ZEN require Pro SDK
52
+ features and Pro entitlement.
53
+
54
+ ## Quick Start
55
+
56
+ ```python
57
+ import nxuskit
58
+
59
+ # Create a provider (auto-discovers API key from environment)
60
+ provider = nxuskit.Provider.claude()
61
+
62
+ # Simple chat
63
+ response = provider.chat([nxuskit.Message.user("What is 2 + 2?")])
64
+ print(response.content)
65
+ print(f"Tokens: {response.usage.total_tokens}")
66
+ ```
67
+
68
+ ## Capability Manifest Public Preview
69
+
70
+ The Python package exposes the stable public Capability Manifest v2 projection
71
+ types. The public shape carries status values and reviewed-on metadata only;
72
+ internal evidence records, model overrides, and provider-specific details stay
73
+ private to the engine registry.
74
+
75
+ ```python
76
+ import nxuskit
77
+
78
+ manifest = nxuskit.PublicCapabilityManifest(
79
+ schema_version="capability-manifest-v2-public-preview/1",
80
+ posture=nxuskit.ManifestPublicationPosture.SPLIT,
81
+ providers=[
82
+ nxuskit.PublicProviderCapability(
83
+ name="openai",
84
+ display_name="OpenAI",
85
+ last_reviewed_on="2026-05-09",
86
+ provider_status="unknown",
87
+ capabilities={
88
+ "json_schema_strict": nxuskit.CapabilityStatus.SUPPORTED,
89
+ "rerank": nxuskit.CapabilityStatus.FUTURE,
90
+ },
91
+ )
92
+ ],
93
+ )
94
+
95
+ print(nxuskit.PUBLIC_CAPABILITY_FIELDS)
96
+ print(manifest.to_dict()["providers"][0]["capabilities"]["json_schema_strict"])
97
+ ```
98
+
99
+ ## Per-Request Model Override
100
+
101
+ ```python
102
+ provider = nxuskit.Provider.openai() # default: gpt-4o
103
+
104
+ # Override model for a single call
105
+ response = provider.chat(
106
+ [nxuskit.Message.user("Hello")],
107
+ model="gpt-4o-mini",
108
+ temperature=0.5,
109
+ )
110
+ ```
111
+
112
+ ## Streaming
113
+
114
+ ```python
115
+ for chunk in provider.chat_stream([nxuskit.Message.user("Tell me a story")]):
116
+ print(chunk.delta, end="", flush=True)
117
+ if chunk.is_final():
118
+ print(f"\nTokens: {chunk.usage.total_tokens}")
119
+ ```
120
+
121
+ ### Streaming Logprobs (v0.9.4+)
122
+
123
+ Per-chunk logprob deltas are now surfaced on streaming responses for
124
+ providers that support them (OpenAI). Check the capability flag before
125
+ issuing the call; non-supporting providers always emit `chunk.logprobs is None`
126
+ on every chunk (FR-007 — no phantom data).
127
+
128
+ ```python
129
+ from nxuskit import Provider, ChatRequest, Role
130
+ import asyncio
131
+
132
+ async def main():
133
+ provider = Provider.openai()
134
+
135
+ if not provider.capabilities().supports_streaming_logprobs:
136
+ print("Provider does not support streaming logprobs.")
137
+
138
+ req = ChatRequest(
139
+ model="gpt-5.4",
140
+ messages=[{"role": Role.USER, "content": "Say hello."}],
141
+ logprobs=True,
142
+ top_logprobs=3,
143
+ )
144
+
145
+ async for chunk in provider.chat_stream(req):
146
+ print(chunk.delta, end="")
147
+ if chunk.logprobs is not None:
148
+ for tok in chunk.logprobs.content:
149
+ print(f" token={tok.token!r} logprob={tok.logprob:.4f}")
150
+
151
+ asyncio.run(main())
152
+ ```
153
+
154
+ ## Tool Calling
155
+
156
+ ```python
157
+ weather_tool = nxuskit.ToolDefinition.create(
158
+ name="get_weather",
159
+ description="Get weather for a location",
160
+ parameters={
161
+ "type": "object",
162
+ "properties": {"location": {"type": "string"}},
163
+ "required": ["location"],
164
+ },
165
+ )
166
+
167
+ response = provider.chat(
168
+ [nxuskit.Message.user("What's the weather in Tokyo?")],
169
+ tools=[weather_tool],
170
+ tool_choice=nxuskit.tool_choice_auto(),
171
+ )
172
+
173
+ if response.tool_calls:
174
+ for call in response.tool_calls:
175
+ print(f"Call: {call.function.name}({call.function.arguments})")
176
+ ```
177
+
178
+ ## Vision
179
+
180
+ ```python
181
+ msg = nxuskit.Message.user("What's in this image?").with_image_file("photo.png")
182
+ response = provider.chat([msg], model="gpt-4o")
183
+ ```
184
+
185
+ ## Error Handling
186
+
187
+ ```python
188
+ try:
189
+ response = provider.chat([nxuskit.Message.user("Hello")])
190
+ except nxuskit.TimeoutError:
191
+ print("Request timed out — try a faster model")
192
+ except nxuskit.NetworkError:
193
+ print("Network issue — check connection")
194
+ except nxuskit.RateLimitError as e:
195
+ print(f"Rate limited — retry after {e.retry_after}s")
196
+ except nxuskit.AuthenticationError:
197
+ print("Check your API key")
198
+ ```
199
+
200
+ ## Model Discovery
201
+
202
+ ```python
203
+ models = provider.list_models()
204
+ for m in models:
205
+ vision = "vision" if m.supports_vision() else "text-only"
206
+ print(f" {m.name}: {vision}")
207
+ ```
208
+
209
+ ## Providers
210
+
211
+ | Provider | Factory | Environment Variable |
212
+ |----------|---------|---------------------|
213
+ | Claude | `Provider.claude()` | `ANTHROPIC_API_KEY` |
214
+ | OpenAI | `Provider.openai()` | `OPENAI_API_KEY` |
215
+ | Ollama | `Provider.ollama()` | None (local) |
216
+ | xAI Grok | `Provider.xai()` | `XAI_API_KEY` |
217
+ | Groq | `Provider.groq()` | `GROQ_API_KEY` |
218
+ | Mistral | `Provider.mistral()` | `MISTRAL_API_KEY` |
219
+ | Fireworks | `Provider.fireworks()` | `FIREWORKS_API_KEY` |
220
+ | Together | `Provider.together()` | `TOGETHER_API_KEY` |
221
+ | OpenRouter | `Provider.openrouter()` | `OPENROUTER_API_KEY` |
222
+ | Perplexity | `Provider.perplexity()` | `PERPLEXITY_API_KEY` |
223
+ | LM Studio | `Provider.lmstudio()` | None (local) |
224
+
225
+ ## CLIPS Session API
226
+
227
+ For direct CLIPS rule engine access (requires native library):
228
+
229
+ ```python
230
+ from nxuskit.clips import ClipsSession
231
+
232
+ with ClipsSession() as s:
233
+ s.load_json(rules_json)
234
+ s.reset()
235
+ s.fact_assert_string('(sensor (name "temp") (value 200))')
236
+ fired = s.run()
237
+ ```
238
+
239
+ ## FFI Provider Note
240
+
241
+ When using FFI-backed features, always use context managers (`with` statement) for reliable cleanup:
242
+
243
+ ```python
244
+ from nxuskit._ffi_provider import create_ffi_provider
245
+
246
+ with create_ffi_provider({"provider_type": "openai", "api_key": "sk-..."}) as p:
247
+ response = p.chat({"model": "gpt-4o", "messages": [...]})
248
+ ```
249
+
250
+ ## Development
251
+
252
+ ```bash
253
+ pip install -e ".[dev]"
254
+ pytest tests/
255
+ ruff check src/ && ruff format --check .
256
+ ```
257
+
258
+ ## License
259
+
260
+ Dual-licensed under MIT and Apache 2.0. See the
261
+ [MIT](https://github.com/nxus-SYSTEMS/nxusKit/blob/sdk-v1.0.3/LICENSE-MIT)
262
+ and
263
+ [Apache 2.0](https://github.com/nxus-SYSTEMS/nxusKit/blob/sdk-v1.0.3/LICENSE-APACHE)
264
+ license texts.
265
+
266
+ See also: [nxusKit-examples](https://github.com/nxus-SYSTEMS/nxusKit-examples) for runnable examples.