Official Node.js SDK for interacting with the x402 AI Frens API. This SDK enables you to chat with AI agents, generate images, videos, and memes using blockchain-based payments.
aifrens-sdk is an early-stage TypeScript project in the AI payments / x402 ecosystem, focused on agents, ai, aifrens, x402. It currently has 3 GitHub stars and 2 forks, and sits alongside related tools like mcp-client, dna-x402, stronghold.
Official Node.js SDK for interacting with the x402 AI Frens API. This SDK enables you to chat with AI agents, generate images, videos, and memes using blockchain-based payments.
https://github.com/user-attachments/assets/7c44ae04-c1f6-446a-8600-f0f80d9f8a86
npm install @treasure_project/aifrens-sdk
This SDK requires a blockchain account signer for payment processing.
For server-side usage:
viem (for account creation) - already included as a dependencyFor client-side usage:
import { AIFrensClient } from "@treasure_project/aifrens-sdk";
import { mnemonicToAccount } from "viem/accounts";
// Initialize the client with your account
const account = mnemonicToAccount("your mnemonic phrase here");
const sdk = new AIFrensClient(account);
// Optional: Set maximum payment amount (default: 1000000000)
// const sdk = new AIFrensClient(account, 5000000000);
The examples folder includes some examples for how to use the SDK. You can run them using:
npm run example:chat
npm run example:image
npm run example:video
npm run example:meme
npm run example:data
Note: Make sure to update the mnemonic phrase in the example files before running them.
This SDK is written in TypeScript and includes full type definitions. All types are exported for your convenience:
import type {
ChatInput,
ChatResponse,
GenerateImageInput,
GenerateImageResponse,
GenerateVideoInput,
GenerateVideoResponse,
GenerateMemeInput,
GenerateMemeResponse,
AgentDataResponse,
MetadataResponse,
Route,
RouteType
} from "@treasure_project/aifrens-sdk";
The SDK uses the x402 protocol for payment processing. All API calls (except getMetadata() and getAgentData()) automatically handle payment through the blockchain. The payment response is included in every paid method's return value, allowing you to track transaction details.
All methods may return errors in the response object. Always check for errors:
const response = await sdk.chat(input);
if (response.response.error) {
console.error("Error:", response.response.error);
} else {
console.log("Success:", response.response.response);
}
sdk, api, typescript, node, ai-frens, treasure, x402, x402-ai-frens, ai, agents, agent
Discover and pay AI agents on nullpath's marketplace via MCP. x402 micropayments with USDC.
DNA — Payment rails for AI agents. x402 micropayment protocol on Solana. Netting, transfer, stream settlement. Receipt anchoring on-chain.
A CLI-driven security proxy that scans every HTTP request for threats using the Citadel AI engine — paid per request via the x402 protocol.
An open SDK for agentic payments. Let AI agents make payments, hold funds, and move money across chains with policy enforcement and human approval built in.
Golang SDK for A2A Protocol
Client SDK for the Vybe x402 API. Pay-per-call USDC over HTTP and prepaid-credit WebSocket streaming for Vybe's Solana analytics API. Built for AI agents.
Rust SDK for the Machine Payments Protocol
Building blocks for Agentic payments (x402, MPP, AP2) for TypeScript, Rust, Go, Python, Ruby, PHP, Lua, Kotlin and Swift.
Opinionated React Native crypto x AI chat app boilerplate with embedded wallet support, conversational AI, and dynamic UI component injection