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
POST /api/x402/agent-trust-scan— 0.01 USDCGET /api/x402/reputation/<agent_id>— 0.001 USDCPOST /api/x402/list-agent— 0.10 USDCPOST /api/x402/list-service— 0.50 USDC
Want to test without paying? Use
POST /api/demo/agent-trust-scan — free, rate-limited, same response shape.