Custom Python Agents + Govyn — Govern Any Python Agent
Custom Python agents give you full flexibility, but that also means full responsibility for cost control and security. Whether you're using the OpenAI SDK, httpx, or raw requests, there's no centralized way to enforce budgets, restrict models, or audit API calls — until you add a governance proxy.
How it works
Step-by-step setup
Start the Govyn proxy
npx govyn start --config govyn.yaml Point the OpenAI SDK at Govyn
from openai import OpenAI
client = OpenAI(
base_url="http://localhost:4111/v1",
api_key="gvn_agent_python_01"
)
response = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "Hello"}]
) Or use httpx / requests directly
import httpx
response = httpx.post(
"http://localhost:4111/v1/chat/completions",
headers={"Authorization": "Bearer gvn_agent_python_01"},
json={
"model": "gpt-4o",
"messages": [{"role": "user", "content": "Hello"}]
}
) Example policy
Define governance rules for your Python agents in a simple YAML file.
agents:
python_01:
budget:
daily: $5.00
monthly: $100.00
models:
allow: [gpt-4o, gpt-4o-mini, claude-sonnet-4-20250514]
providers:
allow: [openai, anthropic]
rate_limit:
requests_per_minute: 30
logging:
replay: true Why use Govyn with Python?
Get started in 5 minutes
Add governance to your Python agents with a single config change. No code rewrites.
Read the docsFrequently asked questions
Do I need to use a specific Python framework?
Can I route to multiple providers through one proxy?
How do I migrate my existing Python agent to use Govyn?
Related integrations
Govern custom Node.js AI agents with Govyn. Works with the OpenAI SDK, fetch, and Vercel AI SDK. Budget limits and full replay.
Add budget limits, policy enforcement, and full replay to LangChain agents using OpenAI. Five-minute setup, zero code changes.
Add governance to OpenAI Agents SDK. Enforce budgets, model policies, and audit trails for every agent run. Five-minute setup.
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 TEMPLATEDetect and redact personally identifiable information in AI agent requests and responses. GDPR-friendly PII protection at the proxy level.
COMPARISONCompare Govyn and LiteLLM for AI agent governance. See how a governance-first proxy differs from a multi-provider routing gateway.