# GenLayer gl.nondet.web.render() Modes: text, html, and screenshot Explained

> Explore gl nondet web render modes text html and screenshot in GenLayer. Learn how to fetch web content as plain text raw HTML or a visual image for your contracts.

- Repository: [GenLayer Labs/genlayer-project-boilerplate](https://github.com/genlayerlabs/genlayer-project-boilerplate)
- Tags: deep-dive
- Published: 2026-08-20

---

**The `gl.nondet.web.render()` function supports three rendering modes—`text`, `html`, and `screenshot`—allowing GenLayer contracts to retrieve web content as plain text, raw HTML, or a visual image.**

The `gl.nondet.web.render()` method in the GenLayer SDK enables smart contracts to fetch external web data for processing within the GenLayer environment. As documented in the `genlayerlabs/genlayer-project-boilerplate` repository, this nondeterministic function accepts a target URL and a `mode` parameter to specify the desired output format. Each mode returns a different data type optimized for specific contract logic, from text analysis to visual verification.

## Overview of gl.nondet.web.render() Modes

According to the SDK reference in [`CLAUDE.md`](https://github.com/genlayerlabs/genlayer-project-boilerplate/blob/main/CLAUDE.md), `gl.nondet.web.render()` accepts three distinct string values for the `mode` parameter:

- **`text`** – Returns a `str` containing the page's plain-text content with HTML tags stripped
- **`html`** – Returns a `str` containing the full raw HTML source of the page  
- **`screenshot`** – Returns an `Image` object representing a visual capture of the rendered page

These modes give developers precise control over how web data enters the contract execution context.

## The Three Rendering Modes Explained

### text Mode

The `text` mode extracts readable content from a web page by removing HTML markup, making it ideal for natural language processing tasks. When you call `gl.nondet.web.render(url, mode="text")`, the function returns a Python string containing the article body or page text without script tags, styles, or markup.

This mode appears in production contracts such as [`contracts/football_bets.py`](https://github.com/genlayerlabs/genlayer-project-boilerplate/blob/main/contracts/football_bets.py), where contracts scrape readable information from sports websites.

### html Mode

Use the `html` mode when your contract requires parsing raw markup, extracting specific DOM elements, or verifying page structure. Invoking `gl.nondet.web.render(url, mode="html")` returns the complete HTML source as a string, including all tags, attributes, and embedded scripts.

This mode suits contracts that perform structured data extraction or checksum validation against page source.

### screenshot Mode

The `screenshot` mode captures a visual rendering of the web page as an `Image` object. This enables computer vision workflows, UI verification, or oracle logic based on visual state rather than text content.

The integration test file [`tests/integration/test_new_features.py`](https://github.com/genlayerlabs/genlayer-project-boilerplate/blob/main/tests/integration/test_new_features.py) demonstrates this capability, showing how contracts can pass image data to LLM prompts for visual analysis.

## Code Implementation Examples

### Fetching Plain Text Content

To extract readable text from an article or documentation page:

```python
url = "https://example.com/article"
page_text = gl.nondet.web.render(url, mode="text")

# Returns: str containing "Article Title\n\nArticle body content..."

```

### Retrieving Raw HTML

To access the full page source for parsing or validation:

```python
url = "https://example.com/page"
raw_html = gl.nondet.web.render(url, mode="html")

# Returns: str containing "<!DOCTYPE html><html>...</html>"

```

### Capturing Visual Screenshots

To obtain an image representation of a dashboard or visual element:

```python
url = "https://example.com/dashboard"
screenshot = gl.nondet.web.render(url, mode="screenshot")

# Returns: Image object compatible with LLM vision inputs

```

### Integrating render() in Smart Contracts

Combine `gl.nondet.web.render()` with LLM calls for autonomous web analysis:

```python
class ScraperContract(gl.Contract):
    @gl.public.view
    def get_page_summary(self, target_url: str) -> str:
        # Retrieve page as plain text

        page_text = gl.nondet.web.render(target_url, mode="text")
        
        # Process with LLM

        summary = gl.nondet.exec_prompt(
            f"Summarize this text in one sentence:\n{page_text}",
            response_format="text"
        )
        return summary

```

## Source Code Reference

The implementation and usage patterns for `gl.nondet.web.render()` appear in the following repository files:

- **[`CLAUDE.md`](https://github.com/genlayerlabs/genlayer-project-boilerplate/blob/main/CLAUDE.md)** – Contains the official SDK documentation defining the three modes and their return types
- **[`contracts/football_bets.py`](https://github.com/genlayerlabs/genlayer-project-boilerplate/blob/main/contracts/football_bets.py)** – Demonstrates production usage of `mode="text"` for scraping sports data
- **[`tests/integration/test_new_features.py`](https://github.com/genlayerlabs/genlayer-project-boilerplate/blob/main/tests/integration/test_new_features.py)** – Shows integration testing for `mode="screenshot"` functionality

These files illustrate how the GenLayer SDK handles nondeterministic web access across different rendering formats.

## Summary

- **`gl.nondet.web.render()`** provides three modes—`text`, `html`, and `screenshot`—for retrieving web content in GenLayer contracts
- **`text` mode** returns clean, HTML-stripped strings suitable for NLP tasks
- **`html` mode** returns raw source markup for structural parsing
- **`screenshot` mode** returns `Image` objects enabling visual verification and computer vision workflows
- All modes are documented in [`CLAUDE.md`](https://github.com/genlayerlabs/genlayer-project-boilerplate/blob/main/CLAUDE.md) and implemented in the `genlayer-project-boilerplate` repository

## Frequently Asked Questions

### What are the valid mode values for gl.nondet.web.render()?

The function accepts exactly three string values for the `mode` parameter: `"text"` for plain content extraction, `"html"` for raw markup retrieval, and `"screenshot"` for visual image capture. Each mode returns a different Python type (`str`, `str`, or `Image` respectively).

### How does the screenshot mode return image data?

When invoked with `mode="screenshot"`, `gl.nondet.web.render()` returns an `Image` object rather than a string. This object can be passed directly to LLM vision capabilities within the GenLayer environment or used for on-chain visual verification logic.

### Which source files demonstrate gl.nondet.web.render() usage?

The `genlayer-project-boilerplate` repository contains three key references: [`CLAUDE.md`](https://github.com/genlayerlabs/genlayer-project-boilerplate/blob/main/CLAUDE.md) documents the API specification, [`contracts/football_bets.py`](https://github.com/genlayerlabs/genlayer-project-boilerplate/blob/main/contracts/football_bets.py) shows `text` mode in a production contract, and [`tests/integration/test_new_features.py`](https://github.com/genlayerlabs/genlayer-project-boilerplate/blob/main/tests/integration/test_new_features.py) validates the `screenshot` mode in integration tests.

### Can gl.nondet.web.render() be used in public contract methods?

Yes, as demonstrated in [`contracts/football_bets.py`](https://github.com/genlayerlabs/genlayer-project-boilerplate/blob/main/contracts/football_bets.py) and the example `ScraperContract`, `gl.nondet.web.render()` can be invoked within `@gl.public.view` methods. Because it is a **nondeterministic** operation, the GenLayer network reaches consensus on the result through its LLM-based validation mechanism.