> ## Documentation Index
> Fetch the complete documentation index at: https://intunedhq.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# isPageLoaded

<Tip>This function uses AI and incurs costs.</Tip>

Uses AI vision to determine if a webpage has finished loading by analyzing a screenshot.
Detects loading spinners, blank content, or incomplete page states.

```typescript theme={null}
export declare function isPageLoaded(input: {
  page: Page;
  timeoutInMs?: number;
  model?: string;
  apiKey?: string;
}): Promise<boolean>;
```

## Examples

<CodeGroup>
  ```typescript Check Page Loading theme={null}
  import { isPageLoaded } from "@intuned/browser/ai";
  import { BrowserContext, Page } from "playwright";

  interface Params {}

  export default async function handler(
    params: Params,
    page: Page,
    context: BrowserContext
  ) {
    // Wait for page to finish loading
    await page.goto("https://sandbox.intuned.dev/");

    const pageLoaded = await isPageLoaded({ page });
    if (pageLoaded) {
      // Continue with scraping or interactions
      console.log("Page is loaded");
    } else {
      // Wait longer or retry
      await page.waitForTimeout(5000);
    }
  }
  ```

  ```typescript Loading Loop theme={null}
  import { isPageLoaded } from "@intuned/browser/ai";
  import { BrowserContext, Page } from "playwright";

  interface Params {}

  export default async function handler(
    params: Params,
    page: Page,
    context: BrowserContext
  ) {
    // Keep checking until page loads
    await page.goto("https://example.com");
    let attempts = 0;
    while (attempts < 10) {
      // We will retry up to 10 times with a 2-second delay between attempts.
      const pageLoaded = await isPageLoaded({
        page,
        model: "claude-sonnet-4-5",
        timeoutInMs: 5000,
      });
      if (pageLoaded) break; // If the page is loaded, break the loop.

      await page.waitForTimeout(2000); // Wait for 2 seconds before the next attempt.
      attempts++;
    }
  }
  ```
</CodeGroup>

## Arguments

<ResponseField name="input" type="Object" required>
  Input object containing the page to check

  <Expandable title="properties" defaultOpen>
    <ResponseField name="input.page" type="Page" required>
      The Playwright page to check
    </ResponseField>

    <ResponseField name="input.timeoutInMs" type="number">
      Screenshot timeout in milliseconds. Defaults to 10000
    </ResponseField>

    <ResponseField name="input.model" type="string">
      AI model to use for the check. Defaults to "gpt-5-mini-2025-08-07"
    </ResponseField>

    <ResponseField name="input.apiKey" type="string">
      Optional API key for the AI call.
    </ResponseField>
  </Expandable>
</ResponseField>

## Returns: `Promise<boolean>`

Promise resolving to true if page is loaded, false if still loading.
