Launch Week - Day 2 - New and improved SDK

    Skyvern SDK v1+ lets you run tasks and workflows and share browser state over a CDP connection. The SDK supports two modes: embedded (local) and remote (cloud). Embedded (Local) mode Get started locally: * uv venv && source .venv/bin/activate — optional but recommended to create a virtual env * uv pip install skyvern — install the Skyvern SDK * skyvern quickstart — follow prompts to configure the environment (AI API keys, etc.) Python example: import asyncio from skyvern import Skyver

    Skyvern SDK v1+ lets you run tasks and workflows and share browser state over a CDP connection.

    The SDK supports two modes: embedded (local) and remote (cloud).

    Embedded (Local) mode

    Get started locally:

    • uv venv && source .venv/bin/activate — optional but recommended to create a virtual env
    • uv pip install skyvern — install the Skyvern SDK
    • skyvern quickstart — follow prompts to configure the environment (AI API keys, etc.)

    Python example:

    import asyncio
    
    from skyvern import Skyvern
    
    async def main():
        skyvern = Skyvern.local()
    
        browser = await skyvern.launch_local_browser()
        page = await browser.get_working_page()
    
        await page.goto("<https://news.ycombinator.com/>")
    
        result = await page.extract("Describe this website in one sentence")
        print(result)
    
    if __name__ == "__main__":
        asyncio.run(main())
    

    TypeScript SDK does not support local mode

    Remote (Cloud) mode

    Remote mode does not require local setup beyond installing the SDK.

    Python:

    • uv venv && source .venv/bin/activate — optional but recommended
    • uv pip install skyvern

    TypeScript:

    • npm install @skyvern/client

    TypeScript example:

    import { Skyvern } from "@skyvern/client";
    
    async function main() {
        const skyvern = new Skyvern({
            apiKey: process.env.SKYVERN_CLOUD_API_KEY!,
        });
    
        const browser = await skyvern.launchCloudBrowser();
        const page = await browser.getWorkingPage();
    
        await page.goto("<https://news.ycombinator.com/>");
    
        const result = await page.extract({ prompt: "Describe this website in one sentence" });
        console.log(result);
    
        await browser.close();
    }
    
    main().catch(console.error);
    

    Python example:

    import asyncio
    import os
    
    from skyvern import Skyvern
    
    async def main():
        skyvern = Skyvern(api_key=os.getenv("SKYVERN_CLOUD_API_KEY"))
    
        browser = await skyvern.launch_cloud_browser()
        page = await browser.get_working_page()
    
        await page.goto("<https://news.ycombinator.com/>")
    
        result = await page.extract("Describe this website in one sentence")
        print(result)
    
        await browser.close()
    
    if __name__ == "__main__":
        asyncio.run(main())
    

    Launching a browser

    After creating Skyvern (embedded or cloud), you can obtain a browser in several ways:

    • skyvern.launch_local_browser() — launches a local browser. Works only in embedded mode because a remote server cannot reach localhost due to NAT.
    • skyvern.connect_to_browser_over_cdp(cdp_url) — connects to a browser via a CDP URL.
    • skyvern.connect_to_cloud_browser_session(browser_session_id) — connects to an existing cloud browser with a pbs_… token.
    • skyvern.launch_cloud_browser() — creates a new cloud browser session.
    • skyvern.use_cloud_browser() — reuses an existing cloud browser session or creates a new one.

    Features

    Once a browser is available, create a page and mix tasks, workflows, and AI actions with regular Playwright code.

    Examples

    Run a login task with cloud-stored credentials, then click a button with Playwright and take a screenshot:

    TypeScript

    await page.goto("<https://www.saucedemo.com/>")
    await page.agent.login("skyvern", { credentialId: "cred_468280144912177062" })
    await page.waitForTimeout(1)
    
    await page.click("#add-to-cart-sauce-labs-backpack")
    await page.waitForTimeout(1)
    await page.screenshot({ path: "screenshot1.png", fullPage: true })
    

    Python

    await page.goto("<https://www.saucedemo.com/>")
    await [page.](<http://page.run>)agent.login(credential_type=CredentialType.skyvern, credential_id="cred_468280144912177062")
    await asyncio.sleep(1)
    
    await [page.click](<http://page.click>)("#add-to-cart-sauce-labs-backpack")
    await asyncio.sleep(1)
    await page.screenshot(path="screenshot1.png", full_page=True)
    

    page.click runs after the workflow and shares the same browser state.

    Go to a page and ask AI to extract information:

    TypeScript

    await page.goto("<https://news.ycombinator.com/>")
    const result = await page.extract({ prompt: "Give me the top news header" })
    console.log(result)
    

    Python

    await page.goto("<https://news.ycombinator.com/>")
    result = await page.extract("Give me the top news header")
    print(result)
    

    Run a workflow, then continue with Playwright:

    TypeScript

    await page.agent.runWorkflow("wpid_468290126806627926")
    await page.waitForTimeout(1)
    await page.screenshot({ path: "screenshot1.png", fullPage: true })
    
    await page.click("#shopping_cart_container")
    await page.waitForTimeout(1)
    await page.screenshot({ path: "screenshot2.png", fullPage: true })
    

    Python

    await page.agent.workflow("wpid_468290126806627926")
    await asyncio.sleep(1)
    await page.screenshot(path="screenshot1.png", full_page=True)
    
    await page.click("#shopping_cart_container")
    await asyncio.sleep(2)
    await page.screenshot(path="screenshot2.png", full_page=True)
    

    AI-augmented actions

    Use Playwright actions augmented with AI prompts.

    Regular Playwright click:

    await page.click("#button")
    

    Click a button using an AI prompt:

    TypeScript

    await page.click({ prompt: "Click the green button" })
    

    Python

    await page.click(prompt="Click the green button")
    

    Click with AI fallback: if the selector click fails, fall back to an AI prompt:

    TypeScript

    await page.click("#counterBroken", { prompt: "Click the green button" })
    

    Python

    await page.click("#counterBroken", prompt="Click the button")
    

    Client mode

    Skyvern can act as a cloud client. When tasks or workflows are run on the root skyvern object, they execute in the cloud without sharing a browser session.

    Example:

    skyvern = Skyvern(
        environment=[SkyvernEnvironment.CLOUD](<http://SkyvernEnvironment.CLOUD>),
        api_key=os.getenv("SKYVERN_CLOUD_API_KEY"),
    )
    
    await skyvern.run_task("Give me top 3 Hacker News items")
    

    Note the difference between skyvern.run_task and page.agent.run_task: the latter shares the browser session.

    Saucedemo

    TypeScript

    import { Skyvern } from "@skyvern/client";
    
    async function main() {
        const skyvern = new Skyvern({
            apiKey: process.env.SKYVERN_CLOUD_API_KEY!,
        });
    
        const browser = await skyvern.launchCloudBrowser();
        const page = await browser.getWorkingPage();
    
        await page.goto("<https://www.saucedemo.com/>")
        await page.agent.login("skyvern", { credentialId: "cred_468719279499195444" })
        await page.waitForTimeout(1)
    
        await page.click("#add-to-cart-sauce-labs-backpack")
        await page.waitForTimeout(2)
        await page.screenshot({ path: "screenshot1.png", fullPage: true })
    
        await page.click({ prompt: "Click on 'Add to card button' for 'Sauce Labs Fleece Jacket'" })
        await page.waitForTimeout(2)
        await page.screenshot({ path: "screenshot2.png", fullPage: true })
    
        await page.click("#shopping_cart_container")
        await page.waitForTimeout(2)
        await page.screenshot({ path: "screenshot3.png", fullPage: true })
    
        await page.agent.runTask("Checkout the order using: John Snow, 12345")
        await page.waitForTimeout(2)
        await page.screenshot({ path: "screenshot4.png", fullPage: true })
    
        await browser.close()
    }
    
    main().catch(console.error);
    

    Python

    import asyncio
    import os
    
    from skyvern import Skyvern
    from skyvern.schemas.run_blocks import CredentialType
    
    async def main():
        skyvern = Skyvern(api_key=os.getenv("SKYVERN_CLOUD_API_KEY"))
        browser = await skyvern.use_cloud_browser()
        page = await browser.get_working_page()
    
        await page.goto("<https://www.saucedemo.com/>")
        await page.agent.login(credential_type=CredentialType.skyvern, credential_id="cred_123")
        await asyncio.sleep(1)
    
        await page.click("#add-to-cart-sauce-labs-backpack")
        await asyncio.sleep(2)
        await page.screenshot(path="screenshot1.png", full_page=True)
    
        await page.click(prompt="Click on 'Add to card button' for 'Sauce Labs Fleece Jacket'")
        await asyncio.sleep(2)
        await page.screenshot(path="screenshot2.png", full_page=True)
    
        await page.click("#shopping_cart_container")
        await asyncio.sleep(2)
        await page.screenshot(path="screenshot3.png", full_page=True)
    
        await page.agent.run_task("Checkout the order using: John Snow, 12345")
        await asyncio.sleep(2)
        await page.screenshot(path="screenshot4.png", full_page=True)
    
        await browser.close()
    
    if __name__ == "__main__":
        asyncio.run(main())
    

    Download file example:

    Python

    import asyncio
    import os
    
    import requests
    
    from skyvern import Skyvern
    
    async def main():
        skyvern = Skyvern(api_key=os.getenv("SKYVERN_CLOUD_API_KEY"))
        browser = await skyvern.launch_cloud_browser()
        page = await browser.get_working_page()
    
        await page.goto("<https://file-examples.com/index.php/sample-video-files/>")
    
        result = await page.agent.download_files(
            prompt="Download 'Audio Video Interleave' download option",
            download_suffix="download"
        )
        print(f"downloaded_files: {result.downloaded_files}")
        for file in result.downloaded_files:
            print(file.url)
    
            response = requests.get(file.url)
            with open(file.filename, "wb") as f:
                f.write(response.content)
                print(f"Saved to {file.filename}")
    
        await browser.close()
    
    if __name__ == "__main__":
        asyncio.run(main())
    
    

    Typescript

    import { Skyvern } from "@skyvern/client";
    
    async function main() {
        const skyvern = new Skyvern({
            apiKey: process.env.SKYVERN_CLOUD_API_KEY!,
        });
    
        const browser = await skyvern.launchCloudBrowser();
        const page = await browser.getWorkingPage();
    
        await page.goto("<https://www.saucedemo.com/>")
        await page.agent.login("skyvern", { credentialId: "cred_468719279499195444" })
        await page.waitForTimeout(1)
    
        await page.click("#add-to-cart-sauce-labs-backpack")
        await page.waitForTimeout(2)
        await page.screenshot({ path: "screenshot1.png", fullPage: true })
    
        await page.click({ prompt: "Click on 'Add to card button' for 'Sauce Labs Fleece Jacket'" })
        await page.waitForTimeout(2)
        await page.screenshot({ path: "screenshot2.png", fullPage: true })
    
        await page.click("#shopping_cart_container")
        await page.waitForTimeout(2)
        await page.screenshot({ path: "screenshot3.png", fullPage: true })
    
        await page.agent.runTask("Checkout the order using: John Snow, 12345")
        await page.waitForTimeout(2)
        await page.screenshot({ path: "screenshot4.png", fullPage: true })
    
        await browser.close()
    }
    
    main().catch(console.error);