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
Step-by-step setup
Start the Govyn proxy
npx govyn start --config govyn.yaml Configure the OpenAI client to use Govyn
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) Run your agent as usual
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.
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?
Get started in 5 minutes
Add governance to your OpenAI Agents SDK agents with a single config change. No code rewrites.
Read the docsFrequently asked questions
Does Govyn support OpenAI Agents SDK handoffs?
Can I use Govyn with the Agents SDK's built-in tracing?
How do I prevent an agent from looping indefinitely?
Related integrations
Add budget controls and policy enforcement to CrewAI multi-agent crews using OpenAI. Govern every agent in your crew independently.
Add governance to any Python AI agent. Works with requests, httpx, and the OpenAI SDK. Budget limits, policy enforcement, full replay.
Add budget limits, policy enforcement, and full replay to LangChain agents using OpenAI. Five-minute setup, zero code changes.
Explore more
SDK wrappers are door locks. Proxies are walls. A deep technical comparison of both governance architectures for AI agents in production.
POLICY TEMPLATESet daily and monthly spending limits for AI agents. Prevent runaway costs with hard budget caps enforced at the proxy level.
POLICY TEMPLATEProtect production environments from AI agent damage. Model restrictions, rate limits, and approval gates for high-risk operations.
COMPARISONCompare Govyn and AgentBudget for AI agent cost control. Proxy-level enforcement vs in-code budget tracking.