Overview
The Skyvern Python SDK provides a Playwright-compatible interface with AI-powered browser automation capabilities. It combines traditional browser automation with AI-powered task execution, allowing you to use natural language prompts alongside standard Playwright methods.Installation
Initialization
Remote Mode (Skyvern Cloud)
Connect to Skyvern Cloud or a self-hosted instance:api_key(str, required): API key for authenticating with Skyvern. Get yours at app.skyvern.com/settingsenvironment(SkyvernEnvironment, optional): The Skyvern environment to connect toSkyvernEnvironment.CLOUD(default) - Skyvern CloudSkyvernEnvironment.STAGING- Staging environmentSkyvernEnvironment.PRODUCTION- Self-hosted production
base_url(str, optional): Override the base URL for the Skyvern APItimeout(float, optional): Timeout in seconds for API requestsfollow_redirects(bool, optional): Whether to follow HTTP redirects (default:True)httpx_client(httpx.AsyncClient, optional): Custom httpx client for API requests
Local/Embedded Mode
Run Skyvern locally in-process:skyvern quickstart first to set up your environment and create a .env file.
Parameters:
llm_config(LLMRouterConfig | LLMConfig, optional): Custom LLM configuration. If provided, overrides theLLM_KEYsetting from.envsettings(dict[str, Any], optional): Dictionary of settings to override from.env(e.g.,{"MAX_STEPS_PER_RUN": 100})
Browser Management
Launch Cloud Browser
Launch a new cloud-hosted browser session:timeout(int, optional): Timeout in minutes for the session (between 5-1440, default: 60)proxy_location(ProxyLocation, optional): Geographic proxy location for browser traffic (Skyvern Cloud only)
Use Cloud Browser
Get or create a cloud browser session (reuses existing session if available):launch_cloud_browser()
Connect to Existing Cloud Session
Connect to an existing cloud browser session by ID:browser_session_id(str, required): The ID of the cloud browser session
Launch Local Browser
Launch a new local Chromium browser with CDP enabled:headless(bool, optional): Run browser in headless mode (default:False)port(int, optional): CDP endpoint port (default:9222)args(list[str], optional): Additional Chromium command-line argumentsuser_data_dir(str, optional): Custom user data directory path
Connect to Browser via CDP
Connect to an existing browser via Chrome DevTools Protocol:cdp_url(str, required): The CDP WebSocket URL
Task Execution
Run Task
Execute a one-off AI-powered browser automation task:prompt(str, required): Natural language description of the taskengine(RunEngine, optional): Execution engine (default:RunEngine.skyvern_v2)model(dict[str, Any], optional): LLM model configuration optionsurl(str, optional): Starting URL for the taskwebhook_url(str, optional): URL for webhook notificationstotp_identifier(str, optional): TOTP identifier for 2FAtotp_url(str, optional): URL to fetch TOTP codestitle(str, optional): Human-readable title for the taskerror_code_mapping(dict[str, str], optional): Custom error code mappingsdata_extraction_schema(dict[str, Any] | str, optional): Schema for extracted dataproxy_location(ProxyLocation, optional): Geographic proxy locationmax_steps(int, optional): Maximum number of stepswait_for_completion(bool, optional): Wait for task to complete (default:False)timeout(float, optional): Timeout in seconds (default:1800)browser_session_id(str, optional): Use existing browser sessionuser_agent(str, optional): Custom user agentextra_http_headers(dict[str, str], optional): Additional HTTP headerspublish_workflow(bool, optional): Publish as workflow (default:False)include_action_history_in_verification(bool, optional): Include action historymax_screenshot_scrolls(int, optional): Maximum screenshot scrollsbrowser_address(str, optional): Custom browser address
TaskRunResponse with execution results
Data Extraction Example:
Run Workflow
Execute a pre-defined workflow:workflow_id(str, required): ID of the workflow to executeparameters(dict[str, Any], optional): Workflow parameterstemplate(bool, optional): Whether this is a templatetitle(str, optional): Human-readable titleproxy_location(ProxyLocation, optional): Geographic proxy locationwebhook_url(str, optional): Webhook notification URLtotp_url(str, optional): TOTP URLtotp_identifier(str, optional): TOTP identifierbrowser_session_id(str, optional): Use existing browser sessionmax_steps_override(int, optional): Override max stepsuser_agent(str, optional): Custom user agentbrowser_profile_id(str, optional): Browser profile IDmax_screenshot_scrolls(int, optional): Maximum screenshot scrollsextra_http_headers(dict[str, str], optional): Additional headersbrowser_address(str, optional): Custom browser addressai_fallback(bool, optional): Enable AI fallbackrun_with(str, optional): Run with specific configurationwait_for_completion(bool, optional): Wait for completion (default:False)timeout(float, optional): Timeout in seconds (default:1800)
WorkflowRunResponse with execution results
Login
Execute a login workflow with stored credentials:credential_type(CredentialType, required): Type of credentialCredentialType.skyvern- Skyvern-stored credentialsCredentialType.bitwarden- Bitwarden credentialsCredentialType.onepassword- 1Password credentialsCredentialType.azure_vault- Azure Key Vault credentials
url(str, optional): Login page URLcredential_id(str, optional): Skyvern credential ID (forCredentialType.skyvern)bitwarden_collection_id(str, optional): Bitwarden collection IDbitwarden_item_id(str, optional): Bitwarden item IDonepassword_vault_id(str, optional): 1Password vault IDonepassword_item_id(str, optional): 1Password item IDazure_vault_name(str, optional): Azure vault nameazure_vault_username_key(str, optional): Azure username keyazure_vault_password_key(str, optional): Azure password keyazure_vault_totp_secret_key(str, optional): Azure TOTP secret keyprompt(str, optional): Custom login instructionswebhook_url(str, optional): Webhook notification URLproxy_location(ProxyLocation, optional): Geographic proxy locationtotp_identifier(str, optional): TOTP identifiertotp_url(str, optional): TOTP URLbrowser_session_id(str, optional): Use existing browser sessionbrowser_address(str, optional): Custom browser addressextra_http_headers(dict[str, str], optional): Additional headersmax_screenshot_scrolling_times(int, optional): Max screenshot scrollswait_for_completion(bool, optional): Wait for completion (default:False)timeout(float, optional): Timeout in seconds (default:1800)
WorkflowRunResponse with execution results
Resource Management
Close Resources
Close Playwright and release resources:Properties
environment
Get the current Skyvern environment:Complete Example
See Also
- AI Commands - Learn about AI-powered page methods
- Browser Automation - Mix Playwright with AI
- Authentication - API keys and credential management
- TypeScript SDK - TypeScript/JavaScript SDK reference