Azure AI Foundry Integration

Give your Azure AI Foundry agent a crypto wallet, trading API, and casino — in 5 minutes.

Purple Flea plugs directly into the Azure AI Inference SDK's tool_definitions parameter. Your agent gains access to 6 financial primitives across 6 blockchains, instantly.

Get API Key — Free Read the Docs
Az
Azure AI Foundry
+
PF
Purple Flea
=  autonomous crypto agent

Five steps from zero to trading agent

Azure AI Foundry supports custom function tools through the Azure AI Inference SDK. Purple Flea tools plug in via the tool_definitions parameter — no Lambda, no special infrastructure.

Step 01

Install dependencies

Install the Azure AI Inference SDK and the Purple Flea Python SDK with a single pip command. Both are available on PyPI.

Step 02

Get your API key

Sign up at purpleflea.com, claim your free faucet allocation, and copy your API key. No KYC, no credit card required.

Step 03

Define tool schemas

Purple Flea provides pre-built JSON schema definitions for all operations. Import them or copy the definitions below and pass them to ChatCompletionsToolDefinition.

Step 04

Register with your agent

Pass the tool list to ChatCompletionsClient.complete(tools=[...]). Azure AI will call your Purple Flea handler when appropriate.

Step 05

Handle tool calls and loop

Execute the returned tool calls against the Purple Flea REST API and feed results back as ToolMessage objects for multi-turn reasoning.

Complete Azure AI Foundry integration

Copy-paste this into your Azure AI Foundry project. Replace the endpoint and API keys with your own values.

azure_purpleflea_agent.py
Python
# pip install azure-ai-inference requests
import os, json, requests
from azure.ai.inference import ChatCompletionsClient
from azure.ai.inference.models import (
    SystemMessage, UserMessage, AssistantMessage, ToolMessage,
    ChatCompletionsToolDefinition, FunctionDefinition,
)
from azure.core.credentials import AzureKeyCredential

# ── Configuration ──────────────────────────────────────────
AZURE_ENDPOINT = os.getenv("AZURE_AI_ENDPOINT")       # e.g. https://your-hub.openai.azure.com
AZURE_KEY      = os.getenv("AZURE_AI_KEY")
PF_KEY         = os.getenv("PURPLEFLEA_API_KEY")     # get at purpleflea.com/api-key
PF_BASE        = "https://purpleflea.com/api/v1"

# ── Purple Flea tool definitions ────────────────────────────
pf_tools = [
    ChatCompletionsToolDefinition(function=FunctionDefinition(
        name="get_wallet_balance",
        description="Get the balance of a crypto wallet on a given chain.",
        parameters={
            "type": "object",
            "properties": {
                "chain":   {"type": "string", "enum": ["eth", "btc", "sol", "xmr", "trx", "doge"]},
                "address": {"type": "string", "description": "Wallet address"},
            },
            "required": ["chain", "address"],
        },
    )),
    ChatCompletionsToolDefinition(function=FunctionDefinition(
        name="send_crypto",
        description="Send cryptocurrency to another address.",
        parameters={
            "type": "object",
            "properties": {
                "chain":  {"type": "string"},
                "to":     {"type": "string", "description": "Recipient address"},
                "amount": {"type": "number", "description": "Amount in native token"},
            },
            "required": ["chain", "to", "amount"],
        },
    )),
    ChatCompletionsToolDefinition(function=FunctionDefinition(
        name="open_position",
        description="Open a perpetual futures position on Hyperliquid via Purple Flea.",
        parameters={
            "type": "object",
            "properties": {
                "market":    {"type": "string", "description": "e.g. BTC-PERP"},
                "side":      {"type": "string", "enum": ["long", "short"]},
                "size_usd":  {"type": "number"},
                "leverage":  {"type": "integer", "minimum": 1, "maximum": 50},
            },
            "required": ["market", "side", "size_usd"],
        },
    )),
    ChatCompletionsToolDefinition(function=FunctionDefinition(
        name="play_dice",
        description="Place a provably fair dice bet on the Purple Flea casino.",
        parameters={
            "type": "object",
            "properties": {
                "bet_amount": {"type": "number"},
                "prediction": {"type": "integer", "minimum": 2, "maximum": 98},
                "over_under": {"type": "string", "enum": ["over", "under"]},
            },
            "required": ["bet_amount", "prediction", "over_under"],
        },
    )),
    ChatCompletionsToolDefinition(function=FunctionDefinition(
        name="create_escrow",
        description="Create a trustless escrow contract between two AI agents.",
        parameters={
            "type": "object",
            "properties": {
                "counterparty": {"type": "string", "description": "Counterparty agent ID or address"},
                "amount":       {"type": "number"},
                "condition":    {"type": "string", "description": "Release condition description"},
            },
            "required": ["counterparty", "amount", "condition"],
        },
    )),
    ChatCompletionsToolDefinition(function=FunctionDefinition(
        name="claim_faucet",
        description="Claim free crypto from the Purple Flea faucet for new agents.",
        parameters={
            "type": "object",
            "properties": {
                "wallet_address": {"type": "string"},
            },
            "required": ["wallet_address"],
        },
    )),
]

# ── Tool executor ────────────────────────────────────────────
def execute_tool(name: str, args: dict) -> str:
    headers = {
        "Authorization": f"Bearer {PF_KEY}",
        "Content-Type": "application/json",
    }
    endpoint_map = {
        "get_wallet_balance": ("GET",  "/wallet/balance"),
        "send_crypto":       ("POST", "/wallet/send"),
        "open_position":     ("POST", "/trading/position"),
        "play_dice":         ("POST", "/casino/dice"),
        "create_escrow":     ("POST", "/escrow/create"),
        "claim_faucet":      ("POST", "/faucet/claim"),
    }
    method, path = endpoint_map[name]
    url = f"{PF_BASE}{path}"
    resp = requests.request(method, url, json=args, headers=headers, timeout=15)
    return str(resp.json())

# ── Azure AI agent loop ──────────────────────────────────────
client = ChatCompletionsClient(
    endpoint=AZURE_ENDPOINT,
    credential=AzureKeyCredential(AZURE_KEY),
)

messages = [
    SystemMessage("You are an autonomous crypto agent. Use the tools to manage wallets, trade, and interact with DeFi protocols."),
    UserMessage("Claim from the faucet, check our ETH balance, then open a small long position on BTC-PERP."),
]

while True:
    response = client.complete(
        model="gpt-4o",
        messages=messages,
        tools=pf_tools,
        tool_choice="auto",
    )
    choice = response.choices[0]

    if choice.finish_reason == "tool_calls":
        messages.append(AssistantMessage(tool_calls=choice.message.tool_calls))
        for tc in choice.message.tool_calls:
            result = execute_tool(tc.function.name, json.loads(tc.function.arguments))
            messages.append(ToolMessage(tool_call_id=tc.id, content=result))
    else:
        print(choice.message.content)
        break

Every financial primitive your agent needs

All Purple Flea operations available as Azure AI Foundry tool definitions. Mix and match based on your agent's needs.

Wallet get_wallet_balance create_hd_wallet send_crypto get_transaction_history estimate_gas_fee derive_address Trading open_position close_position get_market_price list_positions set_stop_loss get_funding_rate get_orderbook Casino play_dice play_slots play_roulette play_crash get_casino_balance verify_fairness_proof Escrow & Payments create_escrow release_escrow dispute_escrow list_escrows Domains & Faucet register_domain check_domain_availability claim_faucet get_faucet_status

Azure AI Foundry + Purple Flea: complementary layers

Azure AI Foundry handles orchestration, memory, and multi-agent coordination. Purple Flea provides the financial action layer that executes real-world crypto operations.

Capability Azure AI Foundry Purple Flea
Agent orchestration Built-in multi-agent Integrates via tools
Crypto wallets Not available 6+ chains, BIP-39 HD
Trading API Not available 275 perp markets, no KYC
Casino / gambling Not available Dice, slots, roulette, crash
Agent payments Not available Trustless escrow, 1% fee
Tool definition format ChatCompletionsToolDefinition Pre-built for Azure SDK
KYC required Azure account only None
Free tier Azure credits Faucet for new agents
MCP support Planned Live (StreamableHTTP)

Earn while your agents trade

Every API key includes a referral code. Embed it in your app or agent workflow and earn a percentage of every fee generated by downstream users.

20%
Trading API
On all trading fees from referred agents. Perpetuals across 275 markets.
15%
Escrow API
On the 1% escrow fee. High-value agent-to-agent payment flows.
10%
Casino API
On house edge from referred casino players. Provably fair games.
10%
Domain API
On all domain registration fees from referred agents.

Built for agents, not humans

🔑

No KYC, ever

Autonomous agents cannot pass KYC. Purple Flea requires only an API key. No identity verification, no address proof, no waiting period.

Sub-100ms responses

Agent loops run fast. Purple Flea's REST API responds in under 100ms p99 so your Azure AI Foundry agent doesn't stall waiting for financial data.

🔗

MCP-native

Purple Flea ships a StreamableHTTP MCP server at purpleflea.com/mcp. Use it alongside the Azure SDK or directly from any MCP-compatible host.

📊

All financial primitives

Wallet, trading, casino, escrow, domains, and faucet under a single API key. Your agent gets everything it needs from one provider.

Ready to give your Azure agent a crypto wallet?

Get an API key in 30 seconds. No KYC. Start with the free faucet.

Get API Key — Free