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 access to an external capability.

LLM provider3 MCP tools: run · compile_skill · run_skillBearer key auth

How Twin plugs into OpenAI

Define a single `twin_run` function in your tool schema and have your handler POST to Twin’s `/api/v1/run`. The model focuses on deciding what to do; Twin handles how to do it in the browser — compiling the task once and serving repeats from the semantic dispatch cache. Because Twin meters and passes LLM cost through at 1×, the rate card stays transparent while the cache drives your effective cost down.

Twin is the browser execution layer your stack calls. The first run cold-compiles a skill; every similar request after that is matched from the cache and replayed deterministically, so your marginal cost per run trends toward zero.

app.example.com
  1. Receive goal from OpenAIdone
  2. Compile DOM → token-efficient indexed statedone
  3. Match the semantic dispatch cacherunning
  4. Replay compiled skill — 0 LLM callsqueued
Wire it up

Drop Twin into OpenAI

Copy, paste, and swap in your Bearer key. The first run compiles a skill; repeats hit the semantic dispatch cache and replay deterministically.

OpenAI tool calling → Twin RESTpython
import requests
from openai import OpenAI

client = OpenAI()
tools = [{
    "type": "function",
    "function": {
        "name": "twin_run",
        "description": "Run a browser goal via Twin Browser",
        "parameters": {
            "type": "object",
            "properties": {"goal": {"type": "string"}, "url": {"type": "string"}},
            "required": ["goal"],
        },
    },
}]

def twin_run(goal, url=None):
    r = requests.post(
        "https://twin-browser.com/api/v1/run",
        headers={"Authorization": "Bearer tw_live_xxx"},
        json={"goal": goal, "url": url},
    )
    return r.json()  # structured result; cache hits skip the LLM

Base URL https://twin-browser.com/api/v1 · auth Authorization: Bearer tw_live_… · MCP tools run, compile_skill, run_skill.

Get started

Connect OpenAI in 4 steps

Install → configure your key → make the first call. The cache takes over from there.

  1. 1
    Describe the tool

    Add a twin_run function schema (goal, url) to your tools array.

  2. 2
    Handle the call

    When the model calls it, POST the args to /api/v1/run with your Bearer key.

  3. 3
    Return the result

    Feed Twin’s structured result back to the model as the tool output.

  4. 4
    Reuse skills

    Repeated goals match the cache, so the browser step costs near zero.

Why this stays cheap at scale

Most browser infrastructure re-runs the LLM on every execution, so cost climbs with usage. Twin compiles a task once via skill compilation, matches re-phrased requests to it, and replays without the model — so repeated workflows stop scaling with your token bill.

FAQ

OpenAI on Twin — common questions

Does Twin replace my OpenAI model?
No. You keep your model for reasoning. Twin is the browser execution layer the model calls as a tool — and it removes the need to re-run any model to drive the browser on repeated tasks.
How is LLM cost billed?
Twin meters the LLM cost of a cold compile and passes it through at 1× (see the rate card at /api/v1/pricing). On a cache hit or replay there is no LLM call to bill.

Wire up OpenAI in minutes

Free to start. Usage-based credits from $29/mo, with LLM cost metered and passed through at 1×.