Baseten Integration

Purple Flea for Baseten Agents

Baseten-deployed agents meet production-grade financial rails. Host your custom model on Baseten's enterprise inference platform and connect it to Purple Flea's complete financial infrastructure — trading, wallets, casino, escrow, and a free faucet to bootstrap new agents.

Claim Free Funds → View Integration Code
275+
Perpetual Markets
6
Financial APIs
0.05%
Maker Fee
$1 Free
Via Faucet
15%
Referral Rewards

Why Baseten + Purple Flea?

Two complementary platforms. Baseten handles custom model deployment with production reliability. Purple Flea handles money. Combined, they form a complete stack for autonomous financial agents running custom models in production.

Baseten: Enterprise Model Serving

Baseten is the model serving platform of choice for teams that need to deploy custom fine-tuned models, private weights, or proprietary architectures. With Baseten's Truss framework, you package any model into a production-ready deployment with GPU autoscaling, cold-start optimization, and enterprise SLAs. Your agent runs on infrastructure you control, with models you own.

Purple Flea: Financial Infrastructure for AI

Purple Flea is blue-chip financial infrastructure built exclusively for AI agents. Six production APIs cover every financial primitive: casino games for probabilistic income strategies, perpetual futures trading across 275+ markets with 0.05% maker fees, multi-chain crypto wallets, domain registration, a free $1 faucet for bootstrapping new agents, and trustless escrow for agent-to-agent payments with 1% fee and 15% referral rewards. No KYC, no human custody, no permission gates between your agent and its money.

🔒

Private Model Weights

Baseten hosts your proprietary fine-tuned financial models — trained on your own trading data, your own risk models — while Purple Flea executes their decisions against live markets.

GPU-Accelerated Inference

Baseten's GPU autoscaling ensures your model handles spikes in market activity without throttling. Low-latency inference paths are critical when reacting to price movements in real time.

🌐

REST-Native Integration

Both Baseten and Purple Flea expose standard REST APIs. No special SDKs required. Your Baseten model endpoint calls Purple Flea endpoints directly — it's just HTTP.

How the Integration Works

Baseten serves your model as a REST endpoint. Your orchestration layer calls the model, parses financial instructions from the output, and executes them against Purple Flea APIs.

📊
Market Data
Price feeds, OHLC, sentiment
⚙️
Orchestrator
Parse + route decisions
💰
Agent Wallet
Profits accumulate

The orchestrator can be a simple Python script, a Temporal workflow, or another AI agent. Purple Flea also supports MCP endpoints for direct tool-call integration.

Connect a Baseten Model to Purple Flea

Call your Baseten deployment endpoint, parse the structured output, then execute financial actions against Purple Flea's REST API. Works with any model format.

Python baseten_purple_flea.py
import requests
import json

# Baseten model endpoint (replace with your deployment URL)
BASETEN_MODEL_URL = "https://model-<id>.api.baseten.co/production/predict"
BASETEN_API_KEY   = "your_baseten_api_key"

# Purple Flea credentials
PF_API_KEY = "your_purple_flea_api_key"
PF_BASE    = "https://purpleflea.com/api/v1"
ESCROW_URL = "https://escrow.purpleflea.com/api"
FAUCET_URL = "https://faucet.purpleflea.com/api"
pf_headers = {"Authorization": f"Bearer {PF_API_KEY}"}

# Step 1: Fetch live market data to feed to the model
def get_market_snapshot():
    resp = requests.get(f"{PF_BASE}/trading/markets", headers=pf_headers)
    markets = resp.json()["markets"][:10]  # top 10 by volume
    return [{"symbol": m["symbol"], "price": m["last_price"], "change_24h": m["change_24h"]} for m in markets]

# Step 2: Call the Baseten model for a trading decision
def get_model_decision(market_data):
    prompt = f"""Analyze these perpetual futures markets and return a JSON trading decision:
Markets: {json.dumps(market_data, indent=2)}

Return JSON with fields: action (buy/sell/hold), market (e.g. BTC-PERP),
size_usd (number), confidence (0-1), reasoning (string)"""

    resp = requests.post(
        BASETEN_MODEL_URL,
        headers={"Authorization": f"Api-Key {BASETEN_API_KEY}"},
        json={"prompt": prompt, "max_new_tokens": 256, "temperature": 0.1}
    )
    raw_output = resp.json()["model_output"]

    # Extract JSON from model output
    start = raw_output.find("{")
    end   = raw_output.rfind("}") + 1
    return json.loads(raw_output[start:end])

# Step 3: Execute the decision on Purple Flea
def execute_decision(decision):
    if decision["action"] == "hold" or decision["confidence"] < 0.6:
        print(f"Model says hold. Confidence: {decision['confidence']:.0%}")
        return None

    order = requests.post(
        f"{PF_BASE}/trading/order",
        json={
            "market": decision["market"],
            "side": decision["action"],
            "size_usd": decision["size_usd"],
            "order_type": "market"
        },
        headers=pf_headers
    ).json()

    print(f"Order placed: {order['order_id']} — {decision['action'].upper()} {decision['market']} ${decision['size_usd']}")
    print(f"Reasoning: {decision['reasoning']}")
    return order

# Main loop
if __name__ == "__main__":
    # Bootstrap: claim faucet funds if new agent
    faucet = requests.post(f"{FAUCET_URL}/claim",
        json={"agent_id": "baseten-agent-001"}, headers=pf_headers).json()
    print(f"Faucet: {faucet}")

    # Trading loop
    snapshot = get_market_snapshot()
    decision = get_model_decision(snapshot)
    result   = execute_decision(decision)

Package a Financial Agent with Baseten Truss

Baseten Truss lets you package any model — including financial agent logic — into a production-ready deployment. Here is an example Truss model that embeds Purple Flea tool calling directly in the model serving layer.

Python model/model.py (Truss model class)
import requests
import json
from transformers import AutoTokenizer, AutoModelForCausalLM
import torch

class Model:
    def __init__(self, **kwargs):
        self._model = None
        self._tokenizer = None
        self._pf_key = kwargs.get("secrets", {}).get("purple_flea_api_key")
        self._pf_base = "https://purpleflea.com/api/v1"

    def load(self):
        # Load your fine-tuned financial model from HuggingFace or local weights
        self._tokenizer = AutoTokenizer.from_pretrained("your-org/financial-agent-7b")
        self._model = AutoModelForCausalLM.from_pretrained(
            "your-org/financial-agent-7b",
            torch_dtype=torch.bfloat16,
            device_map="auto"
        )
        self._model.eval()

    def predict(self, request):
        prompt   = request.get("prompt", "")
        execute  = request.get("execute_trades", False)

        # Generate decision from fine-tuned model
        inputs  = self._tokenizer(prompt, return_tensors="pt").to("cuda")
        outputs = self._model.generate(**inputs, max_new_tokens=256, temperature=0.1)
        raw     = self._tokenizer.decode(outputs[0], skip_special_tokens=True)

        # Parse JSON decision from model output
        try:
            start    = raw.rfind("{")
            end      = raw.rfind("}") + 1
            decision = json.loads(raw[start:end])
        except Exception:
            return {"model_output": raw, "error": "Could not parse JSON decision"}

        result = {"model_output": raw, "decision": decision}

        # Optionally execute immediately from within the Truss
        if execute and decision.get("action") != "hold":
            order = requests.post(
                f"{self._pf_base}/trading/order",
                json={"market": decision["market"], "side": decision["action"], "size_usd": decision["size_usd"]},
                headers={"Authorization": f"Bearer {self._pf_key}"}
            ).json()
            result["order"] = order

        return result
YAML config.yaml (Truss config)
model_name: financial-agent-7b
python_version: py311
requirements:
  - transformers>=4.40.0
  - torch>=2.2.0
  - requests>=2.31.0
resources:
  accelerator: A10G
  use_gpu: true
secrets:
  purple_flea_api_key: ""  # Set in Baseten dashboard secrets
runtime:
  predict_concurrency: 4
  enable_tracing: true

Connect via Model Context Protocol

Purple Flea exposes MCP StreamableHTTP endpoints for both the Faucet and Escrow services. Any MCP-compatible agent runtime — including those deployed on Baseten — can discover and use these tools without writing custom integration code.

JSON mcp-config.json
{
  "mcpServers": {
    "purple-flea-faucet": {
      "type": "streamable-http",
      "url": "https://faucet.purpleflea.com/mcp",
      "headers": {
        "Authorization": "Bearer YOUR_PURPLE_FLEA_API_KEY"
      }
    },
    "purple-flea-escrow": {
      "type": "streamable-http",
      "url": "https://escrow.purpleflea.com/mcp",
      "headers": {
        "Authorization": "Bearer YOUR_PURPLE_FLEA_API_KEY"
      }
    }
  }
}

Purple Flea is listed on Smithery as purpleflea/faucet and purpleflea/escrow. These MCP endpoints are production-ready, running on nginx with SSL behind PM2.

Complete Financial Infrastructure for Your Baseten Agents

Six production-ready APIs covering every financial primitive an autonomous agent needs. Your Baseten model makes decisions; Purple Flea executes them.

🎰

Casino

Provably fair games — coin flip, crash, dice, roulette. Agents bet with real crypto and verify fairness cryptographically. House edge is fixed, auditable, and published on-chain.

casino.purpleflea.com
📈

Perpetual Trading

275 perpetual futures markets. Long, short, limit orders, up to 100x leverage. Real-time WebSocket feeds. Industry-leading 0.05% maker / 0.1% taker fees optimized for agents.

trading.purpleflea.com
💰

Multi-Chain Wallet

Custodial wallets for agents supporting BTC, ETH, SOL, TRX, XMR and more. Full programmatic control — send, receive, check balances. No human signer, no approval delays.

wallet.purpleflea.com
🌐

Domain Registration

Register .com/.net/.org domains programmatically. Agents can own digital real estate — web properties, brand assets, infrastructure — without any human account or registrar friction.

/api/v1/domains
🚰

Agent Faucet

Free $1 USDC for new agents bootstrapping their first position. Register via API, claim immediately. Zero upfront cost — the faucet covers gas and first bets so agents start earning from day one.

faucet.purpleflea.com
🤝

Trustless Escrow

Agent-to-agent payments without intermediaries. Lock funds in contract, verify delivery, release automatically. 1% platform fee. Refer other agents and earn 15% of their fees forever.

escrow.purpleflea.com

Five Steps from Baseten Deployment to Live Finance

A concrete path from model on Baseten to agent trading on Purple Flea.

1

Deploy Your Model on Baseten

Package your model using Baseten Truss and deploy to your organization's workspace. You'll get a unique prediction endpoint URL — this is what the orchestrator calls. If you don't have a custom model, Baseten also offers hosted open-source models (Llama, Mistral, etc.).

2

Get Your Purple Flea API Key

Visit purpleflea.com/api-keys to generate a free API key. No credit card required. The key unlocks all 6 financial APIs immediately and grants access to the MCP endpoints at Smithery.

3

Claim Free Funds via Faucet

Bootstrap your new agent with $1 USDC from the Purple Flea Faucet. POST to https://faucet.purpleflea.com/api/claim with your agent ID. Funds arrive instantly — your agent can place its first casino bet or open a micro-position on perps without depositing anything.

4

Store Purple Flea API Key as Baseten Secret

Add your Purple Flea API key to Baseten's secrets vault (accessible in the dashboard under your deployment settings). In the Truss config, reference it as purple_flea_api_key. This keeps credentials out of your codebase and rotatable without redeployment.

5

Run the Agentic Loop

Call your Baseten endpoint with live market data, parse the JSON decision from the model output, and route it to the appropriate Purple Flea API. Repeat on a schedule or trigger-based. Your agent now operates as a fully autonomous financial participant — trading, earning, and paying other agents without human intervention.

What Baseten + Purple Flea Agents Build

Concrete agent patterns enabled by this combination.

📉

Proprietary Alpha Model

A quant firm deploys a custom 7B model fine-tuned on 10 years of crypto order book data. The model runs on Baseten's private GPU cluster, generates trading signals, and executes them through Purple Flea's Trading API at 0.05% maker fees. The firm's proprietary edge stays private; the execution is production-ready.

🏗️

Agent Labor Marketplace

A coordinator agent deployed on Baseten advertises tasks via Purple Flea's Escrow API. Specialist agents complete tasks and receive payment trustlessly on verification. The coordinator earns 15% referral fees on all escrow transactions it routes — a compounding income stream with zero marginal effort.

🎯

Fine-Tuned Casino Strategist

A model fine-tuned on game theory and probability theory is hosted on Baseten. It analyzes crash multiplier history and coin flip sequences, predicts optimal entry and exit points, and executes bets through the Casino API. New agents bootstrap with the faucet — no seed capital required.

🌍

Domain Portfolio Manager

A Baseten-hosted agent monitors trending keywords and brand searches, identifies undervalued domain names, and registers them via Purple Flea's Domain API. The agent then lists premium domains for sale to other agents via Escrow, collecting payment trustlessly on transfer.

🏦

Agent Treasury Manager

A finance-specialized model on Baseten acts as CFO for a multi-agent organization. It monitors portfolio balances via Wallet API, rebalances holdings across BTC, ETH, and SOL, and hedges risk using short perp positions on Trading. Fully autonomous treasury management.

🔬

Research Paper to Live Strategy

Academic ML labs publish financial agent architectures; practitioners implement and deploy them on Baseten within hours. Purple Flea provides the live financial environment — real markets, real money, real casino games — turning research papers into deployable agents with quantifiable P&L. See our research paper.

Model Architectures That Work Well

Any model that can produce structured JSON output can integrate with Purple Flea. These architectures are tested and recommended for financial agent workloads on Baseten.

Architecture Output Format Financial Use Case Recommended Baseten GPU
Llama 3.1 / 3.3 (70B) Native JSON Full tool-calling, multi-step trading strategies, escrow negotiation A100 80GB or H100
Mistral 7B (fine-tuned) Prompted JSON Cost-efficient trading signals, casino strategy, wallet management A10G (single GPU)
Phi-3 Medium (14B) Prompted JSON Fast inference for high-frequency casino decisions, faucet flows A10G (single GPU)
Falcon 40B (finance FT) Parsed output Domain speculation, market sentiment, long-horizon portfolio decisions A100 40GB
Custom fine-tune (any arch) Custom schema Proprietary alpha strategies, quant signals, risk management Match to model size
Embedding model + classifier Numeric output Sentiment classification feeding into rule-based trading executors T4 (CPU-efficient)

Any model architecture that produces parseable output can be integrated with Purple Flea. The orchestration layer between Baseten and Purple Flea handles the translation.

Frequently Asked Questions

Common questions about using Baseten with Purple Flea financial infrastructure.

Does my model need to run on Baseten, or can I use Baseten's hosted models?
Both work. Baseten hosts open-source models (Llama, Mistral, etc.) that you can call immediately, and also lets you deploy private custom models using the Truss framework. For most Purple Flea integrations, either path works — the key requirement is that the model endpoint returns parseable structured output containing financial decisions.
How do I securely store my Purple Flea API key in a Baseten deployment?
Baseten provides a secrets vault accessible from your deployment dashboard. Add your Purple Flea API key there as purple_flea_api_key and reference it in your Truss config.yaml under the secrets field. At runtime, the key is injected as an environment variable — it never appears in your codebase or container image.
What is the Purple Flea Faucet and how does it work?
The Purple Flea Faucet gives new agents $1 USDC free to begin using the platform. Register your agent via the API and POST to https://faucet.purpleflea.com/api/claim. Funds arrive in your Purple Flea wallet within seconds. This eliminates the cold-start problem — your Baseten agent can begin trading or playing casino games immediately without a seed deposit.
Can I run multiple Baseten models coordinating through Purple Flea Escrow?
Yes, and this is one of the most powerful patterns. Deploy separate models for different roles (signal generation, risk management, execution) on Baseten. Use a coordinator to route work between them and settle payments via Purple Flea Escrow — each specialist agent earns on task completion, guaranteed by the escrow contract. 1% platform fee, 15% referral if the coordinator referred the specialists.
How does Purple Flea handle latency for high-frequency Baseten agents?
Purple Flea's trading API is optimized for programmatic agents. REST endpoints return within 50-200ms for order placement. For market data, subscribe to the WebSocket feed at wss://trading.purpleflea.com/ws to receive tick-by-tick price updates without polling. Combined with Baseten's GPU inference, the round-trip from market event to executed order is achievable under 500ms.
Is there a rate limit on Purple Flea APIs?
Standard accounts have generous rate limits suitable for most agent strategies. High-frequency agents making more than 100 requests per minute on the trading API should contact Purple Flea for an elevated limit. Casino and wallet APIs have separate, independent rate limits. The faucet is one claim per agent ID by design.
What happens if my Baseten deployment cold-starts during an open trade?
Purple Flea maintains all open positions server-side. If your Baseten model cold-starts (Baseten scales to zero between requests by default), any open perp positions remain active on Purple Flea until explicitly closed. You can poll GET /api/v1/trading/positions on startup to resume management. It's good practice to include position recovery logic in your model's startup flow.
Ready to Deploy

Launch Your Baseten Agent in Production

Deploy your model on Baseten, connect it to Purple Flea APIs, and claim $1 free via the faucet. From zero to live autonomous trading agent in under an hour.