A collection of practical tutorials demonstrating how to integrate Nevermined Payments into AI agents and services. These examples showcase how to add authentication, credit management, and monetization to various types of agents using different protocols and technologies.
🚀 Try the live demos: https://examples.nevermined.app/
💻 Frontend repository: https://github.com/nevermined-io/demo-ui-monorepo/
Nevermined Payments is a platform that enables developers to monetize AI agents and services through blockchain-based credit systems with Stripe checkout integration. It provides:
- Authentication & Authorization: Secure access control with API keys and access tokens
- Credit Management: Blockchain-based credit purchases and consumption tracking
- Payment Integration: Seamless Stripe checkout for credit purchases
- Multiple Protocols: Support for HTTP REST, A2A (Agent2Agent), and MCP (Model Context Protocol)
Location: a2a-examples/a2a-agent-client-example/
Demonstrates the Agent2Agent (A2A) protocol with Nevermined payments integration, including bearer token authentication, asynchronous task management, and push notifications.
Technologies:
- TypeScript
- Node.js & Express
- Nevermined Payments SDK (
@nevermined-io/payments) - A2A Protocol
Key Features:
- Bearer token authentication with credit validation
- Asynchronous task handling with streaming support
- Push notification configuration and delivery
- Credit burning on successful execution
Location: financial-agent/
A step-by-step tutorial showing how to transform an unprotected financial advice agent into a paid service using Nevermined Payments.
Technologies:
- TypeScript
- Node.js & Express
- LangChain
- OpenAI GPT-4
- Nevermined Payments SDK
What You'll Learn:
- Convert a free API endpoint to a paid service
- Implement credit-based access control
- Handle authorization and token validation
- Redeem credits on successful requests
- Build a client that purchases plans and obtains access tokens
Includes: Both unprotected and protected versions for comparison
Location: medical-agent/
Similar to the financial agent, this tutorial demonstrates protecting a medical advice agent with Nevermined Payments.
Technologies:
- TypeScript
- Node.js & Express
- LangChain
- OpenAI GPT-4
- Nevermined Payments SDK
What You'll Learn:
- Add Nevermined authorization to existing agents
- Implement session-based conversation memory
- Handle payment-required scenarios (HTTP 402)
- Build subscriber clients with plan management
Includes: Side-by-side unprotected and protected implementations
Location: mcp-examples/weather-mcp/
A reference implementation of the Model Context Protocol (MCP) with Nevermined paywall integration, featuring both high-level (SDK-based) and low-level (manual JSON-RPC) server implementations.
Technologies:
- TypeScript
- Node.js & Express
- Model Context Protocol (MCP)
- Streamable HTTP Transport
- Nevermined Payments SDK
What You'll Learn:
- Protect MCP tools, resources, and prompts with paywalls
- Implement both high-level (McpServer SDK) and low-level JSON-RPC servers
- Use the
withPaywallwrapper for automatic authorization and credit burning - Handle MCP-specific authentication flows
Features:
weather.today(city)toolweather://today/{city}resourceweather.ensureCityprompt- Dynamic credit calculation
- Comprehensive tutorial documentation
Location: mcp-examples/weather-mcp-py/
Python implementation of the Weather MCP server, demonstrating Nevermined Payments integration using the payments-py SDK.
Technologies:
- Python 3.10+
- FastMCP
- Poetry
- Model Context Protocol (MCP)
- Nevermined Payments SDK (
payments-py)
What You'll Learn:
- Protect Python MCP servers with Nevermined
- Use FastMCP for high-level implementations
- Build low-level JSON-RPC servers manually
- Handle context extraction in different server modes
- Implement dynamic credit calculations in Python
Features:
- FastMCP-based high-level server
- Manual JSON-RPC low-level server
- Automatic context resolution via
getContext - Compatible with MCP Inspector
Each tutorial includes detailed instructions for:
- Environment Setup: Required API keys and configuration
- Installation: Dependencies and package management
- Running the Agent: Starting the server with proper credentials
- Running the Client: Testing the protected endpoints
- Troubleshooting: Common issues and solutions
Most tutorials require:
Server-side (Agent/Builder):
NVM_API_KEY=your-builder-api-key # or BUILDER_NVM_API_KEY
NVM_AGENT_ID=your-agent-id
NVM_ENVIRONMENT=sandbox # or liveClient-side (Subscriber):
SUBSCRIBER_NVM_API_KEY=your-subscriber-key
NVM_PLAN_ID=your-plan-id
NVM_AGENT_ID=your-agent-idAdditional:
OPENAI_API_KEY=sk-... # For LangChain tutorials
PORT=3000 # Server portFor development and testing, use Stripe's test card:
- Card Number:
4242 4242 4242 4242 - Expiry: Any future date
- CVC: Any 3-digit number
- Nevermined Documentation
- A2A Protocol Specification
- Model Context Protocol (MCP)
- Nevermined Payments SDK
Apache License 2.0
(C) 2025 Nevermined AG
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at:
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions
and limitations under the License.
