Back to blog

Monetizing AI services with Smart Subscriptions

Access control

9 min read

This is the first post of a series showing how Nevermined enables the monetization of AI as well as Data. In this article we discuss our latest features, which allow for the monetization and access control of AI web services using Nevermined’s Smart Subscriptions. We’ll cover the monetization of Data later.

For context, in previous posts (“Bringing online subscriptions into Web3 with NFTs” and “NFTs are dead. Long live NFTs!”), we introduced some of the concepts and building blocks we are using. The short version: blockchain technology is critical in activating the utility of digital assets, in this case an AI service.

So you’ve built an AI model or agent. Now what?

Tens of thousands of smart people are building AI agents, apps and models. Some of them via APIs of services like ChatGPT, some of them via open source LLMs, some of them build their own. But the crux is: how can you scale usage and make some money?

On the other side of the fence, there are plenty of businesses and developers looking to integrate one or more AI tools into their processes and applications.

Nevermined bridges that gap with Smart Subscriptions, tokens that control the access to an AI’s Web Service.

This approach is based on a proven technique of making Web2 services available to be used by third-parties (eg.. OpenAI API etc.). But as we discussed here, this model has some limitations. It mostly requires paying with a credit card and getting an access token that lives in the database of a third-party company. That subscription is something totally illiquid from the subscriber point of view. For example, if it’s not used, the subscriber loses the value of that subscription.

At Nevermined we use Web3 tech to tokengate a Web2 service. Smart Subscriptions can help AI web service publishers control the access to their product web2 services, making them available and facilitating the direct monetization via peer-to-peer trading between the publisher and the users (sorry Stripe). From the point of view of these users, what they get is a subscription they really own because it doesn’t live in the company database anymore. This subscription has become a liquid asset and can be traded or used in different ways.

How does it work?

Let’s unpack this for 2 different personas, the Publishers of the web service and the Users. The Publishers just need to:

  1. Define one or more subscription tiers. This includes a basic description about the service, the duration of the subscription (e.g. one year.) — the price of the subscription (e.g. 10 USDC.)
  2. Register your AI’s web service endpoints and the service authentication. Once that’s done, you simply link it to the subscription(s) that you created in step 1.
A publisher can register a subscription

The resulting Subscription is your Nevermined asset with an associated Smart Contract owned by the publisher. The web service is also registered as your Nevermined asset and defines conditions that restrict access to only those holders of the applicable access token (i.e. your Smart Subscription).

A publisher can register an AI service and associate to a subscription

When the Publisher provides information about the service, in many occasions these web services are protected to avoid everyone accessing them. Nevermined enables end-point service protection via its tool that encrypts the relevant access information available only to certain node(s) of the network trusted by the Publisher (note that trust can be revoked at any time.).

How does it work, part 2 — the User

From the User side, the process is simple. After reviewing the details of a web service via the metadata provided by the Publisher, the User can purchase the subscription from the Publisher and get access to the associated service. In doing so, the user will own a token that provides access to the web service.

Subscribers can discover and purchase subscriptions giving access to assets

Now that the Subscriber owns a Smart Subscription, they can access the associated service(s) via a unique access token (JWT). This token identifies the User as a subscriber and allows them to send HTTP requests to the web service through any of the Nevermined proxies trusted by the Publisher.

Subscribers can get a JWT that works as access key

Everything here is standard HTTP. A Subscriber who has a JWT access token can make requests with any standard HTTP client or library.

Under the hood, this work as follows:

  1. The Subscriber gets a JWT access token.
  2. The Subscriber configures the JWT access token in a HTTP client or library to communicate with any of the trusted proxies of the Smart Subscription.
  3. The Subscriber, via the HTTP client, sends a secure request to the web service through the proxy attaching the JWT access token.
  4. The proxy checks the access token and authorizes the User.
  5. If the User is authorized, based on the conditions of the Subscription access token, the proxy composes a valid request to the upstream web service, including the upstream. authorization token (different to the JWT and never released to the User)
  6. The web service authorizes the request and returns the result of the web service call through the proxy.

And voila, the User who purchased the Smart Subscription now has access to a web service only available to the holders of the token.

Some of the secret sauce here (but not so secret because it is Open Source) comes from the Nevermined Proxy. This component can be run by anyone, allowing the existence of networks of Proxies trusted (or not) by the Publishers and Users. Enter decentralized superpowers for the win!

I want to see this working!

Nothing like a demo to see things moving. Next we will show how all this works using the Nevermined App, it’s still a prototype but we plan to have a production version soon.

Let’s say I’m using my OpenAI account to fine tune an Elvis Presley copilot, based on everything that can be scraped about Elvis (i.e. biographies, lyrics, etc.). After creating this context-specific dataset and fine tuning the inference using my OpenAI account, I have a specific context that can be used to “interact” with Elvis. I could then build some cool stuff on top (Elvis tamagotchi anyone??). But, it would be nice to allow others to build applications using this Elvis context and charge for it

Using Nevermined, I can register a Smart Subscription, register my Elvis OpenAI web service and link the two together. Then I can publish the Elvis Copilot Subscription, allowing my subscribers to get access to my Elvis context model, all while protecting my access token so it’s never publicly available.

First, I create the Subscription’s smart contract and then register the Subscription:

I now have a new token contract deployed on the Polygon network (right now on the Mumbai testnet) that represents your subscription conditions. Here you can see an example of the metadata associated with such subscription. Next, I need to register the Elvis AI web service:

Again, here you can see the metadata associated with an Elvis AI service we created.

At this point the Elvis Copilot Publisher is done, so let’s switch to the user role. Let’s assume there is a marketplace where the user can search and discover AI services, so when they are interested in an Elvis Copilot, they can find and buy the associated Smart Subscription.

Once the fee has been paid, the user holds the subscription token, giving access to the web service:

In the dashboard users can see the assets the published and purchased

Next, I need to generate the JWT. Via the user interface I get more info about the DID of the web service related to the JWT:

The JWT is the key to access the web service

We have all we need. With the JWT token generated and knowing the proxy or proxies we can use, we just need to use whatever HTTP client or library to get access to the underlying web service through the proxy:

export $JWT_TOKEN="" # Here the JWT token pasted from the NVM App
$ export REQUEST_DATA='{"queries": [{"query": "Adam And Evil", "filter": {}, "top_k": 1 }]}'
$ curl -k -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $JWT_TOKEN" -d "$REQUEST_DATA" https://proxy.nevermined.network/ask
{"response":"nThe song is about a person who is in love with someone who is not perfect, but they cannot live without them. Despite knowing that loving this person will bring heartache, they are willing to take the risk and accept the consequences. The song also compares the relationship to the story of Adam and Eve, with the person in the song being like Adam and their love interest being like Eve.","source_nodes":[{"node":{"text":"Now Adam and Evil, they go hand in hand Eve taught him sin, that's the way it all began But every time you kiss me, my heart pounds like a drum So trouble is a woman, trouble here I come I'm lonely like Adam, you're evil like Eve I shouldn't take forbidden fruit 'cos I believe I'll be heading straight for heartache I should cut loose and run But if loving you means heartache Heartache, here I come You're not the angel that I dreamed about But you're the devil I don't want to live without A woman's a woman, a man is a man I can't be free I'm just putty in your hands Who cares about tomorrow, I need your love tonight And even if you're evil, baby hold me tight You're not the angel that I dreamed about But you're the devil I don't want to live without A","doc_id":"8e748293-f8d2–41b8-a225–7479455b1899","embedding":null,"doc_hash":"451d68b33de1e8034e48c6a98865364e52edd02837f06c34c662ba6d6d462c76","extra_info":null,"node_info":{"start":0,"end":1030},"relationships":{"1":"did:nv:3e0a13a6dba0ab20e83bf25c3e820af8b71c94cea0ab0763b4f822a6998009e6"}},"score":0.7585169416635178}],"extra_info":null}

Note, that in the above example the Elvis Copilot is returning which asset it uses to generate the answer. This is very useful because it allows us to verify what data was used by the AI to generate the answer.

What’s next?

In this post we explained how AI Publishers can make their assets available using Nevermined Smart Subscriptions to monetize and control access to the web service.

The short term future brings us two things.

First, we are working to put all this together in a user interface. Our motivation is to make it simple for AI Publishers to register their services and for the Users to get access to them.

Secondly, we’re working on extending the features of Nevermined to Data Publishers. Note that the example of this post focused on making an AI asset available via tokengated web service. As many of you know, a web service = a web service = a web service, so you could also use Smart Subscriptions to tokengate access to a Data Web Service. But we’re also working on other ways to create access control and monetization benefits for Data Publishers.

If you are interested in this or have any questions or feedback, please feel free to drop us a line in our Discord server.

Stay tuned, Nevermined app is coming …….