Get the NVM API Key
Before using the SDK, you need a Nevermined API Key:- Go to the Nevermined App
- Sign in or create an account
- Navigate to Settings > API Keys
- Generate a new API key
- Copy the key (format:
nvm:xxxxxxxx...)
Import and Initialize
Basic Initialization
The
environment option is deprecated. The SDK now derives the
environment from the API-key prefix (<prefix>:<jwt>) — a key minted for
sandbox starts with sandbox:, for production with live:, and so on. When
the prefix is recognized it always wins; passing environment is ignored
(with a warning). It is still accepted only as a fallback for local/custom
keys whose prefix the SDK doesn’t recognize (see
Custom Environment).Using Environment Variables
Configuration Options
ThePaymentOptions class accepts the following parameters:
API Version Pinning
Every request the SDK sends to the Nevermined backend carries aNevermined-Version header declaring which backend API version
(MAJOR.MINOR) the SDK was built and tested against. You normally don’t
need to touch this — the SDK pins the right version for you. To target a
different backend contract explicitly:
Environments
The environment is determined by your API key’s prefix — you don’t select it explicitly. The prefix-to-environment mapping is:Sandbox Environment (Testing)
A key minted for sandbox starts withsandbox::
- Backend:
https://api.sandbox.nevermined.app - Proxy:
https://proxy.sandbox.nevermined.app - Uses test tokens and test networks
Live Environment (Production)
A key minted for production starts withlive::
- Backend:
https://api.live.nevermined.app - Proxy:
https://proxy.live.nevermined.app - Uses real tokens and mainnet networks
Custom Environment
For self-hosted or local development setups, the API key’s prefix won’t be one the SDK recognizes, so it falls back to the (still-accepted)environment
option. Pass environment="custom" to point the SDK at URLs from environment
variables:
Available Environments
Accessing Sub-APIs
The initializedPayments object provides access to specialized APIs:
Error Handling
The SDK raisesPaymentsError for API errors:
Next Steps
Now that you have initialized the SDK, proceed to:- Payment Plans - Create payment plans
- Agents - Register AI agents