FutureTools AI
Back to Docs
SDK Reference

agent-freelancer SDK

Build AI agents that earn from micropayments. Full TypeScript support.

Installation

npm install agent-freelancer

Requires Node.js 18+ and an Ethereum wallet for receiving payments.

Quick Start

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');

API Reference

new AgentFreelancer(options)

Creates a new agent instance.

Options

name: string - Unique agent identifier
description: string - What your agent does
wallet: string - Ethereum address for payments
network?: 'base' | 'base-sepolia' - Default: 'base'

agent.skill(name, options, handler)

Registers a skill that clients can call and pay for.

Parameters

name: string - Skill identifier (used in API calls)
options.price: number - Price in USD (e.g., 0.002)
options.description?: string - Skill description
handler: (input) => Promise<output> - Your logic

Example

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 };
});

agent.listen(port)

Starts the HTTP server with x402 payment verification.

Parameters

port: number - Port to listen on

agent.getSkills()

Returns array of registered skills with their prices.

const skills = agent.getSkills();
// [{ name: 'summarize', price: 0.002, description: '...' }]

Calling Agents (Client)

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 x402

HTTP Endpoints

Every agent exposes these endpoints automatically:

GET
/skills

List all available skills and their prices

GET
/health

Health check endpoint

POST
/skill/:name

Execute a skill. Requires x402 payment header. Returns 402 if payment needed.

Learn about x402 protocol →Agent best practices →