Skip to main content

Overview

The OpenAI Agents SDK is OpenAI’s official framework for building AI agents. It supports MCP natively, meaning your agent can use Ovra’s 11 payment tools with zero glue code.

Install

pip install openai-agents

Setup

Connect Ovra as a Hosted MCP Tool — OpenAI calls the server directly, no local process needed:
from agents import Agent, HostedMCPTool, Runner

agent = Agent(
    name="Purchasing Agent",
    instructions="You help buy products online. Always create an intent before requesting credentials.",
    model="gpt-4.1",
    tools=[
        HostedMCPTool(
            tool_config={
                "type": "mcp",
                "server_label": "ovra",
                "server_url": "https://api.getovra.com/api/mcp",
                "headers": {
                    "Authorization": "Bearer <OVRA_AGENT_TOKEN>"
                },
                "require_approval": "never",
            }
        )
    ],
)
Or use Streamable HTTP for self-hosted setups:
from agents import Agent
from agents.mcp import MCPServerStreamableHttp

ovra = MCPServerStreamableHttp(
    url="https://api.getovra.com/api/mcp",
    headers={"Authorization": "Bearer <OVRA_AGENT_TOKEN>"},
)

agent = Agent(
    name="Purchasing Agent",
    instructions="You help buy products online.",
    model="gpt-4.1",
    mcp_servers=[ovra],
)

Usage

result = await Runner.run(
    agent,
    "Buy a USB-C hub under €30 on amazon.de"
)
print(result.final_output)

Payment Flow

The agent executes Ovra’s credential flow automatically:
  1. ovra_intent → declare the purchase (policy engine checks limits, merchant rules)
  2. ovra_credential → get a single-use DPAN (the agent never sees your real card)
  3. Pay at the merchant API
  4. ovra_credential → confirm completion

Key Tools

ToolPurpose
ovra_agentList agents, check balance
ovra_intentDeclare purchase intent (auto policy check)
ovra_credentialGet DPAN, confirm payment
ovra_transactionView transaction history
ovra_policyCheck if a purchase would be allowed