OpenAI Agents SDK + Govyn — Govern Your OpenAI Agents

The OpenAI Agents SDK makes it easy to build multi-step agents with handoffs, but it gives agents direct access to your API key. A single agent loop can generate unlimited completions, and there's no built-in way to cap spending or restrict which models an agent can use.

How it works

OpenAI Agents SDK
Your agents
HTTPS
Govyn Proxy
Policy · Budget · Logs
API
OpenAI API
LLM provider

Step-by-step setup

1

Start the Govyn proxy

bash
npx govyn start --config govyn.yaml
2

Configure the OpenAI client to use Govyn

python
from openai import AsyncOpenAI
from agents import Agent, Runner, set_default_openai_client

client = AsyncOpenAI(
    base_url="http://localhost:4111/v1",
    api_key="gvn_agent_openai_sdk_01"
)
set_default_openai_client(client)
3

Run your agent as usual

python
agent = Agent(
    name="Research Assistant",
    instructions="You help with research tasks.",
    model="gpt-4o"
)

result = await Runner.run(agent, "Find recent papers on AI safety")
print(result.final_output)

Example policy

Define governance rules for your OpenAI Agents SDK agents in a simple YAML file.

govyn.yaml
agents:
  openai_sdk_01:
    budget:
      daily: $10.00
      monthly: $200.00
    models:
      allow: [gpt-4o, gpt-4o-mini]
    rate_limit:
      requests_per_minute: 40
    logging:
      replay: true
      log_tool_calls: true

Why use Govyn with OpenAI Agents SDK?

Budget caps for agent runs and handoffs
Model restrictions per agent
Full replay of multi-step agent traces
Rate limiting to prevent infinite loops
Works with agent handoffs and tool calls
No SDK patching — just set the base URL

Get started in 5 minutes

Add governance to your OpenAI Agents SDK agents with a single config change. No code rewrites.

Read the docs

Frequently asked questions

Does Govyn support OpenAI Agents SDK handoffs?
Yes. Handoffs between agents work transparently through Govyn. If each agent uses a different API key, you get independent budget tracking and policy enforcement for each agent in the handoff chain.
Can I use Govyn with the Agents SDK's built-in tracing?
Yes. Govyn's proxy is transparent — the OpenAI Agents SDK's built-in tracing works alongside Govyn's replay logs. You get both OpenAI's tracing and Govyn's governance audit trail.
How do I prevent an agent from looping indefinitely?
Set a rate limit and daily budget cap in your Govyn policy. If an agent hits the rate limit or exhausts its budget, Govyn returns a clear error response that the SDK handles gracefully, stopping the loop.

Related integrations

Explore more