Agents

OpenAI Agents SDK

Connect the OpenAI Agents SDK to your gateway.

The OpenAI Agents SDK connects to your gateway with MCPServerStreamableHttp.

Copy the gateway URL, create a Gateway API Key in MCP Gateways, and export both values:

export CODEINTEGRITY_MCP_URL='https://your-host/mcp/{slug}'
export CODEINTEGRITY_API_KEY='ci_mcp_...'
pip install openai-agents
import asyncio
import os

from agents import Agent, Runner
from agents.mcp import MCPServerStreamableHttp

async def main():
    async with MCPServerStreamableHttp(
        name="orchestrator",
        params={
            "url": os.environ["CODEINTEGRITY_MCP_URL"],
            "headers": {
                "Authorization": f"Bearer {os.environ['CODEINTEGRITY_API_KEY']}"
            },
        },
    ) as server:
        agent = Agent(
            name="Assistant",
            instructions="Use the MCP tools to answer the question.",
            mcp_servers=[server],
        )
        result = await Runner.run(agent, "What tools can you use?")
        print(result.final_output)

asyncio.run(main())

The gateway exposes search, execute_code, and authorize. Programmatic agents normally authenticate with the Gateway API Key above.