LLM provider integration
Twin Browser + 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.
How Twin plugs into OpenAI
Define one `twin_run` function in your tools array and have the handler POST to `/api/v1/run`. The model decides what to do; Twin handles how to do it in the browser. Cost stays legible: a cold run is billed the higher of its flat action price and its metered cost, a semantic-cache hit skips the planning, and a compiled skill replayed by name makes no model call at all.
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.
What you get through OpenAI
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.
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, requests
from openai import OpenAI
client = OpenAI()
tools = [{
"type": "function",
"function": {
"name": "twin_run",
"description": "Perform a task in a real browser on an authorized URL",
"parameters": {
"type": "object",
"properties": {
"url": {"type": "string"},
"prompt": {"type": "string"},
},
"required": ["url", "prompt"],
},
},
}]
def twin_run(url, prompt):
r = requests.post(
"https://twin-browser.com/api/v1/run",
headers={"Authorization": f"Bearer {os.environ['TWIN_API_KEY']}"},
json={"url": url, "prompt": prompt, "success": {"kind": "extracted"}},
timeout=300,
)
return r.json()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.
Describe the tool
Add a twin_run function schema with url and prompt parameters to your tools array.
Handle the call
When the model calls it, POST { url, prompt, success } to /api/v1/run with your Bearer key.
Return the result
Feed Twin’s structured result back to the model as the tool output.
Compile the repeats
Once a goal is stable, compile it and replay by name so the browser step costs no model call.
FAQ
OpenAI on Twin — common questions
Does Twin replace my OpenAI model?
How is LLM cost billed?
Related
More ways to connect Twin
- Agent framework
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.
- LLM provider
Anthropic (Claude tool use)
Claude’s Messages API supports tool use: you pass a `tools` array where each tool has a `name`, a `description` and an `input_schema`. When Claude decides to use one, the response comes back with `stop_reason: "tool_use"`, you execute it, and you return a `tool_result` block in the next message.
- Language
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.
Integrations
Wire up OpenAI 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.