Skip to main content

nlght-ai

The runtime between your app and your LLM: workflows, tools, memory, and model providers.

Tests Coverage PyPI

E2E scope note. The test badge covers the cloud model-client e2e suite (tests/e2e); each provider skips itself when its API key is absent. The local Ollama model-client suite (tests/local_e2e) runs separately against a local Ollama daemon. Run it with pytest tests/local_e2e -m local_e2e.


What it does

  1. A protocol adapter accepts an OpenAI or Ollama API request and resolves its workflow trigger.
  2. The workflow executor runs the configured steps. Steps receive request messages and the configured model, tool, playbook, and session ports.
  3. Steps call models or tools, use session memory, and emit signals without handling HTTP.
  4. The adapter returns the result as a batch response or stream.

Features

Feature Description
OpenAI-compatible API Chat Completions endpoint for supported OpenAI clients
Ollama API Native Ollama protocol support
Multi-provider Ollama, Anthropic Claude, OpenAI, Google Gemini
Workflow engine Stateless step machine with configurable routing
Tool system Register custom tools, call them from steps
Playbook catalog YAML-defined agent capabilities, loaded from filesystem
Session memory Hive Mind: conversation, session results, and working memory
Session routing Configurable SessionKeyResolver per protocol adapter
PostgreSQL persistence Workflow metadata and resource registry via SQLAlchemy
Ports & Adapters Core contracts have no framework dependency

Install

Install uv, then add nlght-ai inside a Python project:

uv add nlght-ai

Optional extras:

uv add 'nlght-ai[anthropic]'   # Anthropic Claude
uv add 'nlght-ai[openai]'      # OpenAI / Azure OpenAI
uv add 'nlght-ai[google]'      # Google Gemini
uv add 'nlght-ai[hive-mind]'   # File-backed session memory
uv add 'nlght-ai[docker]'      # Docker OS runtime
uv add 'nlght-ai[web-search]'  # Web search tool

This declares nlght-ai in the project, so later uv sync and uv run commands keep it installed. For a standalone CLI that is independent of any project environment, use uv tool install nlght-ai instead.


Quickstart

In the configuration examples, YOUR-LICENSE-KEY means the key from a free developer license. Replace it with your own key.

1. Configure: Create .config/platform.yaml:

licensing:
  license_key: YOUR-LICENSE-KEY   # free developer licenses available

protocol_adapters:
  - name: openai-http
    kind: openai
    enabled: true
    config:
      base_path: /v1
      model_provider: ollama
      session_key_resolver:
        resolver: header
        key: x-session-id

gateways:
  - name: http-gateway
    kind: http
    enabled: true
    config:
      host: 0.0.0.0
      port: 8000

integrations:
  persistence:
    workflows:
      backend: postgres
      url: postgresql+asyncpg://user:pass@localhost/nlght
  model_providers:
    - name: ollama
      kind: ollama-local
      config:
        base_url: http://localhost:11434
        default_model: llama3.2

2. Start PostgreSQL with the local credentials above:

docker run -d --name nlght-postgres \
  -e POSTGRES_USER=user -e POSTGRES_PASSWORD=pass -e POSTGRES_DB=nlght \
  -p 5432:5432 postgres:16

3. Migrate the database (initial setup and after every upgrade):

uv run nlght-ai migrate

4. Start Ollama and the runtime (use separate terminals):

Terminal 1:

ollama serve

Terminal 2:

ollama pull llama3.2
uv run nlght-ai serve

5. Call:

curl http://localhost:8000/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{"model": "llama3.2", "messages": [{"role": "user", "content": "Hello!"}]}'

Writing a Step

from typing import ClassVar

from nlght.core.model.messages import TrustedInstructionMessage
from nlght.core.workflow.step import StepBase, StepResult, WorkflowStepContext


class SummarizeStep(StepBase):
    TYPE: ClassVar[str] = "summarize"

    async def run(self, ctx: WorkflowStepContext) -> StepResult:
        if ctx.llm is None:
            return StepResult(ctx=ctx, verdict="failed")
        instructions = TrustedInstructionMessage(
            "Summarize the conversation in three bullet points."
        )
        await ctx.llm.call(messages=[instructions, *ctx.messages])
        return StepResult(ctx=ctx, verdict="done")

Register and wire it up in your entrypoint, then reference it in a workflow definition stored in the database.


Session Memory (Hive Mind)

Hive Mind persists conversation turns and session results. Working memory holds transient atoms for the active task. Applications can store JSON-compatible values in namespaced coordinator slots. The store has no directive API.

Configure a session backend and select model context with PromptInputPolicy. See Session Memory for the current configuration, store contracts, and copyable examples.


Demo

The Demo Showcase introduces six complete workflows across grounding, tools, routing, session memory, and isolated runtime execution. Setup, migration, and run requirements are maintained by the demo repository linked there.


Model Providers

Provider Extra Config kind
Ollama (local) (none) ollama-local
Anthropic Claude [anthropic] anthropic
OpenAI [openai] openai
Google Gemini [google] google

Architecture

nlght-ai follows a strict hexagonal (ports & adapters) architecture:

  • core/: Domain logic and framework independent types
  • ports/: Interfaces for external concerns
  • adapters/inbound/: HTTP and protocol adapters
  • adapters/outbound/: Model clients, persistence, tools, Hive Mind, and OS runtime
  • application/: Services that coordinate ports
  • bootstrap/: Container, startup, and configuration loading

See the nlght-ai documentation for the full user documentation.


Requirements

  • Python 3.11+
  • PostgreSQL (for workflow metadata and resource registry)
  • A model provider (Ollama recommended for local development)

Development

Dependencies are pinned in uv.lock for a reproducible environment. With mise (see mise.toml, which pins Python 3.13 and uv):

mise install
uv sync
uv run pytest -q -m "not e2e and not integration"
uv run ruff check src tests

The default dev group installs nlght-ai[all], so local development and CI exercise every portable runtime capability. Accelerator-specific embedding-cpu and embedding-cuda remain explicit machine choices.

uv sync --locked (used in CI) fails instead of silently re-resolving if pyproject.toml and uv.lock have drifted apart. Run uv lock after changing dependencies and commit the updated lockfile.

Metadata

Release files for nlght-ai 0.1.5

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

Source distribution (sdist)

Source distribution for nlght-ai 0.1.5
File Size Uploaded Provenance Actions
nlght_ai-0.1.5.tar.gz 681.3 kB With provenance Details for nlght_ai-0.1.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for nlght-ai 0.1.5
File Interpreter ABI Platform Actions
nlght_ai-0.1.5-py3-none-any.whl Python 3 none any Details for nlght_ai-0.1.5-py3-none-any.whl

Total release size: 1.6 MB

Release files / nlght_ai-0.1.5.tar.gz

Download URL nlght_ai-0.1.5.tar.gz
Size 681.3 kB
Tags Source
SHA-256 checksum
How to use checksums
0578e3aace8f833338c3f3266d536f29ed63df8cd36a4d57fc411d890909b49b
BLAKE2b-256 checksum
How to use checksums
41a387c91f67531da6d20f9b2962a6f62451a67cce242837d3ecd3ec170f308d
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 Nov 7, 2026.

Transparency log

Release files / nlght_ai-0.1.5-py3-none-any.whl

Download URL nlght_ai-0.1.5-py3-none-any.whl
Size 898.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9474e7855bc892d8dd023fa655bac0efbc9f047213a54ebc3ff0a82e3ae2669d
BLAKE2b-256 checksum
How to use checksums
94ac3d8144542609bd3486a75aaf2367791e6a374adb78cb048c301bd399d273
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 Nov 7, 2026.

Transparency log

Security for nlght-ai 0.1.5

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.

Select from 2 files

Attestation for nlght_ai-0.1.5.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 Nov 7, 2026.

Transparency log

A 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.

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