Skip to Content
ReferenceCLIAgent

Agent

Start Lightpanda as an interactive AI agent that can browse the web. See how to run the agent for practical documentation.

Options

usage: lightpanda agent [SCRIPT] [OPTIONS] [COMMON_OPTIONS] Arguments: [SCRIPT] Optional path to a .js script, or `-` for stdin. Runs the script (no LLM calls) and exits; `lightpanda run SCRIPT` is the preferred spelling. With no script and no --task, the REPL starts; from there /load runs a script and /save exports the session to a file. Caution: .js files can contain evaluate(...) calls that run arbitrary JavaScript in the page. Only run scripts you trust, the same way you would a shell script. Options: -a, --attach <PATH> Feed a local file to the model alongside --task. Repeatable, one file per flag. Text files are inlined (max 512 KiB each); images/audio/pdf are base64-encoded (max 20 MiB each). Requires --task. --base-url <URL> Override the API base URL for the provider. Defaults to the provider's standard endpoint. Ollama default: http://localhost:11434/v1. llama.cpp default: http://localhost:8080/v1. Hugging Face default is the serverless router (https://router.huggingface.co/v1); point this at a dedicated Inference Endpoint to use one. --effort <LEVEL> Per-turn reasoning budget, mapped to each provider's native thinking/reasoning knob. Default: low in the REPL (snappy turns), medium in one-shot --task mode, unless the provider sets its own default (Mistral defaults to none, as its default model rejects effort). In the REPL, use /effort to change it. Allowed values: none, minimal, low, medium, high, xhigh. --list-models Print the model IDs usable with `agent` for --provider, one per line, sorted, and exit. Auto-detects the provider from env when --provider is omitted. --model <MODEL> The model name to use. Defaults to a sensible default per provider. In the REPL, use /model to list and change models for the active provider. --no-llm Force the basic REPL even when an API key is present or --provider is set. Useful for testing slash commands without burning tokens, or for disabling the LLM in a saved command without editing the existing flags. Wins over --provider. --provider <PROVIDER> The AI provider. When omitted, lightpanda auto-detects an API key from your environment (ANTHROPIC_API_KEY, OPENAI_API_KEY, GOOGLE_API_KEY/GEMINI_API_KEY, HF_TOKEN, AI_GATEWAY_API_KEY, MISTRAL_API_KEY, OPENROUTER_API_KEY, VERTEX_API_KEY). With exactly one key set: that provider is used. With multiple keys on a TTY: you'll be prompted to pick; in non-interactive contexts, pass --provider explicitly. With no keys set: falls back to the basic REPL (slash commands only, no natural-language input, no LOGIN / ACCEPT_COOKIES keywords). openai_compatible targets any OpenAI-style server via OPENAI_BASE_URL + OPENAI_API_KEY; it is auto-detected when OPENAI_BASE_URL is set. Vertex project mode (GOOGLE_CLOUD_PROJECT + a gcloud token) works with --provider vertex; it is only auto-detected when GOOGLE_GENAI_USE_VERTEXAI=1 is set too. Local servers (ollama, llama_cpp) are never auto-detected (they need no key); select them explicitly with --provider ollama / --provider llama_cpp. Same for codex, which uses a ChatGPT subscription (OAuth) instead of an API key. Allowed values: "anthropic", "openai", "gemini", "huggingface", "vercel", "mistral", "openrouter", "ollama", "llama_cpp", "vertex", "codex", "openai_compatible". In the REPL, use /provider to list and change providers. --save <PATH> Synthesize a replayable .js script from the --task run and write it to PATH, instead of printing the answer. Replay it later with `run PATH` (no LLM calls). Overwrites PATH if it exists. A script that only reads pages (no clicks, key presses, page JavaScript, logins or files written) is replayed once first; if it fails or returns nothing, the model fixes it against the page the replay ended on. Requires --task. --search-engine <ENGINE> Which web search API the `search` tool uses. Default: auto, which takes the first with a key in the environment, in the order brave, tavily, exa, keenable. `keenable` also works with no key at all, through a rate-limited public endpoint. Allowed values: auto, brave, tavily, exa, keenable. --system-prompt <STRING> Override the default system prompt. --task <STRING> One-shot mode: run a single user turn, print the final answer to stdout, and exit. Conflicts with the positional script. With --save, the answer is suppressed and a script is written instead. --trace <PATH> Write one JSON line per step to PATH: each model call (latency, input, cached and output tokens) and each tool call (arguments, latency, result size, page URL and HTTP status), then a summary. Arguments keep their $LP_* placeholders; results are not written unless --trace-results is set. Overwrites PATH if it exists. --trace-results Also write each tool result's text to the --trace file, as the model received it. Pages can be large and may hold personal data, so this is off by default. Requires --trace. --url <URL> Open this page before the first turn. With --task it saves the model a turn spent navigating; with --save the opening navigation is the first line of the script. --verbosity <LEVEL> Stderr chatter level. Default: high when --task captures stderr to a pipe or file; low otherwise. low/medium also raise --log-level to err (mutes page-side console.error spam) unless --log-level is set explicitly. Allowed values: low silent in --task mode (final answer to stdout only); spinner + summary in REPL. medium + one `● [tool: ...]` line per call. high + the matching `[result: ...]` body (required by the benchmarks harness).

The provider, model, effort, verbosity, streaming, and search engine you choose in the REPL are remembered per-directory in .lp-agent.zon and reused on the next run.

API keys

API keys are read from the environment: ANTHROPIC_API_KEY, OPENAI_API_KEY, GOOGLE_API_KEY/GEMINI_API_KEY, HF_TOKEN, AI_GATEWAY_API_KEY, MISTRAL_API_KEY, OPENROUTER_API_KEY, or VERTEX_API_KEY. Any other OpenAI-compatible server is used through OPENAI_BASE_URL + OPENAI_API_KEY.

The local servers (Ollama, llama.cpp) do not require an API key.

The codex provider uses your ChatGPT subscription instead of a key: log in once with /provider codex in the REPL (see use your ChatGPT plan), and later runs reuse the stored login.

Examples

lightpanda agent (auto-detects API key from env) lightpanda agent --provider anthropic --model claude-sonnet-4-6 lightpanda agent --provider huggingface (HF serverless router, HF_TOKEN) lightpanda agent --provider openrouter --model anthropic/claude-sonnet-5 lightpanda agent --provider ollama --model qwen3.5:latest lightpanda agent --provider codex (ChatGPT subscription, after a /provider codex login) lightpanda agent --no-llm (basic slash-command-only REPL) lightpanda agent --task "..." --save out.js (synthesize a replayable script)

The command also accepts the common options.

REPL commands

Inside the REPL, slash commands work alongside natural-language input.

Meta commands

These commands configure the REPL and never reach the model.

CommandDescription
/help [command]List commands, or show help for one
/quitExit the REPL
/verbosity <low|medium|high>Set agent verbosity
/effort <null|none|minimal|low|medium|high|xhigh>Set per-turn reasoning effort
/stream [on|off]Toggle streaming of assistant text
/usageShow token usage and cache stats for this session
/clearClear conversation history and usage (keeps page/cookies)
/resetReset conversation and browser session (drops page/cookies)
/save [filename.js] [prompt]Save this session to a file
/load <path>Load and run a script from disk
/model [name]Change the model
/provider [name|null]Change the provider, or ‘null’ to disable the LLM
/searchEngine <auto|brave|tavily|exa|parallel|keenable>Change the web search engine

LLM commands

These commands send a prebuilt prompt to the model, so they need a provider.

CommandDescription
/logoutLog out of the current site

Browser commands

Given its fields, every browser tool runs directly as a slash command, with no model call. A lone required argument can be passed positionally; the rest take key=value or a JSON object.

These take only key=value, and also accept a prompt in place of their fields: /evaluate, /extract, /click, /fill, /hover, /selectOption, /setChecked. /click the sign in button asks the model for the selector, and the call it makes is what /save records.

CommandDescription
/goto <url> [timeout=…] [waitUntil=…]Open a URL and keep the page in memory
/search <query> [timeout=…]Web search, results as markdown
/download url=… path=…Fetch a URL with the session’s cookies into a file
/markdown [selector=…] [backendNodeId=…] [maxBytes=…] [strip=…] [url=…] [alternate=…] [timeout=…]Render the page or a subtree as markdown
/html [selector=…] [backendNodeId=…] [maxBytes=…] [strip=…] [url=…] [timeout=…]Raw HTML of the page or a node
/screenshot [path=…] [selector=…] [backendNodeId=…] [fullPage=…] [strip=…] [url=…] [timeout=…]Screenshot of the page or a node
/links [limit=…] [url=…] [timeout=…]List all links on the page
/tree [url=…] [timeout=…] [backendNodeId=…] [maxDepth=…] [maxBytes=…] [delta=…]Semantic DOM tree of the page
/nodeDetails <backendNodeId>Inspect a node by backendNodeId
/interactiveElements [url=…] [timeout=…]List interactive elements on the page
/structuredData [url=…] [timeout=…]Extract JSON-LD / microdata / OpenGraph data
/detectForms [url=…] [timeout=…]List forms and their fields
/findElement [role=…] [name=…]Find elements by role or name
/evaluate script=… [url=…] [timeout=…] [save=…]Run JavaScript in the page
/extract schema=… [save=…]Extract structured data via a CSS-selector schema
/classify <questions> [selector=…] [presets=…]Classify page state using semantic questions or presets
/click [selector=…] [backendNodeId=…]Click an element
/fill value=… [selector=…] [backendNodeId=…]Type text into an input
/scroll [selector=…] [backendNodeId=…] [x=…] [y=…]Scroll the page or an element
/hover [selector=…] [backendNodeId=…]Hover over an element
/press <key> [selector=…] [backendNodeId=…]Press a keyboard key
/selectOption value=… [selector=…] [backendNodeId=…]Select an option in a dropdown
/setChecked checked=… [selector=…] [backendNodeId=…]Check or uncheck a box
/acceptCookies [prefer=…] [selectors=…]Dismiss a cookie consent banner
/login <password> [username=…] [usernameSelector=…] [passwordSelector=…] [submitSelector=…] [nextSelector=…] [decideOnly=…]Sign in, picking the fields with Jev
/waitForSelector <selector> [timeout=…]Wait for an element to appear
/waitForScript <script> [timeout=…]Wait until a JS expression is truthy
/waitForState <state> [timeout=…]Wait for the page to reach a load state
/consoleLogsRead buffered console messages
/getUrlShow the current page URL
/getCookies [url=…] [all=…]Show stored cookies
/getEnv [name=…]Read or list LP_* env vars
/popups [follow=…]List windows the page opened, or switch to one
/pageToolsList the page’s WebMCP tools
/callPageTool <name> [arguments=…]Call one of the page’s WebMCP tools

Search engine. An API key is optional. By default (auto mode) search uses Keenable’s keyless public endpoint, rate-limited per client IP. To route through a specific provider, set BRAVE_API_KEY, TAVILY_API_KEY, EXA_API_KEY, or KEENABLE_API_KEY; auto tries Brave, Tavily, Exa, then Keenable in that order, using whichever keys are set.