Run a task
POST /api/v1/predict — run one Ostra Decision task (failure triage, test impact or selector survival) and get its decision.
https://ostra.testrelic.ai/api/v1/predictRuns one Ostra Decision task (failure triage, test impact or selector survival) and returns its decision.
Send model: "ostra-lite", the task, and that task’s input. The answer is in output, in the shape for the task. An identical task and input within 24 hours is answered from cache, for free.
- Auth
Authorization: Bearer $OSTRA_API_KEY. Needs a Full-access key.- Rate limit
- Counts against your workspace's requests per minute.
- Cost
- Triage $0.50 per 1M failures; test impact $2.00 per 1M requests; selector survival $0.25 per 1M locators. Output is free. Cached answers and errors cost nothing; a
deferanswer is billed. - Over MCP
- Same operation as the
ostra_triage_failuretool.
curl https://ostra.testrelic.ai/api/v1/predict \
-H "Authorization: Bearer $OSTRA_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"model": "ostra-lite",
"task": "triage",
"input": {
"test_id": "checkout.spec.ts > applies coupon",
"run_id": "gha-18241",
"context": {
"framework": "playwright",
"capture_level": "full",
"error_message": "TimeoutError: locator.click: Timeout 30000ms exceeded.\n waiting for locator('\''#apply-coupon'\'')",
"action": "click",
"locator": {
"strategy": "css"
},
"diff": {
"files_changed": 3,
"lines_added": 41,
"lines_removed": 12,
"touches_test_file": false,
"touches_selector_file": false,
"locator_values_removed": false
},
"dom": {
"locator_found": true
},
"memory": {
"runs_50": 40,
"flake_rate_50": 0.15,
"failed_count_50": 6,
"signature_repeat_count": 5
}
}
}
}'import os
import requests
response = requests.post(
"https://ostra.testrelic.ai/api/v1/predict",
headers={
"Authorization": f"Bearer {os.environ['OSTRA_API_KEY']}",
},
json={
"model": "ostra-lite",
"task": "triage",
"input": {
"test_id": "checkout.spec.ts > applies coupon",
"run_id": "gha-18241",
"context": {
"framework": "playwright",
"capture_level": "full",
"error_message": "TimeoutError: locator.click: Timeout 30000ms exceeded.\n waiting for locator('#apply-coupon')",
"action": "click",
"locator": {
"strategy": "css",
},
"diff": {
"files_changed": 3,
"lines_added": 41,
"lines_removed": 12,
"touches_test_file": False,
"touches_selector_file": False,
"locator_values_removed": False,
},
"dom": {
"locator_found": True,
},
"memory": {
"runs_50": 40,
"flake_rate_50": 0.15,
"failed_count_50": 6,
"signature_repeat_count": 5,
},
},
},
},
timeout=60,
)
response.raise_for_status()
print(response.json())const response = await fetch('https://ostra.testrelic.ai/api/v1/predict', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.OSTRA_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
model: 'ostra-lite',
task: 'triage',
input: {
test_id: 'checkout.spec.ts > applies coupon',
run_id: 'gha-18241',
context: {
framework: 'playwright',
capture_level: 'full',
error_message: 'TimeoutError: locator.click: Timeout 30000ms exceeded.\n waiting for locator(\'#apply-coupon\')',
action: 'click',
locator: {
strategy: 'css',
},
diff: {
files_changed: 3,
lines_added: 41,
lines_removed: 12,
touches_test_file: false,
touches_selector_file: false,
locator_values_removed: false,
},
dom: {
locator_found: true,
},
memory: {
runs_50: 40,
flake_rate_50: 0.15,
failed_count_50: 6,
signature_repeat_count: 5,
},
},
},
}),
});
if (!response.ok) {
throw new Error(`Ostra ${response.status}: ${await response.text()}`);
}
console.log(await response.json());package main
import (
"fmt"
"io"
"net/http"
"os"
"strings"
)
func main() {
body := strings.NewReader(`{
"model": "ostra-lite",
"task": "triage",
"input": {
"test_id": "checkout.spec.ts > applies coupon",
"run_id": "gha-18241",
"context": {
"framework": "playwright",
"capture_level": "full",
"error_message": "TimeoutError: locator.click: Timeout 30000ms exceeded.\n waiting for locator('#apply-coupon')",
"action": "click",
"locator": {
"strategy": "css"
},
"diff": {
"files_changed": 3,
"lines_added": 41,
"lines_removed": 12,
"touches_test_file": false,
"touches_selector_file": false,
"locator_values_removed": false
},
"dom": {
"locator_found": true
},
"memory": {
"runs_50": 40,
"flake_rate_50": 0.15,
"failed_count_50": 6,
"signature_repeat_count": 5
}
}
}
}`)
req, err := http.NewRequest("POST", "https://ostra.testrelic.ai/api/v1/predict", body)
if err != nil {
panic(err)
}
req.Header.Set("Authorization", "Bearer "+os.Getenv("OSTRA_API_KEY"))
req.Header.Set("Content-Type", "application/json")
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
out, err := io.ReadAll(res.Body)
if err != nil {
panic(err)
}
fmt.Println(res.Status)
fmt.Println(string(out))
}import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class OstraExample {
public static void main(String[] args) throws Exception {
String body = """
{
"model": "ostra-lite",
"task": "triage",
"input": {
"test_id": "checkout.spec.ts > applies coupon",
"run_id": "gha-18241",
"context": {
"framework": "playwright",
"capture_level": "full",
"error_message": "TimeoutError: locator.click: Timeout 30000ms exceeded.\\n waiting for locator('#apply-coupon')",
"action": "click",
"locator": {
"strategy": "css"
},
"diff": {
"files_changed": 3,
"lines_added": 41,
"lines_removed": 12,
"touches_test_file": false,
"touches_selector_file": false,
"locator_values_removed": false
},
"dom": {
"locator_found": true
},
"memory": {
"runs_50": 40,
"flake_rate_50": 0.15,
"failed_count_50": 6,
"signature_repeat_count": 5
}
}
}
}
""";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://ostra.testrelic.ai/api/v1/predict"))
.header("Authorization", "Bearer " + System.getenv("OSTRA_API_KEY"))
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(body))
.build();
HttpResponse<String> response = HttpClient.newHttpClient()
.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.statusCode());
System.out.println(response.body());
}
}using System.Net.Http.Headers;
using System.Text;
using var client = new HttpClient();
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("OSTRA_API_KEY"));
using var request = new HttpRequestMessage(HttpMethod.Post, "https://ostra.testrelic.ai/api/v1/predict");
request.Content = new StringContent(
"""
{
"model": "ostra-lite",
"task": "triage",
"input": {
"test_id": "checkout.spec.ts > applies coupon",
"run_id": "gha-18241",
"context": {
"framework": "playwright",
"capture_level": "full",
"error_message": "TimeoutError: locator.click: Timeout 30000ms exceeded.\n waiting for locator('#apply-coupon')",
"action": "click",
"locator": {
"strategy": "css"
},
"diff": {
"files_changed": 3,
"lines_added": 41,
"lines_removed": 12,
"touches_test_file": false,
"touches_selector_file": false,
"locator_values_removed": false
},
"dom": {
"locator_found": true
},
"memory": {
"runs_50": 40,
"flake_rate_50": 0.15,
"failed_count_50": 6,
"signature_repeat_count": 5
}
}
}
}
""",
Encoding.UTF8,
"application/json");
using var response = await client.SendAsync(request);
Console.WriteLine((int)response.StatusCode);
Console.WriteLine(await response.Content.ReadAsStringAsync());require "net/http"
require "uri"
uri = URI("https://ostra.testrelic.ai/api/v1/predict")
request = Net::HTTP::Post.new(uri)
request["Authorization"] = "Bearer #{ENV.fetch("OSTRA_API_KEY")}"
request["Content-Type"] = "application/json"
request.body = <<~'JSON'
{
"model": "ostra-lite",
"task": "triage",
"input": {
"test_id": "checkout.spec.ts > applies coupon",
"run_id": "gha-18241",
"context": {
"framework": "playwright",
"capture_level": "full",
"error_message": "TimeoutError: locator.click: Timeout 30000ms exceeded.\n waiting for locator('#apply-coupon')",
"action": "click",
"locator": {
"strategy": "css"
},
"diff": {
"files_changed": 3,
"lines_added": 41,
"lines_removed": 12,
"touches_test_file": false,
"touches_selector_file": false,
"locator_values_removed": false
},
"dom": {
"locator_found": true
},
"memory": {
"runs_50": 40,
"flake_rate_50": 0.15,
"failed_count_50": 6,
"signature_repeat_count": 5
}
}
}
}
JSON
response = Net::HTTP.start(uri.host, uri.port, use_ssl: true) { |http| http.request(request) }
puts response.code
puts response.body<?php
$ch = curl_init("https://ostra.testrelic.ai/api/v1/predict");
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
"Authorization: Bearer " . getenv("OSTRA_API_KEY"),
"Content-Type: application/json",
],
CURLOPT_POSTFIELDS => <<<'JSON'
{
"model": "ostra-lite",
"task": "triage",
"input": {
"test_id": "checkout.spec.ts > applies coupon",
"run_id": "gha-18241",
"context": {
"framework": "playwright",
"capture_level": "full",
"error_message": "TimeoutError: locator.click: Timeout 30000ms exceeded.\n waiting for locator('#apply-coupon')",
"action": "click",
"locator": {
"strategy": "css"
},
"diff": {
"files_changed": 3,
"lines_added": 41,
"lines_removed": 12,
"touches_test_file": false,
"touches_selector_file": false,
"locator_values_removed": false
},
"dom": {
"locator_found": true
},
"memory": {
"runs_50": 40,
"flake_rate_50": 0.15,
"failed_count_50": 6,
"signature_repeat_count": 5
}
}
}
}
JSON,
]);
$response = curl_exec($ch);
echo curl_getinfo($ch, CURLINFO_HTTP_CODE), PHP_EOL;
echo $response, PHP_EOL;# The same task over MCP (JSON-RPC tools/call)
curl https://ostra.testrelic.ai/mcp \
-H "Authorization: Bearer $OSTRA_API_KEY" \
-H 'Content-Type: application/json' \
-H 'Accept: application/json, text/event-stream' \
-H 'MCP-Protocol-Version: 2025-06-18' \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "ostra_triage_failure",
"arguments": {
"test_id": "checkout.spec.ts > applies coupon",
"run_id": "gha-18241",
"context": {
"framework": "playwright",
"capture_level": "full",
"error_message": "TimeoutError: locator.click: Timeout 30000ms exceeded.\n waiting for locator('\''#apply-coupon'\'')",
"action": "click",
"locator": {
"strategy": "css"
},
"diff": {
"files_changed": 3,
"lines_added": 41,
"lines_removed": 12,
"touches_test_file": false,
"touches_selector_file": false,
"locator_values_removed": false
},
"dom": {
"locator_found": true
},
"memory": {
"runs_50": 40,
"flake_rate_50": 0.15,
"failed_count_50": 6,
"signature_repeat_count": 5
}
}
}
}
}'curl https://ostra.testrelic.ai/api/v1/predict \
-H "Authorization: Bearer $OSTRA_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"model": "ostra-lite",
"task": "test_impact",
"input": {
"diff": {
"files_changed": 2,
"lines_added": 87,
"lines_removed": 14,
"touches_test_file": false,
"touches_selector_file": false
},
"candidates": [
{
"test_id": "checkout.spec.ts > applies coupon",
"co_change_rate": 0.62,
"historical_fail_rate": 0.08
},
{
"test_id": "checkout.spec.ts > rejects expired coupon",
"co_change_rate": 0.58,
"historical_fail_rate": 0.03
},
{
"test_id": "search.spec.ts > filters by brand",
"co_change_rate": 0.02,
"historical_fail_rate": 0.04
}
]
}
}'import os
import requests
response = requests.post(
"https://ostra.testrelic.ai/api/v1/predict",
headers={
"Authorization": f"Bearer {os.environ['OSTRA_API_KEY']}",
},
json={
"model": "ostra-lite",
"task": "test_impact",
"input": {
"diff": {
"files_changed": 2,
"lines_added": 87,
"lines_removed": 14,
"touches_test_file": False,
"touches_selector_file": False,
},
"candidates": [
{
"test_id": "checkout.spec.ts > applies coupon",
"co_change_rate": 0.62,
"historical_fail_rate": 0.08,
},
{
"test_id": "checkout.spec.ts > rejects expired coupon",
"co_change_rate": 0.58,
"historical_fail_rate": 0.03,
},
{
"test_id": "search.spec.ts > filters by brand",
"co_change_rate": 0.02,
"historical_fail_rate": 0.04,
},
],
},
},
timeout=60,
)
response.raise_for_status()
print(response.json())const response = await fetch('https://ostra.testrelic.ai/api/v1/predict', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.OSTRA_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
model: 'ostra-lite',
task: 'test_impact',
input: {
diff: {
files_changed: 2,
lines_added: 87,
lines_removed: 14,
touches_test_file: false,
touches_selector_file: false,
},
candidates: [
{
test_id: 'checkout.spec.ts > applies coupon',
co_change_rate: 0.62,
historical_fail_rate: 0.08,
},
{
test_id: 'checkout.spec.ts > rejects expired coupon',
co_change_rate: 0.58,
historical_fail_rate: 0.03,
},
{
test_id: 'search.spec.ts > filters by brand',
co_change_rate: 0.02,
historical_fail_rate: 0.04,
},
],
},
}),
});
if (!response.ok) {
throw new Error(`Ostra ${response.status}: ${await response.text()}`);
}
console.log(await response.json());package main
import (
"fmt"
"io"
"net/http"
"os"
"strings"
)
func main() {
body := strings.NewReader(`{
"model": "ostra-lite",
"task": "test_impact",
"input": {
"diff": {
"files_changed": 2,
"lines_added": 87,
"lines_removed": 14,
"touches_test_file": false,
"touches_selector_file": false
},
"candidates": [
{
"test_id": "checkout.spec.ts > applies coupon",
"co_change_rate": 0.62,
"historical_fail_rate": 0.08
},
{
"test_id": "checkout.spec.ts > rejects expired coupon",
"co_change_rate": 0.58,
"historical_fail_rate": 0.03
},
{
"test_id": "search.spec.ts > filters by brand",
"co_change_rate": 0.02,
"historical_fail_rate": 0.04
}
]
}
}`)
req, err := http.NewRequest("POST", "https://ostra.testrelic.ai/api/v1/predict", body)
if err != nil {
panic(err)
}
req.Header.Set("Authorization", "Bearer "+os.Getenv("OSTRA_API_KEY"))
req.Header.Set("Content-Type", "application/json")
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
out, err := io.ReadAll(res.Body)
if err != nil {
panic(err)
}
fmt.Println(res.Status)
fmt.Println(string(out))
}import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class OstraExample {
public static void main(String[] args) throws Exception {
String body = """
{
"model": "ostra-lite",
"task": "test_impact",
"input": {
"diff": {
"files_changed": 2,
"lines_added": 87,
"lines_removed": 14,
"touches_test_file": false,
"touches_selector_file": false
},
"candidates": [
{
"test_id": "checkout.spec.ts > applies coupon",
"co_change_rate": 0.62,
"historical_fail_rate": 0.08
},
{
"test_id": "checkout.spec.ts > rejects expired coupon",
"co_change_rate": 0.58,
"historical_fail_rate": 0.03
},
{
"test_id": "search.spec.ts > filters by brand",
"co_change_rate": 0.02,
"historical_fail_rate": 0.04
}
]
}
}
""";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://ostra.testrelic.ai/api/v1/predict"))
.header("Authorization", "Bearer " + System.getenv("OSTRA_API_KEY"))
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(body))
.build();
HttpResponse<String> response = HttpClient.newHttpClient()
.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.statusCode());
System.out.println(response.body());
}
}using System.Net.Http.Headers;
using System.Text;
using var client = new HttpClient();
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("OSTRA_API_KEY"));
using var request = new HttpRequestMessage(HttpMethod.Post, "https://ostra.testrelic.ai/api/v1/predict");
request.Content = new StringContent(
"""
{
"model": "ostra-lite",
"task": "test_impact",
"input": {
"diff": {
"files_changed": 2,
"lines_added": 87,
"lines_removed": 14,
"touches_test_file": false,
"touches_selector_file": false
},
"candidates": [
{
"test_id": "checkout.spec.ts > applies coupon",
"co_change_rate": 0.62,
"historical_fail_rate": 0.08
},
{
"test_id": "checkout.spec.ts > rejects expired coupon",
"co_change_rate": 0.58,
"historical_fail_rate": 0.03
},
{
"test_id": "search.spec.ts > filters by brand",
"co_change_rate": 0.02,
"historical_fail_rate": 0.04
}
]
}
}
""",
Encoding.UTF8,
"application/json");
using var response = await client.SendAsync(request);
Console.WriteLine((int)response.StatusCode);
Console.WriteLine(await response.Content.ReadAsStringAsync());require "net/http"
require "uri"
uri = URI("https://ostra.testrelic.ai/api/v1/predict")
request = Net::HTTP::Post.new(uri)
request["Authorization"] = "Bearer #{ENV.fetch("OSTRA_API_KEY")}"
request["Content-Type"] = "application/json"
request.body = <<~'JSON'
{
"model": "ostra-lite",
"task": "test_impact",
"input": {
"diff": {
"files_changed": 2,
"lines_added": 87,
"lines_removed": 14,
"touches_test_file": false,
"touches_selector_file": false
},
"candidates": [
{
"test_id": "checkout.spec.ts > applies coupon",
"co_change_rate": 0.62,
"historical_fail_rate": 0.08
},
{
"test_id": "checkout.spec.ts > rejects expired coupon",
"co_change_rate": 0.58,
"historical_fail_rate": 0.03
},
{
"test_id": "search.spec.ts > filters by brand",
"co_change_rate": 0.02,
"historical_fail_rate": 0.04
}
]
}
}
JSON
response = Net::HTTP.start(uri.host, uri.port, use_ssl: true) { |http| http.request(request) }
puts response.code
puts response.body<?php
$ch = curl_init("https://ostra.testrelic.ai/api/v1/predict");
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
"Authorization: Bearer " . getenv("OSTRA_API_KEY"),
"Content-Type: application/json",
],
CURLOPT_POSTFIELDS => <<<'JSON'
{
"model": "ostra-lite",
"task": "test_impact",
"input": {
"diff": {
"files_changed": 2,
"lines_added": 87,
"lines_removed": 14,
"touches_test_file": false,
"touches_selector_file": false
},
"candidates": [
{
"test_id": "checkout.spec.ts > applies coupon",
"co_change_rate": 0.62,
"historical_fail_rate": 0.08
},
{
"test_id": "checkout.spec.ts > rejects expired coupon",
"co_change_rate": 0.58,
"historical_fail_rate": 0.03
},
{
"test_id": "search.spec.ts > filters by brand",
"co_change_rate": 0.02,
"historical_fail_rate": 0.04
}
]
}
}
JSON,
]);
$response = curl_exec($ch);
echo curl_getinfo($ch, CURLINFO_HTTP_CODE), PHP_EOL;
echo $response, PHP_EOL;# The same task over MCP (JSON-RPC tools/call)
curl https://ostra.testrelic.ai/mcp \
-H "Authorization: Bearer $OSTRA_API_KEY" \
-H 'Content-Type: application/json' \
-H 'Accept: application/json, text/event-stream' \
-H 'MCP-Protocol-Version: 2025-06-18' \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "ostra_select_impacted_tests",
"arguments": {
"diff": {
"files_changed": 2,
"lines_added": 87,
"lines_removed": 14,
"touches_test_file": false,
"touches_selector_file": false
},
"candidates": [
{
"test_id": "checkout.spec.ts > applies coupon",
"co_change_rate": 0.62,
"historical_fail_rate": 0.08
},
{
"test_id": "checkout.spec.ts > rejects expired coupon",
"co_change_rate": 0.58,
"historical_fail_rate": 0.03
},
{
"test_id": "search.spec.ts > filters by brand",
"co_change_rate": 0.02,
"historical_fail_rate": 0.04
}
]
}
}
}'curl https://ostra.testrelic.ai/api/v1/predict \
-H "Authorization: Bearer $OSTRA_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"model": "ostra-lite",
"task": "selector_survival",
"input": {
"locators": [
{
"locator_id": "checkout.apply-coupon",
"strategy": "css",
"dom_locator_found": true,
"history": [
{
"release": "2026.10.1",
"resolve_rate": 1
},
{
"release": "2026.10.2",
"resolve_rate": 0.92
},
{
"release": "2026.11.1",
"resolve_rate": 0.71
}
]
},
{
"locator_id": "nav.account-menu",
"strategy": "role",
"dom_locator_found": true,
"history": [
{
"release": "2026.10.2",
"resolve_rate": 1
},
{
"release": "2026.11.1",
"resolve_rate": 1
}
]
}
]
}
}'import os
import requests
response = requests.post(
"https://ostra.testrelic.ai/api/v1/predict",
headers={
"Authorization": f"Bearer {os.environ['OSTRA_API_KEY']}",
},
json={
"model": "ostra-lite",
"task": "selector_survival",
"input": {
"locators": [
{
"locator_id": "checkout.apply-coupon",
"strategy": "css",
"dom_locator_found": True,
"history": [
{
"release": "2026.10.1",
"resolve_rate": 1,
},
{
"release": "2026.10.2",
"resolve_rate": 0.92,
},
{
"release": "2026.11.1",
"resolve_rate": 0.71,
},
],
},
{
"locator_id": "nav.account-menu",
"strategy": "role",
"dom_locator_found": True,
"history": [
{
"release": "2026.10.2",
"resolve_rate": 1,
},
{
"release": "2026.11.1",
"resolve_rate": 1,
},
],
},
],
},
},
timeout=60,
)
response.raise_for_status()
print(response.json())const response = await fetch('https://ostra.testrelic.ai/api/v1/predict', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.OSTRA_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
model: 'ostra-lite',
task: 'selector_survival',
input: {
locators: [
{
locator_id: 'checkout.apply-coupon',
strategy: 'css',
dom_locator_found: true,
history: [
{
release: '2026.10.1',
resolve_rate: 1,
},
{
release: '2026.10.2',
resolve_rate: 0.92,
},
{
release: '2026.11.1',
resolve_rate: 0.71,
},
],
},
{
locator_id: 'nav.account-menu',
strategy: 'role',
dom_locator_found: true,
history: [
{
release: '2026.10.2',
resolve_rate: 1,
},
{
release: '2026.11.1',
resolve_rate: 1,
},
],
},
],
},
}),
});
if (!response.ok) {
throw new Error(`Ostra ${response.status}: ${await response.text()}`);
}
console.log(await response.json());package main
import (
"fmt"
"io"
"net/http"
"os"
"strings"
)
func main() {
body := strings.NewReader(`{
"model": "ostra-lite",
"task": "selector_survival",
"input": {
"locators": [
{
"locator_id": "checkout.apply-coupon",
"strategy": "css",
"dom_locator_found": true,
"history": [
{
"release": "2026.10.1",
"resolve_rate": 1
},
{
"release": "2026.10.2",
"resolve_rate": 0.92
},
{
"release": "2026.11.1",
"resolve_rate": 0.71
}
]
},
{
"locator_id": "nav.account-menu",
"strategy": "role",
"dom_locator_found": true,
"history": [
{
"release": "2026.10.2",
"resolve_rate": 1
},
{
"release": "2026.11.1",
"resolve_rate": 1
}
]
}
]
}
}`)
req, err := http.NewRequest("POST", "https://ostra.testrelic.ai/api/v1/predict", body)
if err != nil {
panic(err)
}
req.Header.Set("Authorization", "Bearer "+os.Getenv("OSTRA_API_KEY"))
req.Header.Set("Content-Type", "application/json")
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
out, err := io.ReadAll(res.Body)
if err != nil {
panic(err)
}
fmt.Println(res.Status)
fmt.Println(string(out))
}import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class OstraExample {
public static void main(String[] args) throws Exception {
String body = """
{
"model": "ostra-lite",
"task": "selector_survival",
"input": {
"locators": [
{
"locator_id": "checkout.apply-coupon",
"strategy": "css",
"dom_locator_found": true,
"history": [
{
"release": "2026.10.1",
"resolve_rate": 1
},
{
"release": "2026.10.2",
"resolve_rate": 0.92
},
{
"release": "2026.11.1",
"resolve_rate": 0.71
}
]
},
{
"locator_id": "nav.account-menu",
"strategy": "role",
"dom_locator_found": true,
"history": [
{
"release": "2026.10.2",
"resolve_rate": 1
},
{
"release": "2026.11.1",
"resolve_rate": 1
}
]
}
]
}
}
""";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://ostra.testrelic.ai/api/v1/predict"))
.header("Authorization", "Bearer " + System.getenv("OSTRA_API_KEY"))
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(body))
.build();
HttpResponse<String> response = HttpClient.newHttpClient()
.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.statusCode());
System.out.println(response.body());
}
}using System.Net.Http.Headers;
using System.Text;
using var client = new HttpClient();
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("OSTRA_API_KEY"));
using var request = new HttpRequestMessage(HttpMethod.Post, "https://ostra.testrelic.ai/api/v1/predict");
request.Content = new StringContent(
"""
{
"model": "ostra-lite",
"task": "selector_survival",
"input": {
"locators": [
{
"locator_id": "checkout.apply-coupon",
"strategy": "css",
"dom_locator_found": true,
"history": [
{
"release": "2026.10.1",
"resolve_rate": 1
},
{
"release": "2026.10.2",
"resolve_rate": 0.92
},
{
"release": "2026.11.1",
"resolve_rate": 0.71
}
]
},
{
"locator_id": "nav.account-menu",
"strategy": "role",
"dom_locator_found": true,
"history": [
{
"release": "2026.10.2",
"resolve_rate": 1
},
{
"release": "2026.11.1",
"resolve_rate": 1
}
]
}
]
}
}
""",
Encoding.UTF8,
"application/json");
using var response = await client.SendAsync(request);
Console.WriteLine((int)response.StatusCode);
Console.WriteLine(await response.Content.ReadAsStringAsync());require "net/http"
require "uri"
uri = URI("https://ostra.testrelic.ai/api/v1/predict")
request = Net::HTTP::Post.new(uri)
request["Authorization"] = "Bearer #{ENV.fetch("OSTRA_API_KEY")}"
request["Content-Type"] = "application/json"
request.body = <<~'JSON'
{
"model": "ostra-lite",
"task": "selector_survival",
"input": {
"locators": [
{
"locator_id": "checkout.apply-coupon",
"strategy": "css",
"dom_locator_found": true,
"history": [
{
"release": "2026.10.1",
"resolve_rate": 1
},
{
"release": "2026.10.2",
"resolve_rate": 0.92
},
{
"release": "2026.11.1",
"resolve_rate": 0.71
}
]
},
{
"locator_id": "nav.account-menu",
"strategy": "role",
"dom_locator_found": true,
"history": [
{
"release": "2026.10.2",
"resolve_rate": 1
},
{
"release": "2026.11.1",
"resolve_rate": 1
}
]
}
]
}
}
JSON
response = Net::HTTP.start(uri.host, uri.port, use_ssl: true) { |http| http.request(request) }
puts response.code
puts response.body<?php
$ch = curl_init("https://ostra.testrelic.ai/api/v1/predict");
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
"Authorization: Bearer " . getenv("OSTRA_API_KEY"),
"Content-Type: application/json",
],
CURLOPT_POSTFIELDS => <<<'JSON'
{
"model": "ostra-lite",
"task": "selector_survival",
"input": {
"locators": [
{
"locator_id": "checkout.apply-coupon",
"strategy": "css",
"dom_locator_found": true,
"history": [
{
"release": "2026.10.1",
"resolve_rate": 1
},
{
"release": "2026.10.2",
"resolve_rate": 0.92
},
{
"release": "2026.11.1",
"resolve_rate": 0.71
}
]
},
{
"locator_id": "nav.account-menu",
"strategy": "role",
"dom_locator_found": true,
"history": [
{
"release": "2026.10.2",
"resolve_rate": 1
},
{
"release": "2026.11.1",
"resolve_rate": 1
}
]
}
]
}
}
JSON,
]);
$response = curl_exec($ch);
echo curl_getinfo($ch, CURLINFO_HTTP_CODE), PHP_EOL;
echo $response, PHP_EOL;# The same task over MCP (JSON-RPC tools/call)
curl https://ostra.testrelic.ai/mcp \
-H "Authorization: Bearer $OSTRA_API_KEY" \
-H 'Content-Type: application/json' \
-H 'Accept: application/json, text/event-stream' \
-H 'MCP-Protocol-Version: 2025-06-18' \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "ostra_check_selector",
"arguments": {
"locators": [
{
"locator_id": "checkout.apply-coupon",
"strategy": "css",
"dom_locator_found": true,
"history": [
{
"release": "2026.10.1",
"resolve_rate": 1
},
{
"release": "2026.10.2",
"resolve_rate": 0.92
},
{
"release": "2026.11.1",
"resolve_rate": 0.71
}
]
},
{
"locator_id": "nav.account-menu",
"strategy": "role",
"dom_locator_found": true,
"history": [
{
"release": "2026.10.2",
"resolve_rate": 1
},
{
"release": "2026.11.1",
"resolve_rate": 1
}
]
}
]
}
}
}'Headers
- x-request-id
- req_01JDXK4M7Q2N8R5T6V9W3Y1Z0A
- ostra-ratelimit-requests-limit
- 600
- ostra-ratelimit-requests-remaining
- 599
- ostra-ratelimit-requests-reset
- 42
- ostra-balance-remaining-usd
- 24.9999995
{
"id": "req_01JDXK4M7Q2N8R5T6V9W3Y1Z0A",
"model": "ostra-lite@v.beta.5",
"task": "triage",
"cached": false,
"billed": {
"units": 1,
"costNano": 500,
"costUsd": "0.0000005"
},
"output": {
"decision_id": "dec_5b0c9e2a7f3d4e18a6b2c9d0e1f4a7b3",
"task": "triage",
"decision": "flaky",
"value": "flaky",
"p": 0.83,
"probabilities": {
"flaky": 0.83,
"product_bug": 0.06,
"test_bug": 0.05,
"environment": 0.04,
"selector_drift": 0.02
},
"threshold": 0.6,
"defer_reason": null,
"decided_by": "model",
"rule": null,
"model": {
"release": "v.beta.5",
"version": "1.4.0",
"content_hash": "sha256:3f9a1c07d2e4b8a6",
"gate_passed": true
},
"test_id": "checkout.spec.ts > applies coupon",
"run_id": "gha-18241",
"error_class": "timeout",
"error_class_source": "error_message"
}
}{
"id": "req_01JDXK5A1B2C3D4E5F6G7H8J9K",
"model": "ostra-lite@v.beta.5",
"task": "test_impact",
"cached": false,
"billed": {
"units": 1,
"costNano": 2000,
"costUsd": "0.000002"
},
"output": {
"decisions": [
{
"decision_id": "dec_1a2b3c4d5e6f708192a3b4c5d6e7f809",
"task": "test_impact",
"decision": "impacted",
"value": "impacted",
"p": 0.91,
"probabilities": {
"impacted": 0.91,
"not_impacted": 0.09
},
"threshold": 0.55,
"defer_reason": null,
"decided_by": "model",
"rule": null,
"model": {
"release": "v.beta.5",
"version": "1.1.2",
"content_hash": "sha256:a07be3315c9d4f12",
"gate_passed": true
},
"test_id": "checkout.spec.ts > applies coupon"
},
{
"decision_id": "dec_2b3c4d5e6f708192a3b4c5d6e7f8091a",
"task": "test_impact",
"decision": "impacted",
"value": "impacted",
"p": 0.86,
"probabilities": {
"impacted": 0.86,
"not_impacted": 0.14
},
"threshold": 0.55,
"defer_reason": null,
"decided_by": "model",
"rule": null,
"model": {
"release": "v.beta.5",
"version": "1.1.2",
"content_hash": "sha256:a07be3315c9d4f12",
"gate_passed": true
},
"test_id": "checkout.spec.ts > rejects expired coupon"
},
{
"decision_id": "dec_3c4d5e6f708192a3b4c5d6e7f8091a2b",
"task": "test_impact",
"decision": "not_impacted",
"value": "not_impacted",
"p": 0.97,
"probabilities": {
"impacted": 0.03,
"not_impacted": 0.97
},
"threshold": 0.55,
"defer_reason": null,
"decided_by": "model",
"rule": null,
"model": {
"release": "v.beta.5",
"version": "1.1.2",
"content_hash": "sha256:a07be3315c9d4f12",
"gate_passed": true
},
"test_id": "search.spec.ts > filters by brand"
}
],
"impacted": [
"checkout.spec.ts > applies coupon",
"checkout.spec.ts > rejects expired coupon"
],
"selection": "model"
}
}{
"id": "req_01JDXK6P7Q8R9S0T1U2V3W4X5Y",
"model": "ostra-lite@v.beta.5",
"task": "selector_survival",
"cached": false,
"billed": {
"units": 2,
"costNano": 500,
"costUsd": "0.0000005"
},
"output": {
"decisions": [
{
"decision_id": "dec_4d5e6f708192a3b4c5d6e7f8091a2b3c",
"task": "selector_survival",
"decision": "breaks",
"value": "breaks",
"p": 0.78,
"probabilities": {
"survives": 0.22,
"breaks": 0.78
},
"threshold": 0.6,
"defer_reason": null,
"decided_by": "model",
"rule": null,
"model": {
"release": "v.beta.5",
"version": "1.2.0",
"content_hash": "sha256:5d21f0e9c4a7b3e8",
"gate_passed": true
},
"locator_id": "checkout.apply-coupon"
},
{
"decision_id": "dec_5e6f708192a3b4c5d6e7f8091a2b3c4d",
"task": "selector_survival",
"decision": "survives",
"value": "survives",
"p": 0.96,
"probabilities": {
"survives": 0.96,
"breaks": 0.04
},
"threshold": 0.6,
"defer_reason": null,
"decided_by": "model",
"rule": null,
"model": {
"release": "v.beta.5",
"version": "1.2.0",
"content_hash": "sha256:5d21f0e9c4a7b3e8",
"gate_passed": true
},
"locator_id": "nav.account-menu"
}
]
}
}{
"error": {
"type": "invalid_request",
"message": "`task` must be one of triage, test_impact, selector_survival.",
"param": "task",
"request_id": "req_01JDXK8B9C0D1E2F3G4H5J6K7L"
}
}{
"error": {
"type": "insufficient_balance",
"message": "Your balance ($0.00) does not cover this request ($0.0000005). Top up in the TestRelic Console.",
"balance_usd": "0.00",
"cost_usd": "0.0000005",
"request_id": "req_01JDXK8B9C0D1E2F3G4H5J6K7L"
}
}{
"error": {
"type": "rate_limit_exceeded",
"message": "Rate limit of 600 requests per minute reached. Retry after 18s.",
"retry_after_ms": 18000,
"request_id": "req_01JDXK8B9C0D1E2F3G4H5J6K7L"
}
}Request body
modelstringRequiredAlways
ostra-lite(Ostra Decision).Valueostra-litetaskstringRequiredWhich task to run.
One oftriagetest_impactselector_survivalinputobjectRequiredThe task’s input. Unknown fields are rejected. See the three task shapes below.
Task input and output
input and output depend on task. Unknown input fields are rejected, and every evidence field is optional: send what you have.
input for triage
test_idstringYour identifier for the failing test, echoed back in the answer. Use a stable name, e.g.
checkout.spec.ts > applies coupon.1–512 charsrun_idstringYour identifier for the CI run, echoed back.
1–512 charscontextobjectRequiredEvidence about the failure. Every field is optional except that
error_classorerror_messagemust be present. Missing evidence is treated as missing, never as zero, so send what you have.Show 10 child fieldsHide child fields
idstringYour own id for this failure record.
1–512 charsframeworkstringTest framework that produced the failure.
One ofplaywrightcypressjestseleniumcapture_levelstringHow much of the failure was captured (trace, DOM, network):
full,partialornone.One offullpartialnoneerror_classstringNormalized class of the error. Required unless you send
error_message.One oftimeoutlocator_not_foundstale_elementstrict_mode_violationassertion_mismatchnetwork_errorscript_errorunmappederror_messagestringThe raw error text. Used only to derive
error_classwhen you don’t send one; the answer reports which you used inerror_class_source.0–8,000 charsactionstringThe step that failed.
One ofclickfillnavigateassertwait_forapi_callscreenshotlocatorobjectThe locator the failing step used.
Show 1 child fieldHide child fields
strategystringHow the element was located.
One ofcssxpathtest_idtextrolenone
diffobjectThe code change the run tested.
Show 6 child fieldsHide child fields
files_changedintegerFiles changed in the commit or pull request under test.
0 to 1,000,000lines_addedintegerLines added.
0 to 1,000,000lines_removedintegerLines removed.
0 to 1,000,000touches_test_filebooleanThe change edits a test file.
touches_selector_filebooleanThe change edits a page object, locator map or other file that defines selectors.
locator_values_removedbooleanThe change removes or renames a locator value (an id, test id, class or text) that the test uses.
domobjectWhat the page looked like at failure time.
Show 1 child fieldHide child fields
locator_foundbooleanThe locator still matched an element in the captured DOM.
memoryobjectThis test’s recent history, over its last 50 runs at most.
Show 6 child fieldsHide child fields
runs_50integerRuns in the window.
0 to 50failed_count_50integerFailed runs in the window.
0 to 50passed_on_retry_50integerRuns that failed and then passed on retry.
0 to 50consecutive_failures_50integerFailures in a row up to this one.
0 to 50flake_rate_50numberShare of runs in the window that were flaky, 0–1.
0 to 1signature_repeat_countintegerHow many times this exact error signature has been seen before.
0 to 1,000,000
output for triage
decision_idstringUnique id of this decision:
dec_and 32 hex characters.taskstringThe task that answered.
One oftriagetest_impactselector_survivaldecisionstringThe answer: one of the task’s classes,
likely_flaky(triage only), ordeferwhen the model isn’t confident enough.valuestring or nullThe same answer, or
nullwhen the decision isdefer.pnumberProbability of the top class, 0–1.
probabilitiesmap of numbersProbability of every class, keyed by class.
thresholdnumberThe confidence the top class must reach for a firm answer. Below it, the answer is
defer(orlikely_flaky).defer_reasonstring or nullWhy the answer is
defer;nullotherwise.insufficient_evidencemeans the request carried nothing about this test or locator.One ofbelow_thresholdmodel_gate_failedinsufficient_evidencedecided_bystringrulewhen an unambiguous environment rule answered (seerule). The probabilities are still the model’s.One ofmodelrulerulestring or nullThe rule that answered, when
decided_byisrule. A rule answer is alwaysenvironment.One ofbrowser_not_installedhost_missing_dependencieswebdriver_session_not_createdport_in_usedisk_fullmodelobjectThe model release that answered.
Show 4 child fieldsHide child fields
releasestringOstra Decision release, e.g.
v.beta.5.versionstringVersion of this task’s model in that release.
content_hashstringContent hash of the model that answered.
gate_passedbooleanThe model passed its release quality gate. When
false, every answer isdeferwithmodel_gate_failed.
test_idstring or nullYour
test_id, echoed.run_idstring or nullYour
run_id, echoed.error_classstringThe error class the model used.
One oftimeoutlocator_not_foundstale_elementstrict_mode_violationassertion_mismatchnetwork_errorscript_errorunmappederror_class_sourcestringrequestwhen you senterror_class,error_messagewhen it was derived from your message.One ofrequesterror_message
Response
idstringRequest id, the same as the
x-request-idheader.modelstringThe model and release that answered, e.g.
ostra-lite@v.beta.5.taskstringThe task you ran.
cachedbooleantruewhen the answer came from the 24-hour cache (and cost nothing).billedobjectWhat this request cost. Cached answers cost 0.
Show 3 child fieldsHide child fields
unitsintegerBillable units: 1 per failure (triage), 1 per request (test impact), 1 per locator (selector survival). 0 for a cached answer.
costNanointegerCost in nano-dollars (1 USD = 1,000,000,000).
costUsdstringCost in USD as an exact decimal string, e.g.
"0.0000005".
outputobjectThe task’s answer. Shapes: triage, test impact and selector survival below.
Response headers
x-request-idstringId of this request (
req_+ 26 characters). Quote it to support.ostra-ratelimit-requests-limitintegerYour workspace’s requests-per-minute limit.
ostra-ratelimit-requests-remainingintegerRequests left in the current minute.
ostra-ratelimit-requests-resetintegerSeconds until the current minute ends and the count resets.
ostra-balance-remaining-usdstringWorkspace credit balance after this request, in USD. Approximate under concurrent requests.
Errors
| Status | Type | When |
|---|---|---|
| 400 | invalid_request | The body isn’t valid JSON or fails validation; param names the field. |
| 413 | payload_too_large | The request body is larger than the route allows. |
| 401 | authentication_error | The API key is missing, malformed, unknown, revoked or expired. |
| 403 | permission_error | The caller’s IP isn’t in the key’s allowlist, or a read-only key called a route that needs full access. |
| 402 | insufficient_balance | Your credit balance doesn’t cover the request. Nothing is charged. |
| 402 | spend_limit_reached | The workspace’s monthly spend limit (scope: "org") or this key’s monthly spend cap (scope: "key") is reached. |
| 429 | rate_limit_exceeded | The workspace’s requests-per-minute limit is reached. Wait Retry-After seconds. |
| 502 | upstream_error | Ostra Decision failed to answer. Nothing was charged. |
| 503 | service_unavailable | Too many requests are updating the workspace balance at once. Nothing was charged; retry after Retry-After (1 s). |
| 504 | upstream_timeout | Ostra Decision didn’t answer within 10 seconds. Nothing was charged. |
Every error has the same envelope and a request_id. See Errors for messages and retry advice.