Skip to main content

OpenAI Agents SDK

Integrate AgentSuite with the OpenAI Agents SDK via the Virtue Gateway for full protection: MCP Guard, AgentGuard, and Access Control — with full session tracing and observability in the dashboard.

Installation

pip install agentsuite-sdk[openai]

How It Works

  • adapter.mcp_server() — proxy MCP server to pass into Agent(mcp_servers=[...]).
  • adapter.input_filter — register as RunConfig(call_model_input_filter=...) to track user messages each turn.

Quickstart

from agents import Agent, Runner, RunConfig
from agentsuite import GatewayClient

client = GatewayClient(url="...", api_key="sk-vai-...")
adapter = client.openai()

mcp_server = adapter.mcp_server()
await mcp_server.connect()

try:
agent = Agent(
name="my-agent",
model="gpt-4o",
mcp_servers=[mcp_server],
)
run_config = RunConfig(
model="gpt-4o",
call_model_input_filter=adapter.input_filter,
)
result = await Runner.run(agent, input="What are my open tickets?", run_config=run_config)
print(result.final_output)
finally:
await mcp_server.cleanup()

Full runnable example: demo_openai.py

Example Output

The agent responds to the query and prints the session ID:

OpenAI demo terminal output

View the full session trace in the VirtueAgent dashboard (Observability → Sessions):

VirtueAgent Sessions tab: session overview and execution trace

Environment Variables

VariableDescription
VIRTUE_GATEWAY_URLGateway MCP endpoint URL
VIRTUE_API_KEYVirtueAI API key
OPENAI_API_KEYOpenAI API key
AGENT_MODELModel name (default: gpt-4o)