Skip to navigation

Client APIs

View as Markdown

The following reference provides detailed documentation for the synchronous and asynchronous clients of the NeMo Helix Python SDK.

Synchronous Client

Use NemoClient from regular Python code when you want blocking API calls. The typed client talks directly to the NeMo Helix HTTP API. In most code, build it with from_config(), which reads the base URL, default workspace, and credentials from your current CLI context. To configure contexts, see Connect with CLI Contexts.

from nemo_helix_plugin.client.client import NemoClient
client = NemoClient.from_config()
for workspace in client.workspaces.list_workspaces().items():
print(workspace.name)

Constructor

To connect without reading the CLI configuration, pass the connection settings directly:

from nemo_helix_plugin.client.client import NemoClient
client = NemoClient(
base_url="http://localhost:8080",
workspace="default",
)

The NemoClient constructor accepts the following options.

ParameterDescription
base_urlBase URL of the NeMo Helix API (required). For example http://localhost:8080.
workspaceWorkspace name used by workspace-scoped routes. You can set it on the client or pass it to individual methods that accept a workspace argument.
authA token provider, or a static bearer token string, used to authenticate requests.
default_headersHeaders sent with every request.
timeoutRequest timeout for API calls. Pass a float in seconds, an httpx.Timeout, or None.
retryA RetryPolicy describing when and how many times to retry transient failures.
http_clientCustom httpx.Client. When provided, the client shares that transport instead of building its own.
owns_http_clientWhether the client owns (and closes) http_client. Defaults to True when http_client is not provided.

Connection Modes

ModeExampleBehavior
CLI context (recommended)NemoClient.from_config()Reads the active CLI context (base URL, workspace, auth) configured by nemo setup / nemo auth login. NHX_* environment variables such as NHX_BASE_URL and NHX_ACCESS_TOKEN override the saved values.
Named contextNemoClient.from_config(context="dev")Reads a specific CLI context instead of the active one.
Explicit config pathNemoClient.from_config(config_path="/path/to/config.yaml")Reads a specific CLI config file.
Direct APINemoClient(base_url="http://localhost:8080")Uses the given URL, workspace, and any explicit auth without reading a config file.

Use with_options(...) to clone a client with request defaults changed:

short_timeout_client = client.with_options(timeout=10.0)

Asynchronous Client

Use AsyncNemoClient from asyncio applications. It exposes the same resource tree as NemoClient, but API methods are awaited.

import asyncio
from nemo_helix_plugin.client.client import AsyncNemoClient
async def main() -> None:
client = AsyncNemoClient.from_config()
async for workspace in client.workspaces.list_workspaces().items():
print(workspace.name)
asyncio.run(main())

Async client constructor

from nemo_helix_plugin.client.client import AsyncNemoClient
client = AsyncNemoClient(
base_url="http://localhost:8080",
workspace="default",
)

AsyncNemoClient accepts the same connection and authentication parameters as NemoClient, and AsyncNemoClient.from_config() accepts the same arguments as NemoClient.from_config(). Pass a custom httpx.AsyncClient through http_client only when you need to control the underlying transport directly.

Errors

API calls raise typed exceptions from nemo_helix_plugin.client.errors:

ExceptionTypical HTTP status
BadRequestError400
AuthenticationError401
PermissionDeniedError403
NotFoundError404
ConflictError409
UnprocessableEntityError422
RateLimitError429
InternalServerError5xx

Catch NemoHTTPError for all non-success HTTP responses, or NemoClientError for SDK-level errors. Transport failures raise NemoTransportError.

Client Attributes

The NeMo Helix clients provide access to API resources through the following properties. Each returns a typed per-service client that shares the main client’s transport. For endpoint details, see the REST API Reference.

Organization

  • workspaces: Manage workspaces (via the entity store)
  • projects: Manage projects within a workspace
  • iam: Identity and access management
  • auth: Authentication
  • access_keys: Access keys

Model Management

  • models: Model entity CRUD
  • inference: Providers, deployments, deployment configs, and virtual models (client.inference.providers, client.inference.deployments, client.inference.deployment_configs, client.inference.virtual_models)
  • evaluator: Evaluations

Data & Synthesis

  • files: Filesets and file upload/download
  • data_designer: Synthetic data generation jobs
  • intake: Telemetry intake

Safety & Compliance

  • guardrail: Guardrail configurations and checks
  • garak: Model safety audit jobs and configs
  • agent_hardener: Agent hardening

Platform

  • jobs: Cross-service job management
  • agents: Deployed agents
  • secrets: Secret management

Plugin resources

Plugin-owned resources are resolved from the nemo.sdk entry point and exposed as client attributes (for example client.customization for the Customizer plugin, or client.agents for the Agents plugin when provided by a plugin). Use them the same way as core resources.

Response Handling

Each method returns a typed response:

  • NemoResponse (.data() for the parsed entity, .http_response for the raw httpx.Response)
  • NemoPaginatedResponse (.items() and .pages() for paginated lists)
  • NemoBinaryResponse (.read() or .stream() for binary downloads)
  • NemoStreamResponse (.stream() for streaming responses)