Set terminateOnCompletion: true on your final task, or call terminate explicitly. This alone reduces costs by 50% if you’re currently letting sessions timeout.
// Single task - auto-terminatesconst result = await fetch("https://connect.webrun.ai/start/run-task", { method: "POST", headers: { "Content-Type": "application/json", "Authorization": `Bearer ${API_KEY}` }, body: JSON.stringify({ task: { prompt: "Extract data from this page" } })});// Multi-task - terminate on last taskconst finalTask = await fetch("https://connect.webrun.ai/start/send-message", { method: "POST", headers: { "Content-Type": "application/json", "Authorization": `Bearer ${API_KEY}` }, body: JSON.stringify({ sessionId, message: { actionType: "newTask", prompt: "Final task here", terminateOnCompletion: true } }});
Shorter descriptions = fewer input tokens. Be specific, not verbose.❌ Verbose (150 tokens):
"Please navigate to the Amazon website and then perform a search for wireless keyboards. After you get the results, I need you to look through them carefully and find the ones that have good ratings, preferably above 4 stars, and then return me a list of the top 5 products with their titles, prices, and rating information."
✅ Concise (35 tokens):
"Go to Amazon, search 'wireless keyboard'. Return top 5 with rating ≥ 4.0 as JSON: title, price, rating."
Impact: 75% reduction in input tokens for this task.
Reuse sessions for related tasks instead of creating new ones.❌ Expensive:
await runTask("Go to amazon.com"); // New sessionawait runTask("Search for keyboards"); // Another new sessionawait runTask("Get first result"); // Yet another session
✅ Optimized:
const session = await startSession("Go to amazon.com");await sendTask(session, "Search for keyboards");await sendTask(session, "Get first result", { terminateOnCompletion: true });
WebRun-managed proxies cost $2 per GB of data transfer. For tasks that download large files or scrape image-heavy pages, use your own proxy to avoid per-GB charges. Only enable proxies when you actually need geographic targeting or IP management — each proxied session adds 2-3 seconds of cold-start latency.
{ "proxy": { "source": "custom", "type": "http", "host": "your-proxy.com", "port": "8080" }, "task": { "prompt": "Download all product images from the catalog" }}
// Creates 3 separate sessionsconst result1 = await runTask("Go to amazon.com");await sleep(5000); // Forgot to terminate, paying for idle timeconst result2 = await runTask("Please navigate to the search box and then type in 'wireless keyboard' and press enter");await sleep(5000);const result3 = await runTask("Get me information about the first result");
After: Optimized
// Single session, concise tasks, explicit terminationconst session = await startSession({ mode: "default", task: { prompt: "Go to amazon.com", startingUrl: "https://amazon.com", maxDuration: 60000 // 1 minute max }});await sendTask(session, "Search 'wireless keyboard'");await sendTask(session, "Return first result as JSON: title, price, rating", { terminateOnCompletion: true});
Savings: ~70% cost reduction from session reuse, concise prompts, and explicit termination.