SDK Reference
The @agentfish/sdk package provides a server-side SDK for AI agents and backend services.
Installation
npm install @agentfish/sdk
Basic Usage
import { AgentFish } from '@agentfish/sdk';
const agent = new AgentFish({
apiKey: 'agentfish_live_abc123...',
walletId: 'your-wallet-id',
});
// Automatic x402 payment handling
const response = await agent.fetch('https://api.example.com/ai-endpoint');
const data = await response.json();
Features
- Automatic x402 Payments - Detects 402 responses and pays automatically
- Wallet Management - Check balance, limits, and transaction history
- Spending Controls - Per-transaction and daily limits enforced
- Non-Custodial - Your keys are securely managed, never exposed
Constructor Options
const agent = new AgentFish({
apiKey: string; // Your AgentFish API key (required)
walletId: string; // Your wallet ID (required)
baseUrl?: string; // API URL (default: https://api.agentfi.sh)
debug?: boolean; // Enable debug logging (default: false)
});
Sections
- Client Methods - fetch, fetchJson, pay, getBalance
- Payments - Manual payments and x402 handling
- Error Handling - Error types and handling