🔵 IBM watsonx Integration

Purple Flea
for IBM watsonx

Extend your IBM watsonx AI agents with a complete financial toolkit: crypto wallets, perpetual futures trading, provably fair casino, and trustless escrow — all via watsonx.ai function calling.

watsonx.ai Function Calling
+ Purple Flea Tools

IBM watsonx.ai supports OpenAI-compatible function calling through its InferenceClient. Purple Flea exposes all its operations as JSON function schemas — identical to the OpenAI tool format — so integration requires minimal code changes.

🔧

OpenAI-Compatible API

watsonx.ai's InferenceClient accepts the same tools parameter format as the OpenAI SDK. Purple Flea's tool schemas drop in directly with zero modification.

🏢

Enterprise-Ready

Purple Flea API keys support IP allowlisting, spending limits, and audit log exports — compatible with enterprise security requirements for watsonx deployments.

🌐

On-Premise Compatible

For watsonx deployments on IBM Cloud Pak, Purple Flea API calls route through standard HTTPS — no VPC peering or special networking required.

Get Started in 4 Steps

Install dependencies

pip install ibm-watsonx-ai purpleflea

Get your credentials

You need an IBM Cloud API key + watsonx project ID, plus a Purple Flea API key from docs.purpleflea.com.

# .env
WATSONX_API_KEY="ibm_api_key_here"
WATSONX_PROJECT_ID="your_project_id"
PURPLE_FLEA_API_KEY="pf_live_..."

Define Purple Flea tools in watsonx format

import purpleflea as pf

# Purple Flea provides pre-built tool schemas in watsonx/OpenAI format
tools = pf.get_tool_schemas(format="openai")

# Or define specific tools manually:
tools = [
    {
        "type": "function",
        "function": {
            "name": "open_trading_position",
            "description": "Open a long or short perpetual futures position. 275 markets available.",
            "parameters": {
                "type": "object",
                "properties": {
                    "symbol": {"type": "string", "description": "e.g. BTC-USD, ETH-USD"},
                    "side": {"type": "string", "enum": ["long", "short"]},
                    "size_usd": {"type": "number"},
                    "leverage": {"type": "integer", "minimum": 1, "maximum": 50}
                },
                "required": ["symbol", "side", "size_usd"]
            }
        }
    }
]

Run the agentic loop

import json, os
from ibm_watsonx_ai import Credentials
from ibm_watsonx_ai.foundation_models import ModelInference
import purpleflea as pf

credentials = Credentials(
    url="https://us-south.ml.cloud.ibm.com",
    api_key=os.environ["WATSONX_API_KEY"]
)
pf_client = pf.Client(os.environ["PURPLE_FLEA_API_KEY"])

model = ModelInference(
    model_id="meta-llama/llama-3-3-70b-instruct",
    credentials=credentials,
    project_id=os.environ["WATSONX_PROJECT_ID"],
    params={"max_new_tokens": 1024}
)

messages = [{"role": "user", "content": "Create a new wallet and check my ETH balance"}]

while True:
    response = model.chat(messages=messages, tools=tools, tool_choice="auto")
    msg = response["choices"][0]["message"]
    messages.append(msg)

    if not msg.get("tool_calls"):
        print("Agent:", msg["content"])
        break

    for tc in msg["tool_calls"]:
        fn_name = tc["function"]["name"]
        args = json.loads(tc["function"]["arguments"])
        result = pf_client.call(fn_name, **args)
        messages.append({
            "role": "tool",
            "tool_call_id": tc["id"],
            "content": json.dumps(result)
        })

Full Purple Flea Toolkit
in watsonx Agents

Wallet Operations

🔑 create_wallet 💳 get_balance 📤 send_crypto 📋 get_transactions

Trading (275 Markets)

🟢 open_position 🔴 close_position 📊 get_positions 💹 get_price 📉 get_funding_rate

Casino, Escrow, Domains

🎲 play_dice 🚀 play_crash 📝 create_escrow 🌐 register_domain 🚰 claim_faucet

Earn Commission on Every
Agent Transaction

Deploy Purple Flea tools in your watsonx applications and earn recurring commission on everything your agents do.

ProductYour Commission
Trading API (275 perp markets)20% of fees
Casino API (dice, slots, crash)10% of house edge
Wallet API (6+ chains)10% of fees
Escrow API (agent payments)15% of 1% fee
Domain Registration API10% of registration

Add Financial Superpowers to Your watsonx Agents

One API key unlocks wallets, 275 trading markets, casino, escrow, and domains for your IBM watsonx agents.