AI Evaluate (Stream)
curl --request POST \
--url https://api.example.com/browser/sessions/{id}/ai/evaluate/stream \
--header 'Content-Type: application/json' \
--data '
{
"prompt": "<string>",
"mode": "<string>",
"maxSteps": 123,
"model": "<string>",
"schema": {}
}
'import requests
url = "https://api.example.com/browser/sessions/{id}/ai/evaluate/stream"
payload = {
"prompt": "<string>",
"mode": "<string>",
"maxSteps": 123,
"model": "<string>",
"schema": {}
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
prompt: '<string>',
mode: '<string>',
maxSteps: 123,
model: '<string>',
schema: {}
})
};
fetch('https://api.example.com/browser/sessions/{id}/ai/evaluate/stream', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/browser/sessions/{id}/ai/evaluate/stream",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'prompt' => '<string>',
'mode' => '<string>',
'maxSteps' => 123,
'model' => '<string>',
'schema' => [
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/browser/sessions/{id}/ai/evaluate/stream"
payload := strings.NewReader("{\n \"prompt\": \"<string>\",\n \"mode\": \"<string>\",\n \"maxSteps\": 123,\n \"model\": \"<string>\",\n \"schema\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/browser/sessions/{id}/ai/evaluate/stream")
.header("Content-Type", "application/json")
.body("{\n \"prompt\": \"<string>\",\n \"mode\": \"<string>\",\n \"maxSteps\": 123,\n \"model\": \"<string>\",\n \"schema\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/browser/sessions/{id}/ai/evaluate/stream")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"prompt\": \"<string>\",\n \"mode\": \"<string>\",\n \"maxSteps\": 123,\n \"model\": \"<string>\",\n \"schema\": {}\n}"
response = http.request(request)
puts response.read_bodyAI
AI Evaluate (Stream)
Stream an AI evaluation against the current page as Server-Sent Events in an OpenAI-compatible format.
POST
/
browser
/
sessions
/
{id}
/
ai
/
evaluate
/
stream
AI Evaluate (Stream)
curl --request POST \
--url https://api.example.com/browser/sessions/{id}/ai/evaluate/stream \
--header 'Content-Type: application/json' \
--data '
{
"prompt": "<string>",
"mode": "<string>",
"maxSteps": 123,
"model": "<string>",
"schema": {}
}
'import requests
url = "https://api.example.com/browser/sessions/{id}/ai/evaluate/stream"
payload = {
"prompt": "<string>",
"mode": "<string>",
"maxSteps": 123,
"model": "<string>",
"schema": {}
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
prompt: '<string>',
mode: '<string>',
maxSteps: 123,
model: '<string>',
schema: {}
})
};
fetch('https://api.example.com/browser/sessions/{id}/ai/evaluate/stream', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/browser/sessions/{id}/ai/evaluate/stream",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'prompt' => '<string>',
'mode' => '<string>',
'maxSteps' => 123,
'model' => '<string>',
'schema' => [
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/browser/sessions/{id}/ai/evaluate/stream"
payload := strings.NewReader("{\n \"prompt\": \"<string>\",\n \"mode\": \"<string>\",\n \"maxSteps\": 123,\n \"model\": \"<string>\",\n \"schema\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/browser/sessions/{id}/ai/evaluate/stream")
.header("Content-Type", "application/json")
.body("{\n \"prompt\": \"<string>\",\n \"mode\": \"<string>\",\n \"maxSteps\": 123,\n \"model\": \"<string>\",\n \"schema\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/browser/sessions/{id}/ai/evaluate/stream")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"prompt\": \"<string>\",\n \"mode\": \"<string>\",\n \"maxSteps\": 123,\n \"model\": \"<string>\",\n \"schema\": {}\n}"
response = http.request(request)
puts response.read_bodyOverview
Same input asPOST /browser/sessions/{id}/ai/evaluate, but the response is a long-lived Server-Sent Events stream. Response Content-Type is text/event-stream.
Each chunk follows the OpenAI Chat Completions streaming shape — a data: line carrying a JSON object, separated by a blank line. The stream terminates with data: [DONE].
Path Parameters
string
required
Browser session ID (UUID).
Body
Same shape as the non-streaming endpoint.string
required
Natural-language instruction for the model.
string
default:"simple"
One of
simple, agent.integer
default:"20"
Agent-mode step cap.
string
Explicit LLM model ID.
object
JSON schema for structured output.
Example Request
curl -N -X POST "https://api.scrapengine.io/api/v1/browser/sessions/baa3f390-fa6e-4a24-b84a-a575a5f3a9c7/ai/evaluate/stream" \
-H "Authorization: Bearer $SCRAPENGINE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"prompt": "Summarize this page in 3 bullets.",
"mode": "simple"
}'
Response
Success Response (200)
Content-Type: text/event-streamCache-Control: no-cacheConnection: keep-alive
data: {"id":"agent-baa3f390","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"role":"assistant"}}]}
data: {"id":"agent-baa3f390","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"content":"- Example"}}]}
data: {"id":"agent-baa3f390","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"content":" Domain is..."}}]}
data: {"id":"agent-baa3f390","object":"chat.completion.chunk","choices":[{"index":0,"delta":{},"finish_reason":"stop"}]}
data: [DONE]
delta.content: "Error: ..." and finish_reason: "stop", followed by data: [DONE].
Error Responses
| Status | Description |
|---|---|
400 | Invalid body — same validations as the non-streaming endpoint. |
401 | Unauthorized — invalid or missing API key. |
404 | Session not found or not owned by the caller. |
Notes
- Use
-N(no-buffer) with cURL to see chunks as they arrive. - Any OpenAI-compatible SSE parser can consume this endpoint.
- For one-shot JSON output without streaming, use
POST /browser/sessions/{id}/ai/evaluate.
Was this page helpful?