payments
Payments
A class representing a payment system.
Attributes:
nvm_api_key
(str): The nvm api key for authentication.environment
(Environment): The environment for the payment system.app_id
(str, optional): The application ID.version
(str, optional): The version of the payment system.ai_protocol
(bool): Indicates if the AI protocol is enabled.headers
(dict, optional): The headers for the payment system. Methods:create_credits_plan
: Creates a new credits plan.create_time_plan
: Creates a new time plan.create_service
: Creates a new service.create_file
: Creates a new file.order_plan
: Orders the plan.get_asset_ddo
: Gets the asset DDO.get_plan_balance
: Gets the plan balance.get_service_token
: Gets the service token.get_plan_associated_services
: Gets the plan associated services.get_plan_associated_files
: Gets the plan associated files.get_plan_details
: Gets the plan details.get_service_details
: Gets the service details.get_file_details
: Gets the file details.get_checkout_plan
: Gets the checkout plan.download_file
: Downloads the file.mint_credits
: Mints the credits associated to a plan and send to the receiver.burn_credits
: Burns credits associated to a plan that you own.ai_protocol
: The AI Query API.__init__
__init__(
nvm_api_key: str,
environment: Environment,
app_id: Optional[str] = None,
version: Optional[str] = None,
ai_protocol: bool = False,
headers: Optional[dict] = None
)
burn_credits
burn_credits(plan_did: str, amount: str) → BurnResultDto
Burn credits for a given Payment Plan DID.
This method is only can be called by the owner of the Payment Plan.
Args:
plan_did
(str): The DID of the plan.amount
(str): The amount of credits to burn.Returns:
BurnResultDto
: The result of the burning operation.Raises:
HTTPError
: If the API call fails.Example: response = your_instance.burn_credits(plan_did=”did:nv:e405a91e3152be1430c5d0607ebdf9236c19f34bfba0320798d81ba5f5e3e3a5”, amount=”12”) print(response)
create_agent
create_agent(
plan_did: str,
name: str,
description: str,
service_charge_type: str,
auth_type: str,
amount_of_credits: int = 1,
min_credits_to_charge: Optional[int] = 1,
max_credits_to_charge: Optional[int] = 1,
username: Optional[str] = None,
password: Optional[str] = None,
token: Optional[str] = None,
endpoints: Optional[List[dict]] = None,
open_endpoints: Optional[List[str]] = [],
open_api_url: Optional[str] = None,
integration: Optional[str] = None,
sample_link: Optional[str] = None,
api_description: Optional[str] = None,
tags: Optional[List[str]] = None,
use_ai_hub: Optional[bool] = None,
implements_query_protocol: Optional[bool] = None,
query_protocol_version: Optional[str] = None,
service_host: Optional[str] = None
) → CreateAssetResultDto
It creates a new AI Agent on Nevermined. The agent must be associated to a Payment Plan. Users that are subscribers of a payment plan can access the agent. Depending on the Payment Plan and the configuration of the agent, the usage of the agent will consume credits. When the plan expires (because the time is over or the credits are consumed), the user needs to renew the plan to continue using the agent.
This method is oriented to AI Builders
https://docs.nevermined.app/docs/tutorials/builders/register-agent
Args:
plan_did
(str): The DID of the plan.name
(str): The name of the agent.description
(str): The description of the agent.service_charge_type
(str): The charge type of the agent. Options: ‘fixed’, ‘dynamic’auth_type
(str): The authentication type of the agent. Options: ‘none’, ‘basic’, ‘oauth’amount_of_credits
(int): The amount of credits for the agent.min_credits_to_charge
(int, optional): The minimum credits to charge for the agent. Only required for dynamic agents.max_credits_to_charge
(int, optional): The maximum credits to charge for the agent. Only required for dynamic agents.username
(str, optional): The username for authentication.password
(str, optional): The password for authentication.token
(str, optional): The token for authentication.endpoints
(List[Dict[str, str]], optional): The endpoints of the agent.open_endpoints
(List[str], optional): The open endpoints of the agent.open_api_url
(str, optional): The OpenAPI URL of the agent.integration
(str, optional): The integration type of the agent.sample_link
(str, optional): The sample link of the agent.api_description
(str, optional): The API description of the agent.tags
(List[str], optional): The tags associated with the agent.use_ai_hub
(bool, optional): If the agent is using the AI Hub. If true, the agent will be configured to use the AI Hub endpoints.implements_query_protocol
(bool, optional): Indicates if the agent implements the query protocol.query_protocol_version
(str, optional): The version of the query protocol implemented by the agent.service_host
(str, optional): The host of the agent.create_credits_plan
create_credits_plan(
name: str,
description: str,
price: int,
token_address: str,
amount_of_credits: int,
tags: Optional[List[str]] = None
) → CreateAssetResultDto
It allows to an AI Builder to create a Payment Plan on Nevermined based on Credits. A Nevermined Credits Plan limits the access by the access/usage of the Plan. With them, AI Builders control the number of requests that can be made to an agent or service. Every time a user accesses any resouce associated to the Payment Plan, the usage consumes from a capped amount of credits. When the user consumes all the credits, the plan automatically expires and the user needs to top up to continue using the service.
This method is oriented to AI Builders.
https://docs.nevermined.app/docs/tutorials/builders/create-plan
Args:
name
(str): The name of the plan.description
(str): The description of the plan.price
(int): The price of the plan.token_address
(str): The token address.amount_of_credits
(int): The amount of credits for the plan.tags
(List[str], optional): The tags associated with the plan.Returns:
CreateAssetResultDto
: The result of the creation operation.Raises:
HTTPError
: If the API call fails.Example: response = your_instance.create_credits_plan(name=”Basic Plan”, description=”100 credits plan”, price=1, token_address=”0x1234”, amount_of_credits=100, tags=[“basic”]) print(response)
create_file
create_file(
plan_did: str,
asset_type: str,
name: str,
description: str,
files: List[dict],
data_schema: Optional[str] = None,
sample_code: Optional[str] = None,
files_format: Optional[str] = None,
usage_example: Optional[str] = None,
programming_language: Optional[str] = None,
framework: Optional[str] = None,
task: Optional[str] = None,
training_details: Optional[str] = None,
variations: Optional[str] = None,
fine_tunable: Optional[bool] = None,
amount_of_credits: Optional[int] = None,
tags: Optional[List[str]] = None
) → CreateAssetResultDto
It creates a new asset with file associated to it. The file asset must be associated to a Payment Plan. Users that are subscribers of a payment plan can download the files attached to it. Depending on the Payment Plan and the configuration of the file asset, the download will consume credits. When the plan expires (because the time is over or the credits are consumed), the user needs to renew the plan to continue downloading the files.
This method is oriented to AI Builders
https://docs.nevermined.app/docs/tutorials/builders/register-file-asset
Args:
plan_did
(str): The DID of the plan.asset_type (str): The type of the asset. -> ‘algorithm’ |
‘model’ | ‘dataset’ | ‘file’ |
name
(str): The name of the file.description
(str): The description of the file.files
(List[dict]): The files of the file.data_schema
(str, optional): The data schema of the file.sample_code
(str, optional): The sample code of the file.files_format
(str, optional): The files format of the file.usage_example
(str, optional): The usage example of the file.programming_language
(str, optional): The programming language of the file.framework
(str, optional): The framework of the file.task
(str, optional): The task of the file.training_details
(str, optional): The training details of the file.variations
(str, optional): The variations of the file.fine_tunable
(bool, optional): The fine tunable of the file.amount_of_credits
(int, optional): The amount of credits for the file.tags
(List[str], optional): The tags associated with the file.Returns:
CreateAssetResultDto
: The result of the creation operation.Raises:
HTTPError
: If the API call fails.Example: response = your_instance.create_file(plan_did=”did:nv:xyz789”, asset_type=”dataset”, name=”Sample Dataset”, description=”A sample dataset”, files=[{“name”: “file1.csv”, “url”: “https://example.com/file1.csv”}]) print(response)
create_service
create_service(
plan_did: str,
service_type: str,
name: str,
description: str,
service_charge_type: str,
auth_type: str,
amount_of_credits: int = 1,
min_credits_to_charge: Optional[int] = 1,
max_credits_to_charge: Optional[int] = 1,
username: Optional[str] = None,
password: Optional[str] = None,
token: Optional[str] = None,
endpoints: Optional[List[dict]] = None,
open_endpoints: Optional[List[str]] = [],
open_api_url: Optional[str] = None,
integration: Optional[str] = None,
sample_link: Optional[str] = None,
api_description: Optional[str] = None,
tags: Optional[List[str]] = None,
is_nevermined_hosted: Optional[bool] = None,
implements_query_protocol: Optional[bool] = None,
query_protocol_version: Optional[str] = None,
service_host: Optional[str] = None
) → CreateAssetResultDto
It creates a new AI Agent or Service on Nevermined. The agent/service must be associated to a Payment Plan. Users that are subscribers of a payment plan can access the agent/service. Depending on the Payment Plan and the configuration of the agent/service, the usage of the agent/service will consume credits. When the plan expires (because the time is over or the credits are consumed), the user needs to renew the plan to continue using the agent/service.
This method is oriented to AI Builders
https://docs.nevermined.app/docs/tutorials/builders/register-agent
Args:
plan_did
(str): The DID of the plan.service_type
(str): The type of the service. Options: ‘service’, ‘agent’, ‘assistant’name
(str): The name of the service.description
(str): The description of the service.service_charge_type
(str): The charge type of the service. Options: ‘fixed’, ‘dynamic’auth_type
(str): The authentication type of the service. Options: ‘none’, ‘basic’, ‘oauth’amount_of_credits
(int): The amount of credits for the service.min_credits_to_charge
(int, optional): The minimum credits to charge for the service. Only required for dynamic services.max_credits_to_charge
(int, optional): The maximum credits to charge for the service. Only required for dynamic services.username
(str, optional): The username for authentication.password
(str, optional): The password for authentication.token
(str, optional): The token for authentication.endpoints
(List[Dict[str, str]], optional): The endpoints of the service.open_endpoints
(List[str], optional): The open endpoints of the service.open_api_url
(str, optional): The OpenAPI URL of the service.integration
(str, optional): The integration type of the service.sample_link
(str, optional): The sample link of the service.api_description
(str, optional): The API description of the service.tags
(List[str], optional): The tags associated with the service.is_nevermined_hosted
(bool, optional): Indicates if the service is hosted by Nevermined.implements_query_protocol
(bool, optional): Indicates if the service implements the query protocol.query_protocol_version
(str, optional): The version of the query protocol implemented by the service.service_host
(str, optional): The host of the service.Returns:
CreateAssetResultDto
: The result of the creation operation.Raises:
HTTPError
: If the API call fails.Example: response = your_instance.create_service(plan_did=”did:nv:abc123”, service_type=”service”, name=”My Service”, description=”A sample service”, service_charge_type=”fixed”, auth_type=”none”) print(response)
create_time_plan
create_time_plan(
name: str,
description: str,
price: int,
token_address: str,
duration: Optional[int] = 0,
tags: Optional[List[str]] = None
) → CreateAssetResultDto
It allows to an AI Builder to create a Payment Plan on Nevermined based on Time. A Nevermined Time Plan limits the access by the a specific amount of time. With them, AI Builders can specify the duration of the Payment Plan (1 month, 1 year, etc.). When the time period is over, the plan automatically expires and the user needs to renew it.
This method is oriented to AI Builders
https://docs.nevermined.app/docs/tutorials/builders/create-plan
Args:
name
(str): The name of the plan.description
(str): The description of the plan.price
(int): The price of the plan.token_address
(str): The token address.duration
(int, optional): The duration of the plan in days. If not provided, the plan will be valid forever.tags
(List[str], optional): The tags associated with the plan.Returns:
CreateAssetResultDto
: The result of the creation operation.Raises:
HTTPError
: If the API call fails.Example: response = your_instance.create_time_plan(name=”Yearly Plan”, description=”Annual plan”, price=1200, token_address=”0x5678”, duration=365, tags=[“yearly”, “premium”]) print(response)
download_file
download_file(
file_did: str,
destination: str,
agreement_id: Optional[str] = None
) → DownloadFileResultDto
Downloads the file.
Args:
file_did
(str): The DID of the file.agreement_id
(str, optional): The agreement ID.destination str
: The destination of the file.Returns:
Response
: The url of the file.Returns:
DownloadFileResultDto
: The result of the download operation.Raises:
HTTPError
: If the API call fails.Example: response = your_instance.download_file(file_did=”did:nv:7e38d39405445ab3e5435d8c1c6653a00ddc425ba629789f58fbefccaa5e5a5d”, destination=”/tmp”) print(response)
get_asset_ddo
get_asset_ddo(did: str)
Get the Metadata (aka Decentralized Document or DDO) for a given asset identifier (DID).
https://docs.nevermined.io/docs/architecture/specs/Spec-DID https://docs.nevermined.io/docs/architecture/specs/Spec-METADATA
Args:
did
(str): The unique identifier (aka DID) of the asset (payment plan, agent, file, etc).Returns:
Response
: The response from the API call.get_checkout_plan
get_checkout_plan(plan_did: str)
Gets the checkout plan.
Args:
plan_did
(str): The DID of the plan.Returns:
Response
: The url of the checkout plan.get_file_details_url
get_file_details_url(file_did: str)
Gets the file details.
Args:
file_did
(str): The DID of the file.Returns:
Response
: The url of the file details.get_plan_associated_files
get_plan_associated_files(plan_did: str)
Get array of files DIDs associated with a payment plan.
Args:
plan_did
(str): The DID of the plan.Returns:
Response
: List of DIDs of the associated files.get_plan_associated_services
get_plan_associated_services(plan_did: str)
Get array of services/agent DIDs associated with a payment plan.
Args:
plan_did
(str): The DID of the plan.Returns:
Response
: List of DIDs of the associated services.get_plan_balance
get_plan_balance(plan_did: str, account_address: str) → BalanceResultDto
Get the balance of an account for a Payment Plan.
Args:
plan_did
(str): The DID of the plan.account_address
(str): The account address.Returns:
BalanceResultDto
: The response from the API call formatted as a BalanceResultDto.Raises:
HTTPError
: If the API call fails.Example: response = your_instance.get_plan_balance(plan_did=”did:example:123456”, account_address=”0xABC123”) response.raise_for_status() balance = BalanceResultDto.model_validate(response.json()) print(balance)
Expected Response: { “planType”: “credits”, “isOwner”: True, “isSubscriptor”: True, “balance”: 10000000 }
get_plan_details_url
get_plan_details_url(plan_did: str)
Gets the plan details.
Args:
plan_did
(str): The DID of the plan.Returns:
Response
: The url of the plan details.get_service_details_url
get_service_details_url(service_did: str)
Gets the service details.
Args:
service_did
(str): The DID of the service.Returns:
Response
: The url of the service details.get_service_token
get_service_token(service_did: str) → ServiceTokenResultDto
Get the required configuration for accessing a remote service agent. This configuration includes: - The JWT access token - The Proxy url that can be used to query the agent/service.
Args:
service_did
(str): The DID of the service.Returns:
ServiceTokenResultDto
: The result of the creation operation.Raises:
HTTPError
: If the API call fails.Example: response = your_instance.get_service_token(service_did=”did:nv:xyz789”) print(response)
mint_credits
mint_credits(plan_did: str, amount: str, receiver: str) → MintResultDto
Mints the credits associated with a plan and sends them to the receiver.
Args:
plan_did
(str): The DID of the plan.amount
(str): The amount of credits to mint.receiver
(str): The receiver address of the credits.Returns:
MintResultDto
: The result of the minting operation.Raises:
HTTPError
: If the API call fails.Example: response = your_instance.mint_credits(plan_did=”did:nv:e405a91e3152be1430c5d0607ebdf9236c19f34bfba0320798d81ba5f5e3e3a5”, amount=”12”, receiver=”0x4fe3e7d42fA83be4E8cF03451Ac3F25980a73fF6”) print(response)
order_plan
order_plan(
plan_did: str,
agreementId: Optional[str] = None
) → OrderPlanResultDto
Orders a Payment Plan. The user needs to have enough balance in the token selected by the owner of the Payment Plan.
The payment is done using Crypto. Payments using Fiat can be done via the Nevermined App.
Args:
plan_did
(str): The DID of the plan.agreementId
(str, optional): The agreement ID.Returns:
OrderPlanResultDto
: The result of the order operation, containing the agreement ID and success status.Raises:
HTTPError
: If the API call fails.Example: response = your_instance.order_plan(plan_did=”did:nv:a0079b517e580d430916924f1940b764e17c31e368c509483426f8c2ac2e7116”) print(response)
This file was automatically generated via lazydocs.