Overview
Runs an LLM-driven evaluation against the session’s active page. Two modes:
simple — one-shot: the current page’s DOM + screenshot are sent to the model, which answers the prompt (optionally against a JSON schema).
agent — multi-step: the model can drive the browser, clicking and navigating for up to maxSteps iterations.
For streaming output, use POST /browser/sessions/{id}/ai/evaluate/stream.
Path Parameters
Browser session ID (UUID).
Body
Natural-language instruction for the model.
For agent mode, the maximum number of browser actions the model may take.
Explicit LLM model ID (e.g. claude-sonnet-4-20250514, gpt-4o). Defaults to the account’s configured default.
Optional JSON schema. When supplied, the response result is constrained to match.
Example Request
curl -X POST "https://api.scrapengine.io/api/v1/browser/sessions/baa3f390-fa6e-4a24-b84a-a575a5f3a9c7/ai/evaluate" \
-H "Authorization: Bearer $SCRAPENGINE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"prompt": "Extract the product name and price from this page.",
"schema": {
"type": "object",
"properties": {
"name": { "type": "string" },
"price": { "type": "number" }
},
"required": ["name", "price"]
}
}'
Response
Success Response (200)
True when the evaluation finished. False when it aborted (see error).
Model output. When schema was supplied, conforms to that schema.
Error message when success is false.
Number of browser actions taken (agent mode).
Total tokens consumed by the evaluation.
Example Response:
{
"success": true,
"result": { "name": "Widget Pro", "price": 49.99 },
"model": "claude-sonnet-4-20250514",
"tokensUsed": 1832
}
Error Responses
| Status | Description |
|---|
400 | Invalid body — missing prompt, unknown mode, or malformed schema. |
401 | Unauthorized — invalid or missing API key. |
404 | Session not found or not owned by the caller. |
503 | The model provider or browser session is temporarily unreachable. |