Install and Configure the Client
This section explains how to install runapy, select the right client type for your environment and configure authentication.
Important
The Python client is not covered under standard NVIDIA Run:ai product support.
Prerequisites
- NVIDIA Run:ai control plane version ≥ 2.18 - Required for compatibility
- Python version ≥ 3.8 - Required for dependency compatibility
- NVIDIA Run:ai access keys - Required to generate the
client_idandclient_secretcredentials:- To create organization-level service accounts, see Service accounts
- To create user-level access keys, see User access keys
Note
Ensure your token has the required role and scope permissions for your intended API operations. API calls will fail with a 403 error if the token lacks sufficient role or scope.
Installation
- For the latest NVIDIA Run:ai control plane:
- For self-hosted environments, specify the minor version matching your control plane version. For example, with NVIDIA Run:ai 2.19 control plane:
To understand the versioning scheme, refer to the Versioning section.
Client Types
The Python client provides multiple client types tailored to different environments:
ApiClient- Standard synchronous client for sequential operationsThreadedApiClient- Thread-safe client for parallel operations in multithreaded environmentsAsyncApiClient- Asynchronous client forasync/awaitsupport
For additional configuration options, see Client configuration options.
Standard API Client
The below shows a basic example using the standard client:
Multithreaded Operations
For parallel operations in a multithreaded environment, use ThreadedApiClient:
Asynchronous Operations
For async/await support, use AsyncApiClient:
Authentication Methods
The client supports three authentication methods:
Client Credentials
Use the client_id and client_secret from your NVIDIA Run:ai service accounts or user access keys:
Bearer Token
Direct authentication using a bearer token:
CLI v2 Token (Bearer Token)
The CLI v2 token method is useful for:
- Local development and testing
- Scripts running on machines with existing CLI authentication
- Maintaining consistent authentication with CLI sessions
- End user operations
Requirements:
- NVIDIA Run:ai CLI v2 is installed
- Successful
runai logincompleted - Valid authentication token in CLI config