| title | Runtime |
|---|---|
| slug | /reference/api/python-library-reference/runtime |
| description | Drive stateful multi-turn execution through the Runtime API. |
Runtime lifecycle support for the NVIDIA NeMo Fabric Python SDK.
Lifecycle state of a runtime.
ACTIVE accepts invocations, STOPPED has released its runtime, and FAILED records a lifecycle failure that prevents further invocations but still permits cleanup.
Direct bases: str, Enum.
The enum defines the following values:
| Name | Value |
|---|---|
ACTIVE |
active |
STOPPED |
stopped |
FAILED |
failed |
One logical, stateful harness execution.
Create runtimes with Fabric.start_runtime() rather than calling the constructor. A runtime serializes invocations and preserves adapter-owned harness state across turns. Use it as an asynchronous context manager to stop the runtime on exit.
Runtime-scoped overrides are recursively merged with invocation overrides; invocation values win.
Return a detached snapshot of the runtime handle.
Return copied request, runtime, and invocation IDs for completed turns.
Return a deep copy of the latest harness-provided message history.
Return the unique identifier for this started runtime lifecycle.
Return the current ACTIVE, STOPPED, or FAILED state.
Return whether the selected adapter implements native OpenAI streaming.
Return whether NVIDIA NeMo Relay ATOF streaming is enabled.
async def invoke(*, input: Any = None, request: RunRequest | None = None) -> RunResultRun one turn on this runtime.
input and request are mutually exclusive. Runtime overrides are merged below invocation overrides from RunRequest. Concurrent turns on the same runtime are rejected.
Args:
input: JSON-compatible turn input.request: Complete validatedRunRequest.
Returns:
The normalized RunResult for this turn.
Raises:
FabricConfigError: If request fields conflict or are not JSON-compatible.FabricStateError: If the runtime is not active, is stopping, or is already running a turn.FabricNativeUnavailableError: If the native extension is missing.FabricRuntimeError: If native invocation fails before returning a normalized result.
def invoke_openai_stream(
*,
input: Any = None,
request: RunRequest | None = None,
) -> OpenAIInvokeStreamStart one turn and stream native OpenAI chat-completion chunks.
The returned stream yields chat.completion.chunk mappings. Await stream.result() for the separate normalized terminal result.
Raises:
FabricCapabilityError: If the selected adapter does not advertise native OpenAI streaming.FabricConfigError: If request fields conflict or are not JSON-compatible.FabricStateError: If another turn or stream is active.
def invoke_stream(
*,
input: Any = None,
request: RunRequest | None = None,
) -> InvokeStreamStart one turn and stream raw NeMo Relay ATOF records as they arrive.
input and request are mutually exclusive. The returned InvokeStream yields raw ATOF dictionaries. Await stream.result() for the terminal normalized RunResult.
Raises:
FabricCapabilityError: If the runtime was not started with NeMo Relay enabled andstreaming=True.FabricConfigError: If request fields conflict or are not JSON-compatible.FabricStateError: If another turn or stream is active.
async def stop() -> NoneDestroy an idle runtime exactly once.
Repeated calls after a successful stop are no-ops. A failed runtime may still be stopped so its resources are released.
Raises:
FabricStateError: If the runtime is already stopping or has an invocation in flight.FabricNativeUnavailableError: If the native extension is missing.FabricRuntimeError: If native runtime shutdown fails.
This file was automatically generated via lazydocs.