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.

LLM provider4-step setupBearer key auth

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.

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 match the semantic dispatch cache and replay deterministically.

OpenAI tool calling → Twin RESTpython
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.

  1. Describe the tool

    Add a twin_run function schema with url and prompt parameters to your tools array.

  2. Handle the call

    When the model calls it, POST { url, prompt, success } to /api/v1/run with your Bearer key.

  3. Return the result

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

  4. 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?
No. You keep your model for reasoning. Twin is the browser execution layer it calls as a tool — and on a repeated task it removes the need to re-plan the browser work at all.
How is LLM cost billed?
A cold compile is billed the higher of its flat action price or the metered cost of the run — see the rate card at /api/v1/pricing. On a semantic-cache hit or a deterministic replay there is no planning call to bill.

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.