Agent framework integration
Twin Browser + OpenAI Agents SDK
The OpenAI Agents SDK is a lightweight Python framework for agentic applications — agents, handoffs, guardrails and sessions. Alongside function tools it can connect to MCP servers, including ones it launches itself as a local subprocess over stdio.
How Twin plugs into OpenAI Agents SDK
This is the cleanest wiring on the page, because it needs no adapter at all: the Agents SDK launches `twin-browser-mcp` with `MCPServerStdio` and every one of Twin’s 31 tools becomes available to the agent. No tool schemas to write, no request bodies to keep in sync — the server publishes them. Pass your key in the subprocess env and the agent can run goals, compile skills, replay them, take screenshots, extract structured data and resume a paused run.
Twin is the browser execution layer your stack calls. The first run cold-compiles a skill via skill compilation; every similar request after that is matched from the cache and replayed deterministically, so your marginal cost per run trends toward zero rather than climbing with usage.
- Receive goal from OpenAI Agents SDKdone
- Compile DOM → token-efficient indexed statedone
- Match the semantic dispatch cacherunning
- Replay compiled skill — 0 LLM callsqueued
What you get through OpenAI Agents SDK
Every integration is a thin wrapper over the same execution layer, so the cache, the replay, and the corpus apply no matter how you call in.
Semantic dispatch cache
A re-phrased goal fuzzy-matches an already-compiled skill, so most calls never touch the LLM.
Deterministic replay
A compiled skill replays the exact action path with zero LLM calls — fast, repeatable, cheap.
Cross-tenant skill corpus
A skill compiled once can be safely reused across tenants, so the hit rate climbs as the network runs.
One Bearer key
Auth, usage-based billing, and an audit log run on every call — the same key works from every integration.
Wire it up
Drop Twin into OpenAI Agents SDK.
Copy, paste, and swap in your Bearer key. The first run compiles a skill; repeats match the semantic dispatch cache and replay deterministically.
import os
from agents import Agent, Runner
from agents.mcp import MCPServerStdio
async with MCPServerStdio(
name="Twin Browser",
params={
"command": "npx",
"args": ["-y", "twin-browser-mcp"],
"env": {"TWIN_API_KEY": os.environ["TWIN_API_KEY"]},
},
) as twin:
agent = Agent(
name="Ops assistant",
instructions="Use the twin-browser tools for anything on the web.",
mcp_servers=[twin],
)
result = await Runner.run(agent, "Download last month's invoice from the billing portal.")
print(result.final_output)Base URL https://twin-browser.com/api/v1 · auth Authorization: Bearer ab_live_… · over MCP the same engine is run_goal, compile_skill and run_skill — the full tool table.
Install the SDK
pip install openai-agents. Node 20+ must be on PATH so npx can launch the MCP server.
Get an API key
Create an ab_live_ key in the Twin dashboard under Keys & Secrets.
Launch the server
Wrap MCPServerStdio around npx -y twin-browser-mcp, passing TWIN_API_KEY in the params env.
Attach it to an agent
Pass the server in mcp_servers=[...]; the agent discovers all 31 tools on connect.
FAQ
OpenAI Agents SDK on Twin — common questions
Can I connect to Twin over hosted MCP instead of stdio?
Should I use MCP or a function tool here?
Related
More ways to connect Twin
MCP (Model Context Protocol)
MCP is an open protocol that lets an LLM application discover and call external tools over a standard interface. An MCP client — Claude Desktop, Claude Code, Cursor, Windsurf, VS Code, Cline — launches or connects to an MCP server, lists its tools, and invokes them on the model’s behalf, with no bespoke glue per app.
OpenAI
OpenAI’s API supports function (tool) calling: you describe a function as a JSON schema, the model decides when to call it, and your code executes it and returns the result. This is the standard way to give a GPT-class model an external capability.
Python
Python is where most agent code lives — LangChain, LlamaIndex, CrewAI, AutoGen, Pydantic AI and the OpenAI and Anthropic SDKs are all Python-first. Anything you can express as a function call, an agent can be given as a tool.
Wire up OpenAI Agents SDK in minutes.
Free to start. Usage-based credits from $29/mo — each call billed the higher of its flat action price or its metered cost.