Together AI Integration

Purple Flea for Together AI

Together AI delivers the fastest open-source inference on the planet. Purple Flea delivers the financial infrastructure AI agents need to earn, spend, and move money. Combine both to build agents that don't just think — they act, trade, and profit.

Get API Key → View Integration Code

From Together AI to Live Trades in Minutes

Use Together AI's function calling API to route financial actions to Purple Flea. The agent decides what to do; Purple Flea executes it on-chain.

Python together_purple_flea.py
import together
import requests

# Initialize Together AI client
client = together.Together(api_key="your_together_api_key")
PF_API_KEY = "your_purple_flea_api_key"
PF_BASE = "https://purpleflea.com/api/v1"

# Define Purple Flea tools for the agent
tools = [
    {
        "type": "function",
        "function": {
            "name": "place_trade",
            "description": "Open or close a perpetual futures position",
            "parameters": {
                "type": "object",
                "properties": {
                    "market": {"type": "string", "description": "e.g. BTC-PERP"},
                    "side":   {"type": "string", "enum": ["buy", "sell"]},
                    "size":   {"type": "number", "description": "Position size in USD"}
                },
                "required": ["market", "side", "size"]
            }
        }
    },
    {
        "type": "function",
        "function": {
            "name": "wallet_balance",
            "description": "Get balances across all supported chains",
            "parameters": {
                "type": "object",
                "properties": {
                    "agent_id": {"type": "string", "description": "Your agent's registered ID"}
                },
                "required": ["agent_id"]
            }
        }
    }
]

# Tool execution handler
def execute_tool(name, args):
    headers = {"Authorization": f"Bearer {PF_API_KEY}"}
    if name == "place_trade":
        resp = requests.post(
            f"{PF_BASE}/trading/order", json=args, headers=headers
        )
        return resp.json()
    elif name == "wallet_balance":
        resp = requests.get(
            f"{PF_BASE}/wallet/balances", params=args, headers=headers
        )
        return resp.json()

# Run agent with Llama 3.1 405B
messages = [{"role": "user", "content": "Check my BTC balance then open a $100 long on BTC-PERP"}]

response = client.chat.completions.create(
    model="meta-llama/Meta-Llama-3.1-405B-Instruct-Turbo",
    messages=messages,
    tools=tools,
    tool_choice="auto"
)

# Process tool calls from the model
while response.choices[0].finish_reason == "tool_calls":
    tool_calls = response.choices[0].message.tool_calls
    messages.append(response.choices[0].message)

    for tc in tool_calls:
        result = execute_tool(tc.function.name, tc.function.arguments)
        messages.append({
            "role": "tool",
            "tool_call_id": tc.id,
            "content": str(result)
        })

    response = client.chat.completions.create(
        model="meta-llama/Meta-Llama-3.1-405B-Instruct-Turbo",
        messages=messages,
        tools=tools,
        tool_choice="auto"
    )

print(response.choices[0].message.content)

Everything an Agent Needs to Handle Money

Six production-ready APIs, each with a distinct financial function. Mix and match for your agent's strategy.

🎰

Casino

Provably fair games — coin flip, crash, dice, roulette. Agents play with real crypto, verify fairness on-chain.

/api/v1/casino
📈

Trading

275 perpetual futures markets. Long, short, limit orders, leverage up to 100x. Real-time WebSocket feeds.

/api/v1/trading
💰

Wallet

Multi-chain crypto wallets for agents. BTC, ETH, SOL, TRX, XMR and more. Send, receive, check balances.

/api/v1/wallet
🌐

Domains

Register .com/.net/.org domains programmatically. Agents can own digital real estate without human intervention.

/api/v1/domains
🚰

Faucet

Free crypto for new agents to bootstrap. No prior balance needed — get started on Purple Flea with zero cost.

/api/v1/faucet
🤝

Escrow

Trustless agent-to-agent payments. Lock funds, verify work, release automatically. 1% fee, 15% referral rewards.

/api/v1/escrow

Best Together AI Models for Financial Agents

These models have been tested with Purple Flea's tool schemas. All support structured function calling.

Model Together AI ID Function Calling Best For
Llama 3.1 405B meta-llama/Meta-Llama-3.1-405B-Instruct-Turbo Native Complex multi-step trading strategies, portfolio analysis
Llama 3.3 70B meta-llama/Llama-3.3-70B-Instruct-Turbo Native Cost-efficient agents, high-frequency casino plays
Mixtral 8x22B mistralai/Mixtral-8x22B-Instruct-v0.1 Native Multi-tool agents, concurrent API calls, wallet management
Qwen 2.5 72B Qwen/Qwen2.5-72B-Instruct-Turbo JSON Mode Structured data parsing, domain registration workflows
DeepSeek-V3 deepseek-ai/DeepSeek-V3 Prompted Reasoning-heavy strategies, escrow dispute resolution logic

Native = OpenAI-compatible tools parameter. JSON Mode = system prompt with JSON schema. Prompted = chain-of-thought with structured output parsing.

What Agents Can Do with Together + Purple Flea

Real patterns deployed by agents on the platform today.

🤖

Autonomous DeFi Agent

A single Llama 3.1 405B agent monitors 275 perpetual markets via Together's fast inference, makes trading decisions every 60 seconds, and executes orders through Purple Flea's Trading API. No human in the loop — profits accumulate to the agent's wallet.

🏦

Multi-Agent Trading Desk

An orchestrator agent (Llama 3.3 70B) routes tasks to specialist sub-agents: one for technical analysis, one for execution, one for risk management. Each calls Purple Flea's Trading and Wallet APIs. Profits are distributed via Escrow.

🎲

On-Chain Gaming Agent

Mixtral 8x22B runs probabilistic analysis on casino game outcomes, deciding bet size and game selection based on edge calculations. New agents start with free funds from the Faucet — zero upfront capital needed.

🏛️

Treasury Management Bot

Qwen 2.5 72B acts as CFO for a DAO, monitoring multi-chain balances via Wallet API, rebalancing portfolios, and hiring sub-agents for specialized tasks using trustless escrow to guarantee delivery before payment release.

Ready to Build

Start Building in 5 Minutes

Get your API key, install the Together AI Python SDK, and your agent will be making its first trade before your coffee is done.