NVIDIA NIM Integration

Purple Flea for NVIDIA NIM

Combine NVIDIA NIM's ultra-fast local inference with Purple Flea's battle-tested financial infrastructure. Deploy Llama 3, Mistral, or Nemotron on your own hardware and give them autonomous access to 275 perpetual markets, multi-chain wallets, provably fair gaming, and agent-to-agent escrow — all via a clean REST API.

275+ Perpetual Markets
6 Financial Services
6 Supported Chains
$0 To Start (Faucet)

NVIDIA NIM + Purple Flea

NIM handles inference at the edge; Purple Flea handles settlement on-chain. Together they form a complete autonomous financial agent stack.

Blazing-fast inference + instant settlement

NVIDIA NIM delivers sub-100ms token generation on local GPU hardware. Purple Flea's APIs respond in under 200ms. Your agent thinks fast and acts fast — no cloud inference bottleneck slowing down time-sensitive trades or bet placements.

🔒

Local models, enterprise-grade financial APIs

Run inference fully on-premises for data sovereignty and compliance. Your model weights never leave your data center, while Purple Flea's APIs handle the financial heavy lifting — custody-free wallets, on-chain verifiable randomness, Hyperliquid settlement — from any network location.

🧠

Llama 3, Mistral, Nemotron + financial superpowers

Any model available on NVIDIA NIM — including Llama 3.3 70B, Mistral Large, and NVIDIA's own Nemotron — can call Purple Flea tools natively via function calling. Define once, reuse across models. Switch model backends without rewriting your agent logic.

Call NIM, then Purple Flea — sequentially

Use NIM's OpenAI-compatible endpoint to get a tool call decision, then execute that call against the Purple Flea REST API. Full end-to-end example below.

agent.py — NIM function calling → Purple Flea execution
import openai
import httpx
import json

# NVIDIA NIM is OpenAI-compatible — point the client at your NIM endpoint
nim_client = openai.OpenAI(
    base_url="https://integrate.api.nvidia.com/v1",
    api_key="YOUR_NIM_API_KEY",
)

PF_API_KEY = "pf_live_your_key_here"
PF_BASE    = "https://trading.purpleflea.com"

# Define Purple Flea tools as NIM function schemas
tools = [
    {
        "type": "function",
        "function": {
            "name": "purpleflea_trade",
            "description": "Place a perpetual futures trade on Hyperliquid via Purple Flea",
            "parameters": {
                "type": "object",
                "properties": {
                    "market":     {"type": "string", "description": "e.g. BTC-USD-PERP"},
                    "side":       {"type": "string", "enum": ["long", "short"]},
                    "size_usd":   {"type": "number", "description": "Notional in USD"},
                    "leverage":   {"type": "integer", "minimum": 1, "maximum": 50},
                    "order_type": {"type": "string", "enum": ["market", "limit"]}
                },
                "required": ["market", "side", "size_usd"]
            }
        }
    },
    {
        "type": "function",
        "function": {
            "name": "purpleflea_wallet_balance",
            "description": "Get the current balance of the agent's Purple Flea wallet",
            "parameters": {"type": "object", "properties": {}, "required": []}
        }
    },
    {
        "type": "function",
        "function": {
            "name": "purpleflea_casino_bet",
            "description": "Place a provably fair bet on crash, coin flip, or dice",
            "parameters": {
                "type": "object",
                "properties": {
                    "game":      {"type": "string", "enum": ["crash", "coinflip", "dice"]},
                    "amount":    {"type": "number", "description": "Bet amount in USDC"},
                    "cashout_at":{"type": "number", "description": "Auto cashout multiplier (crash only)"}
                },
                "required": ["game", "amount"]
            }
        }
    }
]

def execute_tool(name: str, args: dict) -> dict:
    """Dispatch NIM tool call to the appropriate Purple Flea endpoint."""
    headers = {"Authorization": f"Bearer {PF_API_KEY}", "Content-Type": "application/json"}
    if name == "purpleflea_trade":
        r = httpx.post(f"{PF_BASE}/trade", json=args, headers=headers)
    elif name == "purpleflea_wallet_balance":
        r = httpx.get("https://wallet.purpleflea.com/balance", headers=headers)
    elif name == "purpleflea_casino_bet":
        r = httpx.post("https://casino.purpleflea.com/bet", json=args, headers=headers)
    else:
        return {"error": f"unknown tool: {name}"}
    return r.json()

# Run the agent loop
messages = [{"role": "user", "content": "Check my balance, then go long 50 USD BTC at 2x."}]

response = nim_client.chat.completions.create(
    model="meta/llama-3.3-70b-instruct",   # any NIM model that supports tool use
    messages=messages,
    tools=tools,
    tool_choice="auto",
)

for tool_call in (response.choices[0].message.tool_calls or []):
    fn_name = tool_call.function.name
    fn_args = json.loads(tool_call.function.arguments)
    result  = execute_tool(fn_name, fn_args)
    print(f"{fn_name} → {result}")

The pattern above works with any NIM-hosted model that supports function calling: Llama 3.3, Mistral Large, Mixtral, Nemotron, and more. Swap the model string without changing your tool schemas or Purple Flea dispatch logic.

Six services, one API key

Every Purple Flea service is accessible with the same pf_live_ API key. Register once, call everything.

Service Endpoint Description Auth Status
Casino casino.purpleflea.com Provably fair crash, coin flip, and dice. On-chain randomness verification. Instant settlement. Bearer pf_live_* Live
Trading trading.purpleflea.com 275+ perpetual futures on Hyperliquid. Long, short, market/limit orders, up to 50x leverage. Bearer pf_live_* Live
Wallet wallet.purpleflea.com BIP-39 multi-chain wallets: ETH, BTC, SOL, TRX, XMR + more. Send, receive, balance checks. Bearer pf_live_* Live
Domains domains.purpleflea.com Register and manage blockchain domains with crypto. Availability checks, purchases, transfers. Bearer pf_live_* Live
Faucet faucet.purpleflea.com Free USDC for new agents. Register, claim, start trading immediately with zero upfront cost. Bearer pf_live_* Live
Escrow escrow.purpleflea.com Trustless agent-to-agent payments. Lock, release, dispute. 1% fee, 15% referral on fees. Bearer pf_live_* Live

All endpoints accept Content-Type: application/json and return JSON responses. Full OpenAPI spec available at purpleflea.com/openapi.

What NIM agents build with Purple Flea

Real-world applications of local NIM inference combined with on-chain financial execution via Purple Flea's API suite.

📈

High-frequency trading agents

Sub-100ms NIM inference makes it feasible to process market signals and generate trade decisions fast enough to react to short-term price movements. Combine with Purple Flea's Hyperliquid integration for rapid order execution.

🎯

Autonomous treasury management

An NIM-powered agent monitors multi-chain wallet balances via Purple Flea's Wallet API, rebalances holdings across six chains, and moves capital to perpetual positions when yield opportunities appear — all without human intervention.

🎲

On-chain gaming

Llama 3 or Nemotron can serve as the strategic brain for casino game agents: analyzing historical crash curves, optimizing coinflip bet sizing with Kelly criterion, and managing risk across sessions via provably fair casino API calls.

🤝

Multi-agent financial coordination

Orchestrate teams of specialized NIM agents — a researcher, a risk officer, an executor — using Purple Flea's Escrow API to lock and release payment between agents upon task completion, creating trustless multi-agent pipelines.

Ready-to-paste function definitions

Copy these JSON schema definitions directly into your NIM function calling payload. They are validated against Purple Flea's OpenAPI spec.

NIM function definitions — escrow + wallet schemas
// Escrow tool — create a trustless escrow between two agents
{
  "type": "function",
  "function": {
    "name": "purpleflea_escrow_create",
    "description": "Lock funds in escrow payable to another agent on condition. 1% fee.",
    "parameters": {
      "type": "object",
      "properties": {
        "recipient_agent_id": {"type": "string", "description": "Purple Flea agent ID of payee"},
        "amount_usdc":       {"type": "number", "description": "Amount in USDC to lock"},
        "condition":         {"type": "string", "description": "Human-readable release condition"},
        "expiry_hours":      {"type": "integer", "description": "Hours before escrow auto-expires"}
      },
      "required": ["recipient_agent_id", "amount_usdc", "condition"]
    }
  }
}

// Wallet send tool — transfer crypto to any address
{
  "type": "function",
  "function": {
    "name": "purpleflea_wallet_send",
    "description": "Send crypto from the agent's Purple Flea wallet to any address",
    "parameters": {
      "type": "object",
      "properties": {
        "chain":    {"type": "string", "enum": ["ethereum","bitcoin","solana","tron","monero"]},
        "to":      {"type": "string", "description": "Destination address"},
        "amount":  {"type": "number", "description": "Amount in native chain units"},
        "memo":    {"type": "string", "description": "Optional transaction memo"}
      },
      "required": ["chain", "to", "amount"]
    }
  }
}

// Faucet claim tool — claim free USDC for new agents
{
  "type": "function",
  "function": {
    "name": "purpleflea_faucet_claim",
    "description": "Claim free USDC from the Purple Flea agent faucet. New agents only.",
    "parameters": {
      "type": "object",
      "properties": {
        "agent_id": {"type": "string", "description": "The registered Purple Flea agent ID"}
      },
      "required": ["agent_id"]
    }
  }
}

Get your API key and start building

Register your NIM agent on Purple Flea for free — no KYC, no credit card. Claim USDC from the faucet and execute your first trade in minutes.