> ## Documentation Index
> Fetch the complete documentation index at: https://docs.getovra.com/llms.txt
> Use this file to discover all available pages before exploring further.

# OpenAI Agents SDK

> Connect Ovra MCP to the OpenAI Agents SDK for autonomous payments.

The [OpenAI Agents SDK](https://openai.github.io/openai-agents-python/) speaks MCP natively. Plug in Ovra and your agents pick up all 19 tools — `ovra_pay`, `ovra_card`, `ovra_intent`, the rest — without writing tool wrappers.

<Note>
  Sandbox-only today. Use a `sk_sandbox_*` or `sk_test_*` key.
</Note>

## Install

```bash theme={}
pip install openai-agents
```

## Hosted MCP (recommended)

OpenAI calls Ovra directly — no local subprocess.

```python theme={}
from agents import Agent, HostedMCPTool, Runner

agent = Agent(
    name="Procurement Agent",
    instructions=(
        "You buy office supplies under EUR 100. "
        "Always declare an intent before requesting credentials. "
        "Never ask the user for card numbers — Ovra handles that."
    ),
    model="gpt-4.1",
    tools=[
        HostedMCPTool(
            tool_config={
                "type": "mcp",
                "server_label": "ovra",
                "server_url": "https://api.getovra.com/api/mcp",
                "headers": {"Authorization": "Bearer sk_sandbox_..."},
                "require_approval": "never",
            }
        )
    ],
)
```

## Streamable HTTP (self-hosted)

```python theme={}
from agents import Agent
from agents.mcp import MCPServerStreamableHttp

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

agent = Agent(
    name="Procurement Agent",
    instructions="You buy office supplies under EUR 100.",
    model="gpt-4.1",
    mcp_servers=[ovra],
)
```

## Run

```python theme={}
result = await Runner.run(
    agent,
    "Buy a USB-C hub under EUR 30 on amazon.de"
)
print(result.final_output)
```

## Payment flow the agent executes

<Steps>
  <Step title="Declare intent">
    `ovra_intent { action: "declare", agentId, purpose, expectedAmountEuros, expectedMerchant }`
  </Step>

  <Step title="Mint credential">
    `ovra_pay { action: "checkout", ... }` (or `handle_402` for MPP merchants)
  </Step>

  <Step title="Pay at merchant">
    Either MPP (server-to-server) or CUA (browser autofill).
  </Step>

  <Step title="Verify + close">
    `ovra_intent { action: "verify", ... }` to record actual amount.
  </Step>
</Steps>

## Recommended tools to expose

| Tool               | Purpose                                  |
| ------------------ | ---------------------------------------- |
| `ovra_pay`         | Full flow in one call                    |
| `ovra_intent`      | Declare and verify                       |
| `ovra_credential`  | Fine-grained credential lifecycle        |
| `ovra_transaction` | Read history                             |
| `ovra_policy`      | Inspect spending limits before declaring |

## Human approval

For policies with `enforcementLevel: "approve"`, intents land in `pending_approval`. The OpenAI Agents SDK supports human-in-the-loop checkpoints; pause until your approval surface flips the intent to `approved`.

## Next

<CardGroup cols={2}>
  <Card title="MCP overview" icon="info" href="/mcp/overview">
    Architecture and the full 19-tool list.
  </Card>

  <Card title="LangGraph" icon="diagram-project" href="/integrations/langgraph">
    Stateful agent graphs.
  </Card>

  <Card title="CrewAI" icon="users" href="/integrations/crewai">
    Multi-agent teams with role separation.
  </Card>
</CardGroup>
