Skip to main content
A task is a single browser automation. You describe what you want in natural language — Skyvern opens a browser, navigates to the URL, and executes the instructions with AI. For when to use tasks vs workflows, see Run a Task.

run_task

Start a browser automation. Skyvern opens a cloud browser, navigates to the URL, and executes your prompt with AI.
result = await client.run_task(
    prompt="Get the title of the top post",
    url="https://news.ycombinator.com",
    wait_for_completion=True,
)
print(result.output)

Parameters

ParameterTypeRequiredDefaultDescription
promptstrYesNatural language instructions for what the AI should do.
urlstrNoNoneStarting page URL. If omitted, the AI navigates from a blank page.
engineRunEngineNoskyvern_v2AI engine. Options: skyvern_v2, skyvern_v1, openai_cua, anthropic_cua, ui_tars.
wait_for_completionboolNoFalseBlock until the run finishes.
timeoutfloatNo1800Max wait time in seconds when wait_for_completion=True.
max_stepsintNoNoneCap the number of AI steps to limit cost. Run terminates with timed_out if hit.
data_extraction_schemadict | strNoNoneJSON schema or Pydantic model name constraining the output shape.
proxy_locationProxyLocationNoNoneRoute the browser through a geographic proxy.
browser_session_idstrNoNoneRun inside an existing browser session.
publish_workflowboolNoFalseSave the generated code as a reusable workflow. Only works with skyvern_v2.
webhook_urlstrNoNoneURL to receive a POST when the run finishes.
error_code_mappingdict[str, str]NoNoneMap custom error codes to failure reasons.
totp_identifierstrNoNoneIdentifier for TOTP verification.
totp_urlstrNoNoneURL to receive TOTP codes.
titlestrNoNoneDisplay name for this run in the dashboard.
modeldictNoNoneOverride the output model definition.
user_agentstrNoNoneCustom User-Agent header for the browser.
extra_http_headersdict[str, str]NoNoneAdditional HTTP headers injected into every browser request.
include_action_history_in_verificationboolNoNoneInclude action history when verifying task completion.
max_screenshot_scrollsintNoNoneNumber of scrolls for post-action screenshots. Useful for lazy-loaded content.
browser_addressstrNoNoneConnect to a browser at this CDP address instead of spinning up a new one.

Returns TaskRunResponse

FieldTypeDescription
run_idstrUnique identifier. Starts with tsk_ for task runs.
statusstrcreated, queued, running, completed, failed, terminated, timed_out, or canceled.
outputdict | NoneExtracted data from the run. Shape depends on your prompt or data_extraction_schema.
downloaded_fileslist[FileInfo] | NoneFiles downloaded during the run.
recording_urlstr | NoneURL to the session recording video.
screenshot_urlslist[str] | NoneFinal screenshots (most recent first).
failure_reasonstr | NoneError description if the run failed.
app_urlstr | NoneLink to view this run in the Cloud UI.
step_countint | NoneNumber of AI steps taken.
script_runScriptRunResponse | NoneCode execution result if the run used generated code.
created_atdatetimeWhen the run was created.
finished_atdatetime | NoneWhen the run finished.

Examples

Extract structured data:
result = await client.run_task(
    prompt="Extract the name, price, and rating of the top 3 products",
    url="https://example.com/products",
    data_extraction_schema={
        "type": "array",
        "items": {
            "type": "object",
            "properties": {
                "name": {"type": "string"},
                "price": {"type": "string"},
                "rating": {"type": "number"},
            },
        },
    },
    wait_for_completion=True,
)
print(result.output)
# [{"name": "Widget A", "price": "$29.99", "rating": 4.5}, ...]
Run inside an existing browser session:
session = await client.create_browser_session()

result = await client.run_task(
    prompt="Log in and download the latest invoice",
    url="https://app.example.com/login",
    browser_session_id=session.browser_session_id,
    wait_for_completion=True,
)
Limit cost with max_steps:
result = await client.run_task(
    prompt="Fill out the contact form",
    url="https://example.com/contact",
    max_steps=10,
    wait_for_completion=True,
)
Use a lighter engine:
from skyvern.schemas.runs import RunEngine

result = await client.run_task(
    prompt="Get the page title",
    url="https://example.com",
    engine=RunEngine.skyvern_v1,
    wait_for_completion=True,
)
Publish as a reusable workflow:
result = await client.run_task(
    prompt="Fill out the contact form with the provided data",
    url="https://example.com/contact",
    publish_workflow=True,
    wait_for_completion=True,
)
# The generated workflow is saved and can be re-triggered via run_workflow

get_run

Get the current status and results of any run (task or workflow).
run = await client.get_run("tsk_v2_486305187432193504")
print(run.status, run.output)

Parameters

ParameterTypeRequiredDescription
run_idstrYesThe run ID returned by run_task or run_workflow.

Returns GetRunResponse

A discriminated union based on run_type. All variants share the same core fields as TaskRunResponse above, plus a run_type field (task_v1, task_v2, openai_cua, anthropic_cua, ui_tars, workflow_run). Workflow run responses additionally include run_with and ai_fallback fields.

cancel_run

Cancel a running or queued run.
await client.cancel_run("tsk_v2_486305187432193504")

Parameters

ParameterTypeRequiredDescription
run_idstrYesThe run ID to cancel.
The run transitions to canceled status. If the run has already finished, this is a no-op.

get_run_timeline

Get the step-by-step timeline of a run. Each entry represents one AI action with screenshots and reasoning.
timeline = await client.get_run_timeline("tsk_v2_486305187432193504")
for step in timeline:
    print(f"Step {step.order}: {step.type}{step.status}")

Parameters

ParameterTypeRequiredDescription
run_idstrYesThe run ID.

Returns list[WorkflowRunTimeline]

Each timeline entry contains step details including type, status, order, and associated artifacts.

get_run_artifacts

Get all artifacts (screenshots, recordings, generated code, etc.) for a run.
artifacts = await client.get_run_artifacts("tsk_v2_486305187432193504")
for artifact in artifacts:
    print(f"{artifact.artifact_type}: {artifact.uri}")
Filter by type to get specific artifacts:
# Get only the generated Playwright scripts
scripts = await client.get_run_artifacts(
    "tsk_v2_486305187432193504",
    artifact_type=["script_file"],
)

Parameters

ParameterTypeRequiredDescription
run_idstrYesThe run ID.
artifact_typeArtifactType | list[ArtifactType]NoFilter by artifact type.

Returns list[Artifact]


get_artifact

Get a single artifact by ID.
artifact = await client.get_artifact("art_486305187432193504")
print(artifact.uri)

Parameters

ParameterTypeRequiredDescription
artifact_idstrYesThe artifact ID.

Returns Artifact


retry_run_webhook

Re-send the webhook notification for a completed run. Useful if your webhook endpoint was down when the run finished.
await client.retry_run_webhook("tsk_v2_486305187432193504")

Parameters

ParameterTypeRequiredDescription
run_idstrYesThe run ID.

Polling pattern

If you don’t use wait_for_completion, poll get_run manually:
import asyncio

task = await client.run_task(
    prompt="Extract product data",
    url="https://example.com/products",
)

while True:
    run = await client.get_run(task.run_id)
    if run.status in ("completed", "failed", "terminated", "timed_out", "canceled"):
        break
    await asyncio.sleep(5)

print(run.output)
For production, prefer wait_for_completion=True or webhooks over manual polling.