Client APIs#
The following reference provides detailed documentation for the synchronous and asynchronous clients of the NeMo Platform Python SDK.
Synchronous Client#
- class nemo_platform.NeMoPlatform#
- __init__(
- *,
- workspace: str | None = None,
- base_url: str | URL | None = None,
- inference_base_url: str | URL | None = None,
- config_path: Path | None = None,
- context_name: str | None = None,
- access_token: str | None = None,
- timeout: float | Timeout | None | NotGiven = NOT_GIVEN,
- max_retries: int = 2,
- default_headers: Mapping[str, str] | None = None,
- default_query: Mapping[str, object] | None = None,
- http_client: Client | None = None,
- _strict_response_validation: bool = False,
Construct a new synchronous NeMoPlatform client instance.
Calling with no arguments reads configuration from the active context in
~/.config/nmp/config.yamland wires up transparent OIDC token refresh.Passing only
base_urlactivates direct mode — no config file is read and no auth headers are injected. To combine a custombase_urlwith config-based auth, also passcontext_nameoraccess_token.Example — zero-config (reads from
nmp auth logincredentials):from nemo_platform import NeMoPlatform client = NeMoPlatform()
Example — explicit token for automation:
import os from nemo_platform import NeMoPlatform client = NeMoPlatform( base_url=os.environ["NMP_BASE_URL"], access_token=os.environ["NMP_ACCESS_TOKEN"], workspace="default", )
- Parameters:
workspace – Workspace name used as a path parameter in all resource routes (
/workspaces/{workspace}/...). Can also be supplied per-method. RaisesValueErrorat call time if absent from both.base_url – Base URL of the NeMo Platform API. If omitted, read from the active context in the nmp config file. Passing this parameter without
context_nameoraccess_tokenactivates direct mode (no config file is read, no auth headers are injected).config_path – Path to the nmp config file. Defaults to
~/.config/nmp/config.yaml. Override in containers or CI where the default path is not available or writable.context_name – Name of the context to activate from the config file. Use this to switch between clusters. Also forces the auth bootstrap when
base_urlis explicitly set.access_token – Explicit Bearer token. Bypasses config-file auth and is suitable for CI/CD pipelines that obtain tokens externally. Automatic token refresh is not performed when this parameter is used.
timeout – HTTP request timeout applied to all API calls. Accepts a float (seconds), an
httpx.Timeoutobject, orNone(no timeout). Individual methods can override this with their owntimeoutargument.max_retries – Maximum number of automatic retries on transient failures. Defaults to
2. Set to0to disable retries.default_headers – Additional HTTP headers sent with every request.
default_query – Additional query parameters appended to every request URL.
http_client – Custom
httpx.Clientinstance. When provided, the auth bootstrap is skipped entirely regardless of other parameters.
Asynchronous Client#
- class nemo_platform.AsyncNeMoPlatform#
- __init__(
- *,
- workspace: str | None = None,
- base_url: str | URL | None = None,
- inference_base_url: str | URL | None = None,
- config_path: Path | None = None,
- context_name: str | None = None,
- access_token: str | None = None,
- timeout: float | Timeout | None | NotGiven = NOT_GIVEN,
- max_retries: int = 2,
- default_headers: Mapping[str, str] | None = None,
- default_query: Mapping[str, object] | None = None,
- http_client: AsyncClient | None = None,
- _strict_response_validation: bool = False,
Construct a new asynchronous AsyncNeMoPlatform client instance.
Calling with no arguments reads configuration from the active context in
~/.config/nmp/config.yamland wires up transparent OIDC token refresh.Passing only
base_urlactivates direct mode — no config file is read and no auth headers are injected. To combine a custombase_urlwith config-based auth, also passcontext_nameoraccess_token.Example — zero-config (reads from
nmp auth logincredentials):import asyncio from nemo_platform import AsyncNeMoPlatform async def main() -> None: client = AsyncNeMoPlatform() page = await client.workspaces.list() print(page.data) asyncio.run(main())
Example — explicit token (CI/CD):
import asyncio, os from nemo_platform import AsyncNeMoPlatform async def main() -> None: client = AsyncNeMoPlatform( base_url=os.environ["NMP_BASE_URL"], access_token=os.environ["NMP_ACCESS_TOKEN"], workspace="default", ) page = await client.workspaces.list() print(page.data) asyncio.run(main())
- Parameters:
workspace – Workspace name used as a path parameter in all resource routes (
/workspaces/{workspace}/...). Can also be supplied per-method. RaisesValueErrorat call time if absent from both.base_url – Base URL of the NeMo Platform API. If omitted, read from the active context in the nmp config file. Passing this parameter without
context_nameoraccess_tokenactivates direct mode (no config file is read, no auth headers are injected).config_path – Path to the nmp config file. Defaults to
~/.config/nmp/config.yaml. Override in containers or CI where the default path is not available or writable.context_name – Name of the context to activate from the config file. Use this to switch between clusters. Also forces the auth bootstrap when
base_urlis explicitly set.access_token – Explicit Bearer token. Bypasses config-file auth and is suitable for CI/CD pipelines that obtain tokens externally. Automatic token refresh is not performed when this parameter is used.
timeout – HTTP request timeout applied to all API calls. Accepts a float (seconds), an
httpx.Timeoutobject, orNone(no timeout). Individual methods can override this with their owntimeoutargument.max_retries – Maximum number of automatic retries on transient failures. Defaults to
2. Set to0to disable retries.default_headers – Additional HTTP headers sent with every request.
default_query – Additional query parameters appended to every request URL.
http_client – Custom
httpx.AsyncClientinstance. When provided, the auth bootstrap is skipped entirely regardless of other parameters.
Client Attributes#
The NeMo Platform clients provide access to API resources through the following attributes. For complete method signatures and parameters, see the API Reference.
Organization#
workspaces: Manage workspaces
projects: Manage projects within a workspace
Model Management#
models: Model entity CRUD
customization: Fine-tuning jobs (create, list, cancel, pause, resume, logs, status) — API reference
evaluation: Benchmarks, benchmark jobs, metrics, and metric jobs — API reference
inference: Deployments, deployment configs, providers, and OpenAI-compatible gateway — API reference
Data & Synthesis#
data_designer: Synthetic data generation jobs
safe_synthesizer: PII replacement and safe data synthesis jobs
files: File upload and download
Safety & Compliance#
guardrail: Guardrail configuration and protected chat completions — API reference
audit: Model safety audit jobs and configs — API reference
Platform#
jobs: Cross-service job management — API reference
entities: Generic entity CRUD
secrets: Secret management — API reference
iam: Identity and access management
members: Workspace member and RBAC management
Response Handling#
with_raw_response: Access raw HTTP response data
with_streaming_response: Handle streaming responses