> ## Documentation Index
> Fetch the complete documentation index at: https://notte-docs-anything-api-v2.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# run

<Tip>
  STOP. Do not read past this section until you have read and followed [/quickstart.md](/quickstart.md).

  Goal: produce a reliable SDK automation script. The intended authoring flow is generate then edit, not write browser automation from scratch.

  Do not hand-write SDK code with element IDs, selectors, or form fields from memory. Element IDs, selectors, and field mappings must come from a live `observe()` call, CLI `notte page observe` output, or generated workflow code. Guessed browser targets fail on real pages.

  Use the Notte skill and CLI to inspect the live site, validate actions/selectors, handle auth/session state, and export workflow code with `notte sessions workflow-code` before using SDK docs or SDK code.

  SDK reference pages are for understanding, running, or editing generated workflow code. They are not the starting point for manually authoring the initial browser automation. SDK-first code is guesswork on real-world pages with dynamic selectors, auth state, CAPTCHAs, and anti-bot behavior.
</Tip>

[Source: node-sdk/src/functions.ts](https://github.com/nottelabs/notte/blob/main/node-sdk/src/functions.ts)

Run the function on the cloud and wait for its result, streaming logs by
default like `function.run(**variables)` in Python.

Pass `{ stream: false }` to receive the backend's JSON response without
live logs; execution still blocks until completion. Pass `functionRunId`
to execute a record returned by `createRun()`; otherwise a new run record
is created first, exactly like Python. A failed execution throws
`FailedToRunCloudFunctionError` unless `raiseOnFailure` is false, and the
wait is aborted with `NotteTimeoutError` after `timeoutMs`.

```typescript theme={null}
NotteFunction.run(variables?: Record<string, unknown>, options?: FunctionRunOptions): Promise<FunctionRunResult>;
```

## Parameters

<ParamField body="variables" type={"Record<string, unknown>"}>
  JSON-serializable keyword arguments passed to the Python function's `run` entry point.

  Default:

  ```typescript theme={null}
  {}
  ```
</ParamField>

<ParamField body="options" type={"FunctionRunOptions"}>
  Log streaming, failure handling, runtime, run ID, and timeout settings.

  Default:

  ```typescript theme={null}
  {}
  ```
</ParamField>

## Returns

```typescript theme={null}
Promise<FunctionRunResult>
```

The completed execution response. The function's return value is in `result`. Disabling streaming still waits for completion.

## Raises

* FailedToRunCloudFunctionError if execution fails and `raiseOnFailure` is true.
* NotteTimeoutError if the execution request exceeds `timeoutMs`.
* InvalidRequestError if the run options are invalid.

## Example

```typescript theme={null}
const result = await fn.run({ url: 'https://example.com' });
console.log(result.result);

await fn.run({ url: 'https://example.com' }, { runtime: 'extended', onLog: line => logger.info(line) });
```

## Related types

* [FunctionRunOptions](/typescript-sdk-reference/types/functionrunoptions)
* [FunctionRunResult](/typescript-sdk-reference/types/functionrunresult)
