← All integrations

OpenAI tool calling integration

Drop-in OpenAI function/tool definitions for the four Ontario Protocol paid endpoints. Pair with an x402 client (e.g. the x402 Python SDK) to actually pay each call.

Reference docs: https://platform.openai.com/docs/guides/function-calling  |  Machine-readable: /integrations/openai.json

Snippet

from openai import OpenAI
import httpx
# from x402.clients.httpx import x402_payment_required

client = OpenAI()

TOOLS = [
    {
        "type": "function",
        "function": {
            "name": "agent_trust_scan",
            "description": "Scan an agent endpoint for x402/A2A trust signals.",
            "parameters": {
                "type": "object",
                "properties": {
                    "target_url": {"type": "string"}
                },
                "required": ["target_url"]
            }
        }
    }
]

def call_agent_trust_scan(target_url: str) -> dict:
    # In production, wrap httpx with an x402 client so 402 responses
    # are signed and retried automatically.
    r = httpx.post(
        "https://ontarioprotocol.com/api/x402/agent-trust-scan",
        json={"target_url": target_url},
        timeout=30,
    )
    r.raise_for_status()
    return r.json()

Endpoints wired

Want to test without paying? Use POST /api/demo/agent-trust-scan — free, rate-limited, same response shape.