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.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.create_agent
: Creates a new agentcreate_agent_and_plan
: Creates a new agent associated to a plan in one steporder_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_url
: Gets the plan details.get_service_details_url
: Gets the service details.get_file_details_url
: 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.search_plans
: Query for plans base on an input query options.search_agents
: Query for agents base on an input query options.query
: The AI Query API.ai_protocol
: The AI Query API. Deprecated__init__
__init__(
nvm_api_key: str,
environment: Environment,
app_id: Optional[str] = None,
version: Optional[str] = None,
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(createAgentDto: CreateAgentDto) → 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:
createAgentDto
: (CreateAgentDto): Options for the agent creation.create_agent_and_plan
create_agent_and_plan(
createCreditsPlanDto: CreateCreditsPlanDto,
createAgentDto: CreateAgentDto
) → CreateAgentAndPlanResultDto
It creates a new AI Agent and a Payment Plan on Nevermined.
The agent must be associated to the 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:
createTimePlanDto
: (CreateTimePlanDto): Options for the plan creationcreateAgentDto
: (CreateAgentDto): Options for the agent creation.create_credits_plan
create_credits_plan(
createCreditsPlanDto: CreateCreditsPlanDto
) → 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 resource 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:
createCreditsPlanDto
(CreateCreditsPlanDto): Options for the plan creationReturns:
CreateAssetResultDto
: The result of the creation operation.Raises:
HTTPError
: If the API call fails.Example: response = your_instance.create_credits_plan(CreateCreditsPlanDto(name=”Basic Plan”, description=”100 credits plan”, price=1, token_address=”0x1234”, amount_of_credits=100, tags=[“basic”])) print(response)
create_file
create_file(createFileDto: CreateFileDto) → 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:
createFileDto
: (CreateFileDto): Options for the file creation.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(createServiceDto: CreateServiceDto) → 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:
createServiceDto
: (CreateServiceDto): Options for the service creationReturns:
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(createTimePlanDto: CreateTimePlanDto) → 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:
createTimePlanDto
: (CreateTimePlanDto): Options for the plan creationReturns:
CreateAssetResultDto
: The result of the creation operation.Raises:
HTTPError
: If the API call fails.Example: response = your_instance.create_time_plan(CreateTimePlanDto(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: Optional[str] = None
) → BalanceResultDto
Get the balance of an account for a Payment Plan.
Args:
plan_did
(str): The DID of the plan.account_address
(Optional[str]): The account address. Defaults to self.account_address
if not provided.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_access_config
get_service_access_config(service_did: str) → ServiceTokenResultDto
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)
search_agents
search_agents(
text: Optional[str] = None,
page: Optional[int] = 1,
offset: Optional[int] = 10
)
Search for agents. It will search for agents matching the text provided in their metadata.
Args:
text
(str): The text to search for.page
(int): The page number.offset
(int): The offset.Returns:
Response
: The response from the API call.Example: response = your_instance.search_agents(text=”My Agent”) print(response)
search_plans
search_plans(
text: Optional[str] = None,
page: Optional[int] = 1,
offset: Optional[int] = 10
)
Search for plans. It will search for plans matching the text provided in their metadata.
Args:
text
(str): The text to search for.page
(int): The page number.offset
(int): The offset.Returns:
Response
: The response from the API call.Example: response = your_instance.search_plans(text=”Basic”) print(response)
This file was automatically generated via lazydocs.