Run Kernel with Instant
Kernel gives you a headless browser that your own code drives step by step, with a profile saved when the browser is deleted. This page is part of Run browser agents with Instant. Before you start, follow Set up the project there: turn on Instant, install the SDK, and set COMPOSIO_API_KEY and COMPOSIO_USER_ID.
The script opens a browser for one user, runs a small task on https://example.com, prints the result, and then cleans up everything it created. Every script starts with a run() helper that executes one tool on the user's Instant account and raises if the call fails; the API scripts use an equivalent call helper and a trap that cleans up on exit. If a call fails, read Errors you may see.
Kernel has no agent on Instant: your code or your own model decides which page to read next. Instant browsers are headless only, so there is no live view, screenshots are blank, and keyboard and mouse input don't reach the page. Use Kernel to read pages through a browser that keeps the user's cookies.
KERNEL_CREATE_BROWSER requires timeout_seconds on Instant. KERNEL_BROWSER_CURL fetches a URL through the browser. KERNEL_DELETE_BROWSER closes it and saves the profile.
What the example contains
| Part | What it does |
|---|---|
ProfileKERNEL_CREATE_PROFILE | Stores the user's cookies. Create it once per user and keep its id. |
BrowserKERNEL_CREATE_BROWSER | Opens a headless browser with the profile loaded. timeout_seconds is required and sets how long the browser can run; save_changes: true saves cookies back. The browser ID is session_id (or id). |
Page readKERNEL_BROWSER_CURL | Fetches a URL through the browser, with its cookies, and returns status, headers, and body. Parse body yourself, or hand the text to your model. |
CleanupKERNEL_DELETE_BROWSER, KERNEL_DELETE_PROFILE | Deletes the browser (in finally, so it runs on errors) and then the profile. |
import os
from composio import Composio
composio = Composio()
session = composio.create(
user_id=os.environ["COMPOSIO_USER_ID"], toolkits=["kernel"]
)
def run(slug: str, arguments: dict) -> dict:
result = session.execute(
slug, arguments=arguments, account="instant_account"
)
if result.result_type != "completed":
raise RuntimeError(f"{slug} failed: {result.error}")
return result.data
profile_id = run("KERNEL_CREATE_PROFILE", {})["id"]
try:
browser = run(
"KERNEL_CREATE_BROWSER",
{
"timeout_seconds": 30,
"profile": {"id": profile_id, "save_changes": True},
},
)
browser_id = browser.get("session_id") or browser["id"]
try:
page = run(
"KERNEL_BROWSER_CURL",
{
"id_or_name": browser_id,
"url": "https://example.com",
"timeout_ms": 20000,
},
)
print(page["status"], page["body"][:200])
finally:
# Deleting the browser saves its cookies into the profile.
run("KERNEL_DELETE_BROWSER", {"id_or_name": browser_id})
finally:
run("KERNEL_DELETE_PROFILE", {"id_or_name": profile_id})Each user can hold up to three active Kernel browsers, so delete each one when you're done, including on errors.
All tools in this toolkit
Every Kernel tool you can call with the Instant account. Instant browsers are headless, so only the browser, request, and profile tools are useful there. Required arguments are listed; open a tool in the toolkit catalog for every argument and response field.
Browsers
| Tool | What it does | Required arguments |
|---|---|---|
KERNEL_CREATE_BROWSER | Create a Kernel browser session; defaults to a headless browser with a 60-second inactivity timeout. | None |
KERNEL_DELETE_BROWSER | Permanently end and delete a Kernel browser session by ID or name. | id_or_name |
KERNEL_GET_BROWSER | Get safe operational details for one browser session by ID or name, optionally including a deleted session. | id_or_name |
Reading and sending requests
| Tool | What it does | Required arguments |
|---|---|---|
KERNEL_BROWSER_CURL | Send a read-only GET, HEAD, or OPTIONS request through a Kernel browser's network stack, inheriting its cookies, TLS fingerprint, proxy settings, and default headers. | id_or_name, url |
KERNEL_BROWSER_HTTP_REQUEST | Send a state-changing POST, PUT, PATCH, or DELETE request through a Kernel browser's network stack, inheriting its cookies, TLS fingerprint, proxy settings, and default headers. | id_or_name, url, method |
Profiles
| Tool | What it does | Required arguments |
|---|---|---|
KERNEL_CREATE_PROFILE | Create an empty persistent browser profile, optionally with a unique name, for reuse by later browser sessions. | None |
KERNEL_DELETE_PROFILE | Permanently delete a browser profile by ID or name. | id_or_name |
KERNEL_GET_PROFILE | Get one browser profile by its ID or exact name. | id_or_name |
KERNEL_LIST_PROFILES | List browser profiles, optionally filtered by substring or exact name, one offset page at a time. | None |
KERNEL_RENAME_PROFILE | Rename a Kernel browser profile by ID or exact name. | id_or_name, name |
Mouse, keyboard, screen and clipboard (need a visible browser, so they do nothing useful on Instant)
| Tool | What it does | Required arguments |
|---|---|---|
KERNEL_BATCH_COMPUTER_ACTIONS | Execute 1-100 computer actions sequentially in a Kernel browser, stopping on the first error. | id_or_name, actions |
KERNEL_CLICK | Click at browser viewport coordinates with an optional mouse button, click phase, modifiers, and repetition count. | id_or_name, x, y |
KERNEL_DRAG_MOUSE | Drag a mouse button through an ordered path of browser viewport coordinates, with optional timing, linear-step, and modifier controls. | id_or_name, path |
KERNEL_GET_MOUSE_POSITION | Get the current mouse cursor coordinates in a Kernel browser session. | id_or_name |
KERNEL_MOVE_MOUSE | Move the cursor to browser viewport coordinates, optionally using a timed human-like path and held modifier keys. | id_or_name, x, y |
KERNEL_PRESS_KEY | Press an ordered sequence of X11 keys or key chords in a browser, optionally holding modifiers or holding the sequence for a duration. | id_or_name, keys |
KERNEL_READ_CLIPBOARD | Read the current text from a Kernel browser session's clipboard. | id_or_name |
KERNEL_SCROLL | Scroll horizontally or vertically at browser viewport coordinates, optionally while holding modifier keys. | id_or_name, x, y |
KERNEL_SET_CURSOR_VISIBILITY | Hide or show the cursor in a Kernel browser session. | id_or_name, hidden |
KERNEL_TAKE_SCREENSHOT | Capture the full browser viewport or a rectangular region as a PNG download. | id_or_name |
KERNEL_TYPE_TEXT | Type text into the currently focused browser element with an optional per-keystroke delay. | id_or_name, text |
KERNEL_WRITE_CLIPBOARD | Write text to the system clipboard of a Kernel browser session. | id_or_name, text |
Try it with your own task
Kernel has no agent, so give the browser to your own model as a "read this URL" tool and let the model decide which page to read next. For example, ask your agent:
Read https://news.ycombinator.com and list the top three story titles. Use one page read per URL and stop when you have the answer.Next steps
- Compare the other browser toolkits in Run browser agents with Instant.
- Read how to clean up.