Skip to main content

Overview

Tasks are the fundamental building block in Skyvern. Each task is a single request to Skyvern, instructing it to navigate through a website and accomplish a specific goal. You can create tasks using either the Python SDK, TypeScript SDK, or directly via the REST API.

Creating Tasks with the Python SDK

Basic Task Execution

The simplest way to create and run a task is using the run_task method:
from skyvern import Skyvern

skyvern = Skyvern(api_key="your-api-key")

task = await skyvern.run_task(
    prompt="Find the top post on hackernews today"
)

print(task)

Task with URL and Data Extraction

For more control, specify a starting URL and extract structured data:
from skyvern import Skyvern

skyvern = Skyvern(api_key="your-api-key")

task = await skyvern.run_task(
    prompt="Find the top post on hackernews today",
    url="https://news.ycombinator.com",
    data_extraction_schema={
        "type": "object",
        "properties": {
            "title": {
                "type": "string",
                "description": "The title of the top post"
            },
            "url": {
                "type": "string",
                "description": "The URL of the top post"
            },
            "points": {
                "type": "integer",
                "description": "Number of points the post has received"
            }
        }
    }
)

Waiting for Task Completion

By default, run_task returns immediately. To wait for completion:
task = await skyvern.run_task(
    prompt="Fill out the form and submit it",
    url="https://example.com/form",
    wait_for_completion=True,
    timeout=300.0  # Wait up to 5 minutes
)

print(f"Task status: {task.status}")
print(f"Extracted data: {task.output}")

Using Local Mode

Run Skyvern locally in-process (requires running skyvern quickstart first):
from skyvern import Skyvern

# Local mode - runs Skyvern in-process
skyvern = Skyvern.local()

task = await skyvern.run_task(
    prompt="Get a quote for car insurance",
    url="https://www.geico.com"
)

Creating Tasks with the TypeScript SDK

import { Skyvern } from "@skyvern/client";

const skyvern = new Skyvern({ apiKey: "your-api-key" });

const task = await skyvern.runTask({
  prompt: "Find the top post on hackernews today",
  url: "https://news.ycombinator.com",
  dataExtractionSchema: {
    type: "object",
    properties: {
      title: { type: "string" },
      url: { type: "string" },
      points: { type: "integer" }
    }
  }
});

console.log(task);

Creating Tasks via REST API

API Endpoint

POST https://api.skyvern.com/api/v1/tasks
Content-Type: application/json
Authorization: Bearer YOUR_API_KEY

Request Body

{
  "prompt": "Find the top post on hackernews today",
  "url": "https://news.ycombinator.com",
  "engine": "skyvern-2.0",
  "data_extraction_schema": {
    "type": "object",
    "properties": {
      "title": { "type": "string" },
      "url": { "type": "string" },
      "points": { "type": "integer" }
    }
  }
}

Response

{
  "run_id": "tsk_50da533e-3904-4401-8a07-c49adf88b5eb",
  "status": "created",
  "created_at": "2024-01-01T00:00:00Z",
  "modified_at": "2024-01-01T00:00:00Z",
  "app_url": "https://app.skyvern.com/tasks/tsk_50da533e-3904-4401-8a07-c49adf88b5eb"
}

Task Execution Engines

Skyvern supports multiple execution engines:
  • skyvern-2.0 (default): Latest Skyvern agent, best for complex and multi-step tasks
  • skyvern-1.0: Good for simple tasks like filling forms or searching
  • openai-cua: Uses OpenAI’s Computer Use Agent model
  • anthropic-cua: Uses Anthropic’s Claude Sonnet 3.7 with computer use tool
  • ui-tars: Specialized UI interaction engine
task = await skyvern.run_task(
    prompt="Fill out the contact form",
    url="https://example.com/contact",
    engine=RunEngine.skyvern_v2  # or "skyvern-2.0"
)

Advanced Configuration

Custom LLM Model

Specify a custom model configuration:
task = await skyvern.run_task(
    prompt="Navigate and extract data",
    url="https://example.com",
    model={
        "model_name": "gpt-4o",
        "temperature": 0.7
    }
)

Browser Session Persistence

Run tasks in a persistent browser session:
# Create a browser session
browser = await skyvern.launch_cloud_browser()
page = await browser.get_working_page()

# Run task in this session
task = await skyvern.run_task(
    prompt="Complete the multi-step workflow",
    browser_session_id=browser.browser_session_id
)

Using Webhooks

Receive notifications when tasks complete:
task = await skyvern.run_task(
    prompt="Process the order",
    url="https://example.com/orders",
    webhook_url="https://your-domain.com/webhook"
)

Next Steps

Task Parameters

Learn about all available task parameters and options

Data Extraction

Extract structured data with JSON schemas

Monitoring Runs

Monitor task execution and view results

Build docs developers (and LLMs) love