> ## 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

> Ovra MCP mit dem OpenAI Agents SDK für autonome Zahlungen verbinden.

Das [OpenAI Agents SDK](https://openai.github.io/openai-agents-python/) spricht MCP nativ. Plugge Ovra ein und deine Agents picken alle 19 Tools auf — `ovra_pay`, `ovra_card`, `ovra_intent`, der Rest — ohne Tool-Wrapper schreiben zu müssen.

<Note>
  Heute Sandbox-only. `sk_sandbox_*` oder `sk_test_*` Key verwenden.
</Note>

## Installation

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

## Hosted MCP (empfohlen)

OpenAI ruft Ovra direkt — kein lokaler Subprozess.

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

agent = Agent(
    name="Procurement Agent",
    instructions=(
        "Du kaufst Bürobedarf unter EUR 100. "
        "Immer einen Intent deklarieren bevor Credentials angefordert werden. "
        "Niemals den User nach Kartennummern fragen — Ovra handled das."
    ),
    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="Du kaufst Bürobedarf unter EUR 100.",
    model="gpt-4.1",
    mcp_servers=[ovra],
)
```

## Ausführen

```python theme={}
result = await Runner.run(
    agent,
    "Kauf einen USB-C Hub unter EUR 30 auf amazon.de"
)
print(result.final_output)
```

## Payment-Flow den der Agent ausführt

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

  <Step title="Credential minten">
    `ovra_pay { action: "checkout", ... }` (oder `handle_402` für MPP-Merchants)
  </Step>

  <Step title="Beim Merchant zahlen">
    Entweder MPP (server-zu-server) oder CUA (Browser-Autofill).
  </Step>

  <Step title="Verifizieren + schließen">
    `ovra_intent { action: "verify", ... }` um Actual-Amount aufzuzeichnen.
  </Step>
</Steps>

## Empfohlene Tools

| Tool               | Zweck                                    |
| ------------------ | ---------------------------------------- |
| `ovra_pay`         | Voller Flow in einem Call                |
| `ovra_intent`      | Deklarieren und verifizieren             |
| `ovra_credential`  | Feingranulare Credential-Lifecycle       |
| `ovra_transaction` | History lesen                            |
| `ovra_policy`      | Spend-Limits vor Deklaration inspizieren |

## Menschliche Freigabe

Für Policies mit `enforcementLevel: "approve"` landen Intents in `pending_approval`. Das OpenAI Agents SDK supports Human-in-the-Loop Checkpoints; pausieren bis deine Approval-Surface den Intent auf `approved` flippt.

## Weiter

<CardGroup cols={2}>
  <Card title="MCP-Übersicht" icon="info" href="/de/mcp/overview">
    Architektur und volle 19-Tool-Liste.
  </Card>

  <Card title="LangGraph" icon="diagram-project" href="/de/integrations/langgraph">
    Stateful Agent-Graphs.
  </Card>

  <Card title="CrewAI" icon="users" href="/de/integrations/crewai">
    Multi-Agent-Teams mit Rollen-Trennung.
  </Card>
</CardGroup>
