Skip to main content
GET
/
v1
/
sessions
/
{session_id}
/
screenshot
Get Screenshot
curl --request GET \
  --url https://api.example.com/v1/sessions/{session_id}/screenshot \
  --header 'Authorization: <authorization>'
{
  "screenshot": "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQ...",
  "url": "https://www.kayak.com/flights",
  "title": "KAYAK: Flights"
}

Overview

Capture a screenshot of the current browser state. Useful for debugging, monitoring progress, or verifying page state after operations.

Request

session_id
string
required
The UUID of the session
Authorization
string
required
Bearer token for authentication

Response

screenshot
string
Base64-encoded JPEG image as a data URLFormat: data:image/jpeg;base64,/9j/4AAQSkZJRg...
url
string
Current page URL
title
string
Current page title
{
  "screenshot": "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQ...",
  "url": "https://www.kayak.com/flights",
  "title": "KAYAK: Flights"
}

Example

curl https://api.agi.tech/v1/sessions/<session_id>/screenshot \
  -H "Authorization: Bearer $AGI_API_KEY"

Use Cases

Visual Debugging

# Take screenshot at key points
send_message(session_id, "Add item to cart")
time.sleep(5)

screenshot, info = get_screenshot(session_id)
screenshot.save("after_add_to_cart.jpg")
print(f"Currently on: {info['title']}")

Progress Monitoring

# Capture screenshots during long task
def monitor_with_screenshots(session_id, interval=10):
    start_time = time.time()
    screenshot_count = 0

    while True:
        status = get_status(session_id)

        if status in ["finished", "error"]:
            break

        # Capture periodic screenshots
        if int(time.time() - start_time) % interval == 0:
            screenshot_count += 1
            get_screenshot(session_id, f"progress_{screenshot_count}.jpg")

        time.sleep(1)

Screenshot Verification

# Verify successful form submission
send_message(session_id, "Submit the contact form")
time.sleep(3)

screenshot, info = get_screenshot(session_id)

# Check if on success page
if "success" in info['url'].lower() or "thank" in info['title'].lower():
    print("Form submitted successfully")
else:
    print("Submission may have failed")

Best Practices

Screenshots are useful for debugging and verification, but avoid excessive calls as they can be resource-intensive.
Use screenshots strategically at key decision points rather than continuously polling.