# apifare for OpenAI Agents SDK One prepaid, capped key for every API your agent needs, under hard caps and a kill switch. 1. Get a token: https://apifare.com/start?origin=page:integrations-openai-agents-sdk (shown once). 2. Connect your agent to apifare's remote MCP endpoint with MCPServerStreamableHttp. The token is read from the APIPAY_TOKEN environment variable and sent as an Authorization header. ``` pip install openai-agents ``` ``` import asyncio import os from agents import Agent, Runner from agents.mcp import MCPServerStreamableHttp async def main() -> None: token = os.environ["APIPAY_TOKEN"] async with MCPServerStreamableHttp( name="apifare", params={ "url": "https://apifare.com/mcp", "headers": {"Authorization": f"Bearer {token}"}, "timeout": 10, }, ) as server: agent = Agent( name="Assistant", instructions="Use the MCP tools to answer the questions.", mcp_servers=[server], ) result = await Runner.run(agent, "What's the weather in London?") print(result.final_output) asyncio.run(main()) ``` Set APIPAY_TOKEN and OPENAI_API_KEY, then run it. To run apifare locally instead, MCPServerStdio takes npx -y apifare-mcp with APIPAY_TOKEN in its env. 3. Try it: "search the web for X", then "fetch a URL", then "what's the weather in London". 4. Caps and the kill switch are checked before dispatch. An empty balance returns HTTP 402 with a top-up link (see /errors.md). Prices: https://apifare.com/capabilities. Config checked against https://openai.github.io/openai-agents-python/mcp/ on 2026-09-13.