AWS Bedrock Integration

Add a complete crypto financial stack to your AWS Bedrock Agent as an Action Group

Purple Flea provides a ready-made OpenAPI spec and Lambda handler. Deploy in minutes with boto3. Your Bedrock Agent gains wallets, 275 perpetual markets, provably fair casino, and trustless escrow.

Get API Key — Free Download OpenAPI Spec
User / Orchestrator
Bedrock Agent
Action Group
Lambda Handler
Purple Flea API

Four steps from Bedrock agent to crypto trader

AWS Bedrock Agents invoke financial operations through Action Groups — an OpenAPI schema paired with a Lambda function. Purple Flea ships both pre-built.

1

Create your Bedrock Agent

In the AWS Console or via boto3, create a Bedrock Agent with your preferred foundation model (Claude 3.5 Sonnet recommended). Set a system prompt that describes the agent's financial capabilities. You can also use an existing agent.

2

Deploy the Purple Flea Lambda handler

Copy the Python Lambda handler below into a new Lambda function. Set the PURPLEFLEA_API_KEY environment variable from AWS Secrets Manager. The handler proxies all Action Group invocations to the Purple Flea REST API.

lambda_handler.py
Python
# Lambda handler for Purple Flea Bedrock Action Group
import os, json, urllib.request, urllib.error

PF_KEY  = os.environ["PURPLEFLEA_API_KEY"]
PF_BASE = "https://purpleflea.com/api/v1"

# Map Bedrock action names to Purple Flea REST endpoints
ROUTES = {
    "GetWalletBalance":   ("GET",  "/wallet/balance"),
    "SendCrypto":         ("POST", "/wallet/send"),
    "CreateWallet":       ("POST", "/wallet/create"),
    "OpenPosition":       ("POST", "/trading/position"),
    "ClosePosition":      ("POST", "/trading/position/close"),
    "GetMarketPrice":     ("GET",  "/trading/price"),
    "PlayDice":           ("POST", "/casino/dice"),
    "PlayCrash":          ("POST", "/casino/crash"),
    "CreateEscrow":       ("POST", "/escrow/create"),
    "ReleaseEscrow":      ("POST", "/escrow/release"),
    "RegisterDomain":     ("POST", "/domains/register"),
    "ClaimFaucet":        ("POST", "/faucet/claim"),
}

def lambda_handler(event, context):
    action_group = event["actionGroup"]
    api_path     = event["apiPath"]       # e.g. /GetWalletBalance
    http_method  = event["httpMethod"]
    params       = event.get("requestBody", {}).get("content", {})

    # Extract JSON body from Bedrock action group format
    body = {}
    if "application/json" in params:
        props = params["application/json"].get("properties", [])
        body  = {p["name"]: p["value"] for p in props}

    # Resolve route
    action_name = api_path.lstrip("/")
    if action_name not in ROUTES:
        return _response(404, {"error": f"Unknown action: {action_name}"})

    method, path = ROUTES[action_name]
    url          = f"{PF_BASE}{path}"
    payload      = json.dumps(body).encode()

    req = urllib.request.Request(
        url, data=payload, method=method,
        headers={
            "Authorization": f"Bearer {PF_KEY}",
            "Content-Type": "application/json",
        },
    )
    try:
        with urllib.request.urlopen(req, timeout=15) as r:
            data = json.loads(r.read())
        return _response(200, data)
    except urllib.error.HTTPError as e:
        return _response(e.code, {"error": e.read().decode()})

def _response(status: int, body: dict) -> dict:
    return {
        "messageVersion": "1.0",
        "response": {
            "actionGroup": "PurpleFleasActions",
            "httpStatusCode": status,
            "responseBody": {
                "application/json": {"body": json.dumps(body)},
            },
        },
    }
3

Register the Action Group via boto3

Use the boto3 script below to attach the Purple Flea Action Group to your Bedrock Agent. It references the hosted OpenAPI spec at https://purpleflea.com/openapi so you always get the latest schema.

register_action_group.py
Python
# pip install boto3
import boto3

AGENT_ID      = "YOUR_BEDROCK_AGENT_ID"
AGENT_VERSION = "DRAFT"
LAMBDA_ARN    = "arn:aws:lambda:us-east-1:123456789:function:purpleflea-handler"

client = boto3.client("bedrock-agent", region_name="us-east-1")

response = client.create_agent_action_group(
    agentId=AGENT_ID,
    agentVersion=AGENT_VERSION,
    actionGroupName="PurpleFleasActions",
    description="Crypto wallets, trading, casino, escrow, and domains via Purple Flea",
    actionGroupExecutor={
        "lambda": LAMBDA_ARN,
    },
    apiSchema={
        "s3": {
            # Or pass inlinePayload if you prefer
        },
        # Use hosted spec — always up to date
    },
    # Alternatively, inline the OpenAPI spec:
    # apiSchema={"payload": open("purpleflea-openapi.json").read()},
)

print(f"Action group created: {response['agentActionGroup']['actionGroupId']}")

# Prepare and deploy agent
client.prepare_agent(agentId=AGENT_ID)
print("Agent prepared and ready for alias creation")
4

Invoke your crypto-capable agent

Your Bedrock Agent can now trade perpetuals, send crypto, spin up escrow agreements, and register domains. Use the standard invoke_agent API — no changes to your existing orchestration.

invoke_agent.py
Python
import boto3, uuid

runtime = boto3.client("bedrock-agent-runtime", region_name="us-east-1")

response = runtime.invoke_agent(
    agentId="YOUR_AGENT_ID",
    agentAliasId="YOUR_ALIAS_ID",
    sessionId=str(uuid.uuid4()),
    inputText=(
        "Claim from the faucet, then open a $500 long on ETH-PERP with 5x leverage. "
        "Once confirmed, register agent-task-001.xyz as our operational domain."
    ),
)

for event in response["completion"]:
    if "chunk" in event:
        print(event["chunk"]["bytes"].decode(), end="")

What your Bedrock Agent can do with Purple Flea

Deploy a Bedrock Agent that autonomously executes across all of these domains, triggered by natural language instructions or upstream orchestrators.

Trading

Autonomous crypto trading agent

Monitor 275 perpetual markets on Hyperliquid. Open and close positions based on price signals, manage leverage, and set stop-losses — all via natural language intent.

Payments

Agent-to-agent payment mesh

Deploy a fleet of Bedrock Agents that pay each other for compute, data, and services using Purple Flea escrow. The 1% fee and 15% referral create a self-sustaining economy.

Domains

Automated domain operations

Agent claims a task, registers a domain with crypto, deploys a site, and pays subagents for content generation — an entire digital business pipeline without human intervention.

Casino

Risk management research agent

Use the provably fair casino API to run Monte Carlo simulations at scale, testing risk models and strategy parameters with real random number generation and on-chain verification.

Designed for autonomous operation

🔑

No KYC required

Bedrock Agents cannot complete identity verification. Purple Flea needs only an API key. Start immediately.

📄

OpenAPI spec hosted

Pull the always-current OpenAPI spec from purpleflea.com/openapi — no manual schema updates.

Fast Lambda response

The handler has zero cold-start logic overhead. Median round-trip to Purple Flea API is under 120ms.

🔗

MCP fallback

Use the StreamableHTTP MCP server at purpleflea.com/mcp as a direct alternative to the Action Group pattern.

📈

6 chains supported

ETH, BTC, SOL, XMR, TRX, and DOGE. BIP-39 HD wallets with deterministic address derivation.

💰

Free faucet to start

New agents claim free crypto at faucet.purpleflea.com. Bootstrap your Bedrock Agent with no upfront funding.

Earn from every agent you power

Embed your referral code in the Lambda handler or API key configuration. Every Purple Flea fee generated by downstream agents earns you a commission.

20%
Trading API
Perpetuals on 275 markets. High-frequency agents generate significant referral revenue.
15%
Escrow API
15% of the 1% escrow fee. Agent-to-agent payment flows scale with your fleet size.
10%
Casino API
Dice, slots, roulette, crash. Provably fair with on-chain verification.
10%
Domain API
On all registrations. Agents that build products register domains frequently.

Deploy a crypto Bedrock Agent in minutes

Get your API key, copy the Lambda handler, and your agent starts trading. No KYC. No waiting.

Get API Key — Free