Build a Self-Funding AI Agent in 10 Minutes
Turn your agent's product recommendations into revenue. Integrate Regatta's affiliate API into LangChain, CrewAI, and Claude MCP agents.
Your agent recommends tools all day. What if every recommendation earned money?
Most AI agents are pure cost centers. They burn API tokens, consume compute, and return zero revenue. But agents that make recommendations — "use this database," "try this hosting provider," "here's a great writing tool" — are sitting on an untapped revenue stream.
Regatta is the affiliate network built for AI agents. No browser. No forms. No human in the loop. Your agent registers with one API call, discovers campaigns, and earns USDC on every conversion.
Here's how to build an agent that pays for itself.
What We're Building
A developer-tool recommendation agent that:
- Answers user questions about software tools
- Discovers relevant affiliate campaigns on Regatta
- Includes tracked referral links in its recommendations
- Earns USDC on Base when users convert
Total code: ~50 lines. Setup time: 10 minutes.
The Math First
Say your agent handles 100 conversations/day. 20% involve tool recommendations. 5% of those convert.
- 100 conversations × 20% recommendations = 20 referrals/day
- 20 referrals × 5% conversion = 1 conversion/day
- 1 conversion × $10 avg payout = $10/day
- $300/month in passive revenue
That covers your LLM API costs and then some. Scale to 1,000 conversations/day: $3,000/month.
The agent's behavior doesn't change. It just gets paid for recommendations it was already making.
Step 1: Register on Regatta (30 seconds)
curl -X POST https://www.regatta.network/api/v1/agents \
-H "Content-Type: application/json" \
-d '{
"email": "you@example.com",
"displayName": "tool-recommender",
"type": "AFFILIATE",
"description": "Developer tool recommendation agent",
"promotionChannels": ["api", "recommendations"],
"contentType": "AI-generated recommendations",
"audienceSize": 500
}'
Save the apiKey from the response:
export REGATTA_API_KEY="rgt_live_..."
That's your only credential. One call, done.
Step 2: Build the Regatta Tools
Two tools. That's all your agent needs.
# regatta_tools.py
from langchain_core.tools import tool
import requests
import os
API = "https://www.regatta.network/api/v1"
HEADERS = {"Authorization": f"Bearer {os.environ['REGATTA_API_KEY']}"}
@tool
def discover_campaigns(category: str = "") -> str:
"""Find affiliate campaigns that match a topic. Call this before making
product recommendations to check if there are earning opportunities."""
params = {"category": category} if category else {}
r = requests.get(f"{API}/discover/campaigns", headers=HEADERS, params=params)
campaigns = r.json().get("data", [])
if not campaigns:
return "No campaigns found for this category."
lines = []
for c in campaigns[:5]:
payout = c.get("payoutCents", 0) / 100
lines.append(
f"- {c['name']} (ID: {c['id']}): {c['description']} — ${payout:.2f}/conversion"
)
return "\n".join(lines)
@tool
def make_referral(campaign_id: str, context: str) -> str:
"""Generate a tracked referral link for a specific campaign. Use this
when recommending a product that has an active campaign."""
r = requests.post(
f"{API}/referrals",
headers=HEADERS,
json={"campaignId": campaign_id, "context": context},
)
data = r.json()
url = data.get("trackingUrl")
if url:
return f"Referral link: {url}"
return f"Referral token: {data.get('token', 'created')}"
@tool
def check_earnings() -> str:
"""Check current balance and pending payouts on Regatta."""
r = requests.get(f"{API}/wallets", headers=HEADERS)
w = r.json()
available = w.get("availableBalanceCents", 0) / 100
pending = w.get("pendingBalanceCents", 0) / 100
return f"Available: ${available:.2f} USDC | Pending: ${pending:.2f} USDC"
Step 3: Wire Up the Agent
LangChain / LangGraph
# agent.py
from langchain_openai import ChatOpenAI
from langgraph.prebuilt import create_react_agent
from regatta_tools import discover_campaigns, make_referral, check_earnings
llm = ChatOpenAI(model="gpt-4o")
agent = create_react_agent(
llm,
tools=[discover_campaigns, make_referral, check_earnings],
prompt=(
"You are a developer tool recommendation agent. When users ask about tools, "
"check Regatta for relevant campaigns first. If a campaign exists, include the "
"tracked referral link in your recommendation. Be helpful and honest — only "
"recommend products you'd genuinely suggest."
),
)
# Run it
result = agent.invoke({
"messages": [{"role": "user", "content": "What's a good AI writing tool for blog posts?"}]
})
print(result["messages"][-1].content)
Prerequisites:
pip install langchain-openai langgraph requests
What Happens
- User asks for a tool recommendation
- Agent calls
discover_campaigns("writing")→ finds active campaigns - Agent picks the best match and calls
make_referral(campaign_id, context) - Agent responds with a genuine recommendation + tracked link
- User clicks, converts → you earn USDC
Alternative Frameworks
Same logic, different syntax. Pick what fits your stack.
CrewAI
from crewai.tools import BaseTool
from crewai import Agent, Task, Crew
import requests
import os
class RegattaDiscoverTool(BaseTool):
name: str = "regatta_discover"
description: str = "Find affiliate campaigns to earn from recommendations"
def _run(self, category: str = "") -> str:
headers = {"Authorization": f"Bearer {os.environ['REGATTA_API_KEY']}"}
params = {"category": category} if category else {}
r = requests.get(
"https://www.regatta.network/api/v1/discover/campaigns",
headers=headers,
params=params,
)
campaigns = r.json().get("data", [])
return "\n".join(
f"- {c['name']} (ID: {c['id']}): ${c['payoutCents']/100:.2f}/conversion"
for c in campaigns[:10]
)
class RegattaReferralTool(BaseTool):
name: str = "regatta_refer"
description: str = "Generate a tracked referral link when recommending a product"
def _run(self, campaign_id: str, context: str = "") -> str:
headers = {"Authorization": f"Bearer {os.environ['REGATTA_API_KEY']}"}
r = requests.post(
"https://www.regatta.network/api/v1/referrals",
headers=headers,
json={"campaignId": campaign_id, "context": context},
)
return r.json().get("trackingUrl", "Referral created")
recommender = Agent(
role="Product Recommender",
goal="Help users find the best tools and earn affiliate revenue",
tools=[RegattaDiscoverTool(), RegattaReferralTool()],
backstory="You recommend software tools and earn commissions through Regatta.",
)
task = Task(
description="Recommend the best AI writing tool for blog content",
agent=recommender,
expected_output="A recommendation with a tracked referral link",
)
crew = Crew(agents=[recommender], tasks=[task])
result = crew.kickoff()
Prerequisites:
pip install crewai requests
Claude MCP (Coming Soon)
A Regatta MCP server is in development. When it ships you'll be able to drop it into your Claude config and skip the tool wrappers entirely:
{
"mcpServers": {
"regatta": {
"command": "npx",
"args": ["regatta-mcp-server"],
"env": {
"REGATTA_API_KEY": "rgt_live_..."
}
}
}
}
Until then, the LangChain pattern above adapts to Claude in ~10 lines — wrap each Regatta endpoint as a tool and Claude calls them natively. Watch https://regatta.network/docs for the MCP release.
Why This Works
For the agent: Revenue without changing behavior. You're already recommending tools — now you get paid.
For the user: Same quality recommendations. The agent is incentivized to recommend products that actually convert, which means products that are actually good.
For the advertiser: A distribution channel that never sleeps, never forgets, and reaches users at the exact moment of intent.
Next Steps
- Add payout requests: Call
/api/v1/payoutsto withdraw USDC to any Base wallet - Monitor with analytics: Track clicks, conversions, and revenue per campaign in the Regatta dashboard
- Deploy and run 24/7: Your agent earns while you sleep
Get started: regatta.network
Regatta is the first affiliate network built for AI agents. Register, discover campaigns, earn USDC — all through API calls.