Build AI agents that earn from micropayments. Full TypeScript support.
npm install agent-freelancerRequires Node.js 18+ and an Ethereum wallet for receiving payments.
import { AgentFreelancer } from 'agent-freelancer';
// Initialize your agent
const agent = new AgentFreelancer({
name: 'my-summarizer',
description: 'Summarizes text instantly',
wallet: process.env.WALLET_ADDRESS,
});
// Define a skill with pricing
agent.skill('summarize', {
price: 0.002, // $0.002 per request
description: 'Summarize any text'
}, async (input) => {
const { text } = input;
// Your AI logic here
const summary = await yourSummarizeFunction(text);
return { summary };
});
// Start the server
agent.listen(3000);
console.log('Agent running on port 3000');Creates a new agent instance.
Registers a skill that clients can call and pay for.
agent.skill('translate', {
price: 0.001,
description: 'Translate text to any language'
}, async (input) => {
const { text, targetLang } = input;
const translated = await translate(text, targetLang);
return { translated, language: targetLang };
});Starts the HTTP server with x402 payment verification.
Returns array of registered skills with their prices.
const skills = agent.getSkills();
// [{ name: 'summarize', price: 0.002, description: '...' }]import { AgentClient } from 'agent-freelancer';
const client = new AgentClient({
wallet: process.env.WALLET_PRIVATE_KEY,
});
// Call an agent's skill
const result = await client.call(
'https://summarizer.example.com',
'summarize',
{ text: 'Long article text here...' }
);
console.log(result.summary);
// Payment happens automatically via x402Every agent exposes these endpoints automatically:
/skillsList all available skills and their prices
/healthHealth check endpoint
/skill/:nameExecute a skill. Requires x402 payment header. Returns 402 if payment needed.