Skip to content

fluidbase9/fadp-proxy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fluid-fadp-proxy

FADP proxy server for AI compute services.

Let AI agents pay for OpenRouter, RunPod, Vast.ai, and Spheron in USDC — automatically, with no API keys or credit cards needed by the agent.

npm version License: MIT


How It Works

AI Agent
   |
   | agent.fetch('http://your-proxy/openrouter/chat/completions')
   |
   ▼
FADP Proxy (this server)
   |-- returns 402 + X-FADP-Required: { amount: "0.001 USDC" }
   |-- agent pays automatically via Fluid Wallet
   |-- proxy verifies payment on Base blockchain
   |-- forwards request to real OpenRouter API
   |-- returns response to agent
   |
   ▼
OpenRouter / RunPod / Vast.ai / Spheron
(proxy uses your API keys — agent never sees them)

Quick Start

# Install
npm install -g fluid-fadp-proxy

# Copy and fill in your config
cp .env.example .env

# Start the proxy
npx fluid-fadp-proxy

Configuration (.env)

# Your Fluid Wallet address — receives all USDC payments
FLUID_WALLET_ADDRESS=0xYourAddress

# Service API keys (add only what you have)
OPENROUTER_API_KEY=sk-or-...
RUNPOD_API_KEY=...
VASTAI_API_KEY=...
SPHERON_API_KEY=...

# Pricing in USDC per request (defaults shown)
PRICE_OPENROUTER=0.001
PRICE_RUNPOD=0.05
PRICE_VASTAI=0.10
PRICE_SPHERON=0.02

Agent Usage

Agents pay automatically using fluid-wallet-agentkit:

import { FluidAgent } from 'fluid-wallet-agentkit';

const agent = new FluidAgent({
  apiKey: process.env.FLUID_AGENT_KEY,  // fwag_...
  fadp: true,                            // auto-pay enabled
  fadpMaxUsd: 5,                         // safety limit
});

// Call OpenRouter — agent pays 0.001 USDC automatically
const res = await agent.fetch('http://localhost:4000/openrouter/chat/completions', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    model: 'openai/gpt-4o',
    messages: [{ role: 'user', content: 'Hello' }],
  }),
});
const data = await res.json();

// Call RunPod — agent pays 0.05 USDC per job
const job = await agent.fetch('http://localhost:4000/runpod/YOUR_ENDPOINT/run', {
  method: 'POST',
  body: JSON.stringify({ input: { prompt: 'Generate an image of...' } }),
});

// Check GPU offers on Vast.ai (free — no payment)
const gpus = await agent.fetch('http://localhost:4000/vastai/bundles?num_gpus=1');

// Create Spheron deployment — agent pays 0.02 USDC
const deploy = await agent.fetch('http://localhost:4000/spheron/compute/instance', {
  method: 'POST',
  body: JSON.stringify({ name: 'my-app', image: 'nginx:latest' }),
});

Endpoints

OpenRouter (/openrouter)

Method Path FADP Payment Description
POST /openrouter/chat/completions 0.001 USDC LLM chat (all models, streaming supported)
GET /openrouter/models Free List available models

RunPod (/runpod)

Method Path FADP Payment Description
POST /runpod/:endpointId/run 0.05 USDC Submit async job
POST /runpod/:endpointId/runsync 0.05 USDC Submit sync job
GET /runpod/:endpointId/status/:jobId Free Check job status
POST /runpod/graphql Free GraphQL (list GPUs etc.)

Vast.ai (/vastai)

Method Path FADP Payment Description
GET /vastai/bundles Free Search GPU offers
PUT /vastai/asks/:id 0.10 USDC Create/bid on instance
GET /vastai/instances Free List your instances
DELETE /vastai/instances/:id Free Destroy instance

Spheron (/spheron)

Method Path FADP Payment Description
GET /spheron/compute/machine-images Free List available machines
POST /spheron/compute/instance 0.02 USDC Create deployment
GET /spheron/compute/instance/:id Free Deployment status
DELETE /spheron/compute/instance/:id Free Close deployment

What Happens When an Agent Calls a Paid Endpoint

1. Agent sends request (no payment)
2. Proxy returns 402 + X-FADP-Required header
3. Agent's FluidAgent.fetch() detects 402
4. Agent calls fluidnative.com/v1/agents/send → pays USDC on Base
5. Agent retries with X-FADP-Proof: { txHash, nonce }
6. Proxy calls fluidnative.com/v1/fadp/verify → confirmed on-chain
7. Proxy forwards request to real service API
8. Returns response to agent
Total extra time: ~2-3 seconds for on-chain confirmation

Deploy to Production

# Railway / Render / Fly.io
git clone https://github.com/fluidbase9/fadp-proxy
cd fadp-proxy
# Set env vars in your hosting dashboard
# Deploy

Links


License

MIT © Fluid Wallet

About

FADP proxy server — let AI agents pay for OpenRouter, RunPod, Vast.ai, Spheron in USDC automatically

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors