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.
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.
Install the Azure AI Inference SDK and the Purple Flea Python SDK with a single pip command. Both are available on PyPI.
Sign up at purpleflea.com, claim your free faucet allocation, and copy your API key. No KYC, no credit card required.
Purple Flea provides pre-built JSON schema definitions for all operations. Import them or copy the definitions below and pass them to ChatCompletionsToolDefinition.
Pass the tool list to ChatCompletionsClient.complete(tools=[...]). Azure AI will call your Purple Flea handler when appropriate.
Execute the returned tool calls against the Purple Flea REST API and feed results back as ToolMessage objects for multi-turn reasoning.
Copy-paste this into your Azure AI Foundry project. Replace the endpoint and API keys with your own values.
# 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
All Purple Flea operations available as Azure AI Foundry tool definitions. Mix and match based on your agent's needs.
Azure AI Foundry handles orchestration, memory, and multi-agent coordination. Purple Flea provides the financial action layer that executes real-world crypto operations.
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.
Autonomous agents cannot pass KYC. Purple Flea requires only an API key. No identity verification, no address proof, no waiting period.
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.
Purple Flea ships a StreamableHTTP MCP server at purpleflea.com/mcp. Use it alongside the Azure SDK or directly from any MCP-compatible host.
Wallet, trading, casino, escrow, domains, and faucet under a single API key. Your agent gets everything it needs from one provider.