Create a chat completion
POST /api/v1/chat/completions — send a conversation to Ostra Pro. OpenAI Chat Completions compatible, streamed or not.
https://ostra.testrelic.ai/api/v1/chat/completionsSends a conversation to Ostra Pro and returns its reply. OpenAI Chat Completions compatible, streamed or not.
Any OpenAI client works: set its base URL to https://ostra.testrelic.ai/api/v1 and its API key to your Ostra key. Thinking is on by default; set its depth with reasoning_effort, or turn it off with chat_template_kwargs.enable_thinking: false.
Fields not listed below (for example top_p, stop, seed, response_format, tool_choice) are passed to the model unchanged.
- Auth
Authorization: Bearer $OSTRA_API_KEYorx-api-key: $OSTRA_API_KEY. Needs a Full-access key.- Rate limit
- Counts against your workspace's requests per minute.
- Cost
- Input $0.64, cached input $0.06, output $4.47 per 1M tokens; reasoning tokens bill as output. The most a request can cost is held from your balance up front and the rest is refunded when it ends. Failed requests and cold-start timeouts cost nothing; a stream that breaks bills only the tokens produced.
- Over MCP
- Same operation as the
ostra_pro_chattool.
curl https://ostra.testrelic.ai/api/v1/chat/completions \
-H "Authorization: Bearer $OSTRA_API_KEY" \
-H 'Content-Type: application/json' \
-H 'x-ostra-session: checkout-suite-run-42' \
-d '{
"model": "ostra-pro",
"messages": [
{
"role": "system",
"content": "You are a senior test engineer. Answer briefly."
},
{
"role": "user",
"content": "This Playwright test times out on CI but passes locally. Why, and how do I fix it?"
}
],
"reasoning_effort": "low",
"max_tokens": 1024
}'import os
from openai import OpenAI
client = OpenAI(base_url="https://ostra.testrelic.ai/api/v1", api_key=os.environ["OSTRA_API_KEY"])
completion = client.chat.completions.create(
model="ostra-pro",
messages=[
{
"role": "system",
"content": "You are a senior test engineer. Answer briefly.",
},
{
"role": "user",
"content": "This Playwright test times out on CI but passes locally. Why, and how do I fix it?",
},
],
reasoning_effort="low",
max_tokens=1024,
extra_headers={"x-ostra-session": "checkout-suite-run-42"},
)
print(completion.choices[0].message.content)import OpenAI from 'openai';
const client = new OpenAI({ baseURL: 'https://ostra.testrelic.ai/api/v1', apiKey: process.env.OSTRA_API_KEY });
const completion = await client.chat.completions.create({
model: 'ostra-pro',
messages: [
{
role: 'system',
content: 'You are a senior test engineer. Answer briefly.',
},
{
role: 'user',
content: 'This Playwright test times out on CI but passes locally. Why, and how do I fix it?',
},
],
reasoning_effort: 'low',
max_tokens: 1024,
}, { headers: { 'x-ostra-session': 'checkout-suite-run-42' } });
console.log(completion.choices[0].message.content);import os
import requests
response = requests.post(
"https://ostra.testrelic.ai/api/v1/chat/completions",
headers={
"Authorization": f"Bearer {os.environ['OSTRA_API_KEY']}",
"x-ostra-session": "checkout-suite-run-42",
},
json={
"model": "ostra-pro",
"messages": [
{
"role": "system",
"content": "You are a senior test engineer. Answer briefly.",
},
{
"role": "user",
"content": "This Playwright test times out on CI but passes locally. Why, and how do I fix it?",
},
],
"reasoning_effort": "low",
"max_tokens": 1024,
},
timeout=60,
)
response.raise_for_status()
print(response.json())const response = await fetch('https://ostra.testrelic.ai/api/v1/chat/completions', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.OSTRA_API_KEY}`,
'Content-Type': 'application/json',
'x-ostra-session': 'checkout-suite-run-42',
},
body: JSON.stringify({
model: 'ostra-pro',
messages: [
{
role: 'system',
content: 'You are a senior test engineer. Answer briefly.',
},
{
role: 'user',
content: 'This Playwright test times out on CI but passes locally. Why, and how do I fix it?',
},
],
reasoning_effort: 'low',
max_tokens: 1024,
}),
});
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-pro",
"messages": [
{
"role": "system",
"content": "You are a senior test engineer. Answer briefly."
},
{
"role": "user",
"content": "This Playwright test times out on CI but passes locally. Why, and how do I fix it?"
}
],
"reasoning_effort": "low",
"max_tokens": 1024
}`)
req, err := http.NewRequest("POST", "https://ostra.testrelic.ai/api/v1/chat/completions", body)
if err != nil {
panic(err)
}
req.Header.Set("Authorization", "Bearer "+os.Getenv("OSTRA_API_KEY"))
req.Header.Set("Content-Type", "application/json")
req.Header.Set("x-ostra-session", "checkout-suite-run-42")
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-pro",
"messages": [
{
"role": "system",
"content": "You are a senior test engineer. Answer briefly."
},
{
"role": "user",
"content": "This Playwright test times out on CI but passes locally. Why, and how do I fix it?"
}
],
"reasoning_effort": "low",
"max_tokens": 1024
}
""";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://ostra.testrelic.ai/api/v1/chat/completions"))
.header("Authorization", "Bearer " + System.getenv("OSTRA_API_KEY"))
.header("Content-Type", "application/json")
.header("x-ostra-session", "checkout-suite-run-42")
.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"));
client.DefaultRequestHeaders.Add("x-ostra-session", "checkout-suite-run-42");
using var request = new HttpRequestMessage(HttpMethod.Post, "https://ostra.testrelic.ai/api/v1/chat/completions");
request.Content = new StringContent(
"""
{
"model": "ostra-pro",
"messages": [
{
"role": "system",
"content": "You are a senior test engineer. Answer briefly."
},
{
"role": "user",
"content": "This Playwright test times out on CI but passes locally. Why, and how do I fix it?"
}
],
"reasoning_effort": "low",
"max_tokens": 1024
}
""",
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/chat/completions")
request = Net::HTTP::Post.new(uri)
request["Authorization"] = "Bearer #{ENV.fetch("OSTRA_API_KEY")}"
request["Content-Type"] = "application/json"
request["x-ostra-session"] = "checkout-suite-run-42"
request.body = <<~'JSON'
{
"model": "ostra-pro",
"messages": [
{
"role": "system",
"content": "You are a senior test engineer. Answer briefly."
},
{
"role": "user",
"content": "This Playwright test times out on CI but passes locally. Why, and how do I fix it?"
}
],
"reasoning_effort": "low",
"max_tokens": 1024
}
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/chat/completions");
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
"Authorization: Bearer " . getenv("OSTRA_API_KEY"),
"Content-Type: application/json",
"x-ostra-session: checkout-suite-run-42",
],
CURLOPT_POSTFIELDS => <<<'JSON'
{
"model": "ostra-pro",
"messages": [
{
"role": "system",
"content": "You are a senior test engineer. Answer briefly."
},
{
"role": "user",
"content": "This Playwright test times out on CI but passes locally. Why, and how do I fix it?"
}
],
"reasoning_effort": "low",
"max_tokens": 1024
}
JSON,
]);
$response = curl_exec($ch);
echo curl_getinfo($ch, CURLINFO_HTTP_CODE), PHP_EOL;
echo $response, PHP_EOL;curl -N https://ostra.testrelic.ai/api/v1/chat/completions \
-H "Authorization: Bearer $OSTRA_API_KEY" \
-H 'Content-Type: application/json' \
-H 'x-ostra-session: checkout-suite-run-42' \
-d '{
"model": "ostra-pro",
"messages": [
{
"role": "system",
"content": "You are a senior test engineer. Answer briefly."
},
{
"role": "user",
"content": "This Playwright test times out on CI but passes locally. Why, and how do I fix it?"
}
],
"reasoning_effort": "low",
"max_tokens": 1024,
"stream": true,
"stream_options": {
"include_usage": true
}
}'import os
from openai import OpenAI
client = OpenAI(base_url="https://ostra.testrelic.ai/api/v1", api_key=os.environ["OSTRA_API_KEY"])
stream = client.chat.completions.create(
model="ostra-pro",
messages=[
{
"role": "system",
"content": "You are a senior test engineer. Answer briefly.",
},
{
"role": "user",
"content": "This Playwright test times out on CI but passes locally. Why, and how do I fix it?",
},
],
reasoning_effort="low",
max_tokens=1024,
stream=True,
stream_options={
"include_usage": True,
},
extra_headers={"x-ostra-session": "checkout-suite-run-42"},
)
for chunk in stream:
if chunk.choices and chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="", flush=True)
print()import OpenAI from 'openai';
const client = new OpenAI({ baseURL: 'https://ostra.testrelic.ai/api/v1', apiKey: process.env.OSTRA_API_KEY });
const stream = await client.chat.completions.create({
model: 'ostra-pro',
messages: [
{
role: 'system',
content: 'You are a senior test engineer. Answer briefly.',
},
{
role: 'user',
content: 'This Playwright test times out on CI but passes locally. Why, and how do I fix it?',
},
],
reasoning_effort: 'low',
max_tokens: 1024,
stream: true,
stream_options: {
include_usage: true,
},
}, { headers: { 'x-ostra-session': 'checkout-suite-run-42' } });
for await (const chunk of stream) {
process.stdout.write(chunk.choices[0]?.delta?.content ?? '');
}import os
import requests
response = requests.post(
"https://ostra.testrelic.ai/api/v1/chat/completions",
headers={
"Authorization": f"Bearer {os.environ['OSTRA_API_KEY']}",
"x-ostra-session": "checkout-suite-run-42",
},
json={
"model": "ostra-pro",
"messages": [
{
"role": "system",
"content": "You are a senior test engineer. Answer briefly.",
},
{
"role": "user",
"content": "This Playwright test times out on CI but passes locally. Why, and how do I fix it?",
},
],
"reasoning_effort": "low",
"max_tokens": 1024,
"stream": True,
"stream_options": {
"include_usage": True,
},
},
stream=True,
timeout=600,
)
response.raise_for_status()
for line in response.iter_lines(decode_unicode=True):
if line:
print(line)const response = await fetch('https://ostra.testrelic.ai/api/v1/chat/completions', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.OSTRA_API_KEY}`,
'Content-Type': 'application/json',
'x-ostra-session': 'checkout-suite-run-42',
},
body: JSON.stringify({
model: 'ostra-pro',
messages: [
{
role: 'system',
content: 'You are a senior test engineer. Answer briefly.',
},
{
role: 'user',
content: 'This Playwright test times out on CI but passes locally. Why, and how do I fix it?',
},
],
reasoning_effort: 'low',
max_tokens: 1024,
stream: true,
stream_options: {
include_usage: true,
},
}),
});
if (!response.ok) {
throw new Error(`Ostra ${response.status}: ${await response.text()}`);
}
// Print each server-sent event as it arrives.
const decoder = new TextDecoder();
for await (const chunk of response.body!) {
process.stdout.write(decoder.decode(chunk, { stream: true }));
}package main
import (
"fmt"
"io"
"net/http"
"os"
"strings"
)
func main() {
body := strings.NewReader(`{
"model": "ostra-pro",
"messages": [
{
"role": "system",
"content": "You are a senior test engineer. Answer briefly."
},
{
"role": "user",
"content": "This Playwright test times out on CI but passes locally. Why, and how do I fix it?"
}
],
"reasoning_effort": "low",
"max_tokens": 1024,
"stream": true,
"stream_options": {
"include_usage": true
}
}`)
req, err := http.NewRequest("POST", "https://ostra.testrelic.ai/api/v1/chat/completions", body)
if err != nil {
panic(err)
}
req.Header.Set("Authorization", "Bearer "+os.Getenv("OSTRA_API_KEY"))
req.Header.Set("Content-Type", "application/json")
req.Header.Set("x-ostra-session", "checkout-suite-run-42")
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
fmt.Println(res.Status)
// Copies each server-sent event to stdout as it arrives.
io.Copy(os.Stdout, res.Body)
}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-pro",
"messages": [
{
"role": "system",
"content": "You are a senior test engineer. Answer briefly."
},
{
"role": "user",
"content": "This Playwright test times out on CI but passes locally. Why, and how do I fix it?"
}
],
"reasoning_effort": "low",
"max_tokens": 1024,
"stream": true,
"stream_options": {
"include_usage": true
}
}
""";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://ostra.testrelic.ai/api/v1/chat/completions"))
.header("Authorization", "Bearer " + System.getenv("OSTRA_API_KEY"))
.header("Content-Type", "application/json")
.header("x-ostra-session", "checkout-suite-run-42")
.POST(HttpRequest.BodyPublishers.ofString(body))
.build();
HttpResponse<java.util.stream.Stream<String>> response = HttpClient.newHttpClient()
.send(request, HttpResponse.BodyHandlers.ofLines());
System.out.println(response.statusCode());
response.body().forEach(System.out::println);
}
}using System.Net.Http.Headers;
using System.Text;
using var client = new HttpClient();
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("OSTRA_API_KEY"));
client.DefaultRequestHeaders.Add("x-ostra-session", "checkout-suite-run-42");
using var request = new HttpRequestMessage(HttpMethod.Post, "https://ostra.testrelic.ai/api/v1/chat/completions");
request.Content = new StringContent(
"""
{
"model": "ostra-pro",
"messages": [
{
"role": "system",
"content": "You are a senior test engineer. Answer briefly."
},
{
"role": "user",
"content": "This Playwright test times out on CI but passes locally. Why, and how do I fix it?"
}
],
"reasoning_effort": "low",
"max_tokens": 1024,
"stream": true,
"stream_options": {
"include_usage": true
}
}
""",
Encoding.UTF8,
"application/json");
using var response = await client.SendAsync(request, HttpCompletionOption.ResponseHeadersRead);
Console.WriteLine((int)response.StatusCode);
using var reader = new StreamReader(await response.Content.ReadAsStreamAsync());
while (await reader.ReadLineAsync() is { } line)
{
Console.WriteLine(line);
}require "net/http"
require "uri"
uri = URI("https://ostra.testrelic.ai/api/v1/chat/completions")
request = Net::HTTP::Post.new(uri)
request["Authorization"] = "Bearer #{ENV.fetch("OSTRA_API_KEY")}"
request["Content-Type"] = "application/json"
request["x-ostra-session"] = "checkout-suite-run-42"
request.body = <<~'JSON'
{
"model": "ostra-pro",
"messages": [
{
"role": "system",
"content": "You are a senior test engineer. Answer briefly."
},
{
"role": "user",
"content": "This Playwright test times out on CI but passes locally. Why, and how do I fix it?"
}
],
"reasoning_effort": "low",
"max_tokens": 1024,
"stream": true,
"stream_options": {
"include_usage": true
}
}
JSON
Net::HTTP.start(uri.host, uri.port, use_ssl: true, read_timeout: 600) do |http|
http.request(request) do |response|
puts response.code
response.read_body { |chunk| print chunk }
end
end<?php
$ch = curl_init("https://ostra.testrelic.ai/api/v1/chat/completions");
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_WRITEFUNCTION => function ($ch, $chunk) { echo $chunk; return strlen($chunk); },
CURLOPT_HTTPHEADER => [
"Authorization: Bearer " . getenv("OSTRA_API_KEY"),
"Content-Type: application/json",
"x-ostra-session: checkout-suite-run-42",
],
CURLOPT_POSTFIELDS => <<<'JSON'
{
"model": "ostra-pro",
"messages": [
{
"role": "system",
"content": "You are a senior test engineer. Answer briefly."
},
{
"role": "user",
"content": "This Playwright test times out on CI but passes locally. Why, and how do I fix it?"
}
],
"reasoning_effort": "low",
"max_tokens": 1024,
"stream": true,
"stream_options": {
"include_usage": true
}
}
JSON,
]);
curl_exec($ch);
echo PHP_EOL, curl_getinfo($ch, CURLINFO_HTTP_CODE), PHP_EOL;curl https://ostra.testrelic.ai/api/v1/chat/completions \
-H "Authorization: Bearer $OSTRA_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"model": "ostra-pro",
"messages": [
{
"role": "user",
"content": "Run tests/checkout.spec.ts and tell me what failed."
}
],
"tools": [
{
"type": "function",
"function": {
"name": "run_tests",
"description": "Run part of the test suite and return its output.",
"parameters": {
"type": "object",
"properties": {
"path": {
"type": "string",
"description": "Test file or directory"
}
},
"required": [
"path"
]
}
}
}
],
"reasoning_effort": "low"
}'import os
from openai import OpenAI
client = OpenAI(base_url="https://ostra.testrelic.ai/api/v1", api_key=os.environ["OSTRA_API_KEY"])
completion = client.chat.completions.create(
model="ostra-pro",
messages=[
{
"role": "user",
"content": "Run tests/checkout.spec.ts and tell me what failed.",
},
],
tools=[
{
"type": "function",
"function": {
"name": "run_tests",
"description": "Run part of the test suite and return its output.",
"parameters": {
"type": "object",
"properties": {
"path": {
"type": "string",
"description": "Test file or directory",
},
},
"required": [
"path",
],
},
},
},
],
reasoning_effort="low",
)
message = completion.choices[0].message
for call in message.tool_calls or []:
print(call.id, call.function.name, call.function.arguments)import OpenAI from 'openai';
const client = new OpenAI({ baseURL: 'https://ostra.testrelic.ai/api/v1', apiKey: process.env.OSTRA_API_KEY });
const completion = await client.chat.completions.create({
model: 'ostra-pro',
messages: [
{
role: 'user',
content: 'Run tests/checkout.spec.ts and tell me what failed.',
},
],
tools: [
{
type: 'function',
function: {
name: 'run_tests',
description: 'Run part of the test suite and return its output.',
parameters: {
type: 'object',
properties: {
path: {
type: 'string',
description: 'Test file or directory',
},
},
required: [
'path',
],
},
},
},
],
reasoning_effort: 'low',
});
for (const call of completion.choices[0].message.tool_calls ?? []) {
console.log(call.id, call.type === 'function' ? call.function.name : call.type);
}import os
import requests
response = requests.post(
"https://ostra.testrelic.ai/api/v1/chat/completions",
headers={
"Authorization": f"Bearer {os.environ['OSTRA_API_KEY']}",
},
json={
"model": "ostra-pro",
"messages": [
{
"role": "user",
"content": "Run tests/checkout.spec.ts and tell me what failed.",
},
],
"tools": [
{
"type": "function",
"function": {
"name": "run_tests",
"description": "Run part of the test suite and return its output.",
"parameters": {
"type": "object",
"properties": {
"path": {
"type": "string",
"description": "Test file or directory",
},
},
"required": [
"path",
],
},
},
},
],
"reasoning_effort": "low",
},
timeout=60,
)
response.raise_for_status()
print(response.json())const response = await fetch('https://ostra.testrelic.ai/api/v1/chat/completions', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.OSTRA_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
model: 'ostra-pro',
messages: [
{
role: 'user',
content: 'Run tests/checkout.spec.ts and tell me what failed.',
},
],
tools: [
{
type: 'function',
function: {
name: 'run_tests',
description: 'Run part of the test suite and return its output.',
parameters: {
type: 'object',
properties: {
path: {
type: 'string',
description: 'Test file or directory',
},
},
required: [
'path',
],
},
},
},
],
reasoning_effort: 'low',
}),
});
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-pro",
"messages": [
{
"role": "user",
"content": "Run tests/checkout.spec.ts and tell me what failed."
}
],
"tools": [
{
"type": "function",
"function": {
"name": "run_tests",
"description": "Run part of the test suite and return its output.",
"parameters": {
"type": "object",
"properties": {
"path": {
"type": "string",
"description": "Test file or directory"
}
},
"required": [
"path"
]
}
}
}
],
"reasoning_effort": "low"
}`)
req, err := http.NewRequest("POST", "https://ostra.testrelic.ai/api/v1/chat/completions", 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-pro",
"messages": [
{
"role": "user",
"content": "Run tests/checkout.spec.ts and tell me what failed."
}
],
"tools": [
{
"type": "function",
"function": {
"name": "run_tests",
"description": "Run part of the test suite and return its output.",
"parameters": {
"type": "object",
"properties": {
"path": {
"type": "string",
"description": "Test file or directory"
}
},
"required": [
"path"
]
}
}
}
],
"reasoning_effort": "low"
}
""";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://ostra.testrelic.ai/api/v1/chat/completions"))
.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/chat/completions");
request.Content = new StringContent(
"""
{
"model": "ostra-pro",
"messages": [
{
"role": "user",
"content": "Run tests/checkout.spec.ts and tell me what failed."
}
],
"tools": [
{
"type": "function",
"function": {
"name": "run_tests",
"description": "Run part of the test suite and return its output.",
"parameters": {
"type": "object",
"properties": {
"path": {
"type": "string",
"description": "Test file or directory"
}
},
"required": [
"path"
]
}
}
}
],
"reasoning_effort": "low"
}
""",
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/chat/completions")
request = Net::HTTP::Post.new(uri)
request["Authorization"] = "Bearer #{ENV.fetch("OSTRA_API_KEY")}"
request["Content-Type"] = "application/json"
request.body = <<~'JSON'
{
"model": "ostra-pro",
"messages": [
{
"role": "user",
"content": "Run tests/checkout.spec.ts and tell me what failed."
}
],
"tools": [
{
"type": "function",
"function": {
"name": "run_tests",
"description": "Run part of the test suite and return its output.",
"parameters": {
"type": "object",
"properties": {
"path": {
"type": "string",
"description": "Test file or directory"
}
},
"required": [
"path"
]
}
}
}
],
"reasoning_effort": "low"
}
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/chat/completions");
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-pro",
"messages": [
{
"role": "user",
"content": "Run tests/checkout.spec.ts and tell me what failed."
}
],
"tools": [
{
"type": "function",
"function": {
"name": "run_tests",
"description": "Run part of the test suite and return its output.",
"parameters": {
"type": "object",
"properties": {
"path": {
"type": "string",
"description": "Test file or directory"
}
},
"required": [
"path"
]
}
}
}
],
"reasoning_effort": "low"
}
JSON,
]);
$response = curl_exec($ch);
echo curl_getinfo($ch, CURLINFO_HTTP_CODE), PHP_EOL;
echo $response, PHP_EOL;curl https://ostra.testrelic.ai/api/v1/chat/completions \
-H "Authorization: Bearer $OSTRA_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"model": "ostra-pro",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "List the visual bugs on this checkout page."
},
{
"type": "image_url",
"image_url": {
"url": "https://docs.testrelic.ai/img/samples/checkout.png"
}
}
]
}
],
"reasoning_effort": "medium"
}'import os
from openai import OpenAI
client = OpenAI(base_url="https://ostra.testrelic.ai/api/v1", api_key=os.environ["OSTRA_API_KEY"])
completion = client.chat.completions.create(
model="ostra-pro",
messages=[
{
"role": "user",
"content": [
{
"type": "text",
"text": "List the visual bugs on this checkout page.",
},
{
"type": "image_url",
"image_url": {
"url": "https://docs.testrelic.ai/img/samples/checkout.png",
},
},
],
},
],
reasoning_effort="medium",
)
print(completion.choices[0].message.content)import OpenAI from 'openai';
const client = new OpenAI({ baseURL: 'https://ostra.testrelic.ai/api/v1', apiKey: process.env.OSTRA_API_KEY });
const completion = await client.chat.completions.create({
model: 'ostra-pro',
messages: [
{
role: 'user',
content: [
{
type: 'text',
text: 'List the visual bugs on this checkout page.',
},
{
type: 'image_url',
image_url: {
url: 'https://docs.testrelic.ai/img/samples/checkout.png',
},
},
],
},
],
reasoning_effort: 'medium',
});
console.log(completion.choices[0].message.content);import os
import requests
response = requests.post(
"https://ostra.testrelic.ai/api/v1/chat/completions",
headers={
"Authorization": f"Bearer {os.environ['OSTRA_API_KEY']}",
},
json={
"model": "ostra-pro",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "List the visual bugs on this checkout page.",
},
{
"type": "image_url",
"image_url": {
"url": "https://docs.testrelic.ai/img/samples/checkout.png",
},
},
],
},
],
"reasoning_effort": "medium",
},
timeout=60,
)
response.raise_for_status()
print(response.json())const response = await fetch('https://ostra.testrelic.ai/api/v1/chat/completions', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.OSTRA_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
model: 'ostra-pro',
messages: [
{
role: 'user',
content: [
{
type: 'text',
text: 'List the visual bugs on this checkout page.',
},
{
type: 'image_url',
image_url: {
url: 'https://docs.testrelic.ai/img/samples/checkout.png',
},
},
],
},
],
reasoning_effort: 'medium',
}),
});
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-pro",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "List the visual bugs on this checkout page."
},
{
"type": "image_url",
"image_url": {
"url": "https://docs.testrelic.ai/img/samples/checkout.png"
}
}
]
}
],
"reasoning_effort": "medium"
}`)
req, err := http.NewRequest("POST", "https://ostra.testrelic.ai/api/v1/chat/completions", 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-pro",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "List the visual bugs on this checkout page."
},
{
"type": "image_url",
"image_url": {
"url": "https://docs.testrelic.ai/img/samples/checkout.png"
}
}
]
}
],
"reasoning_effort": "medium"
}
""";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://ostra.testrelic.ai/api/v1/chat/completions"))
.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/chat/completions");
request.Content = new StringContent(
"""
{
"model": "ostra-pro",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "List the visual bugs on this checkout page."
},
{
"type": "image_url",
"image_url": {
"url": "https://docs.testrelic.ai/img/samples/checkout.png"
}
}
]
}
],
"reasoning_effort": "medium"
}
""",
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/chat/completions")
request = Net::HTTP::Post.new(uri)
request["Authorization"] = "Bearer #{ENV.fetch("OSTRA_API_KEY")}"
request["Content-Type"] = "application/json"
request.body = <<~'JSON'
{
"model": "ostra-pro",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "List the visual bugs on this checkout page."
},
{
"type": "image_url",
"image_url": {
"url": "https://docs.testrelic.ai/img/samples/checkout.png"
}
}
]
}
],
"reasoning_effort": "medium"
}
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/chat/completions");
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-pro",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "List the visual bugs on this checkout page."
},
{
"type": "image_url",
"image_url": {
"url": "https://docs.testrelic.ai/img/samples/checkout.png"
}
}
]
}
],
"reasoning_effort": "medium"
}
JSON,
]);
$response = curl_exec($ch);
echo curl_getinfo($ch, CURLINFO_HTTP_CODE), PHP_EOL;
echo $response, PHP_EOL;Headers
- x-request-id
- req_01JDXK4M7Q2N8R5T6V9W3Y1Z0A
- ostra-ratelimit-requests-limit
- 600
- ostra-ratelimit-requests-remaining
- 599
- ostra-ratelimit-requests-reset
- 42
- ostra-model-version
- 1.0
- ostra-cost-usd
- 0.00079318
- ostra-balance-remaining-usd
- 24.99920682
{
"id": "chatcmpl-7f3a9c1e2b4d",
"object": "chat.completion",
"created": 1795615200,
"model": "ostra-pro",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "CI machines are slower and run tests in parallel, so the coupon button renders after your 30 s timeout. Wait for the state you need instead of a fixed time: `await expect(page.getByRole('button', { name: 'Apply coupon' })).toBeEnabled()` before clicking, and stop sharing the cart between tests so parallel workers don’t race.",
"reasoning_content": "Timeout only on CI: likely slower runners or shared state between parallel tests…"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 52,
"completion_tokens": 170,
"total_tokens": 222,
"prompt_tokens_details": {
"cached_tokens": 0
}
}
}data: {"id":"chatcmpl-7f3a9c1e2b4d","object":"chat.completion.chunk","created":1795615200,"model":"ostra-pro","choices":[{"index":0,"delta":{"role":"assistant","content":""},"finish_reason":null}]}
data: {"id":"chatcmpl-7f3a9c1e2b4d","object":"chat.completion.chunk","created":1795615200,"model":"ostra-pro","choices":[{"index":0,"delta":{"content":"CI machines are slower"},"finish_reason":null}]}
data: {"id":"chatcmpl-7f3a9c1e2b4d","object":"chat.completion.chunk","created":1795615200,"model":"ostra-pro","choices":[{"index":0,"delta":{},"finish_reason":"stop"}]}
data: {"id":"chatcmpl-7f3a9c1e2b4d","object":"chat.completion.chunk","created":1795615200,"model":"ostra-pro","choices":[],"usage":{"prompt_tokens":52,"completion_tokens":170,"total_tokens":222,"prompt_tokens_details":{"cached_tokens":0}}}
data: [DONE]
{
"id": "chatcmpl-1c2d3e4f5a6b",
"object": "chat.completion",
"created": 1795615260,
"model": "ostra-pro",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": null,
"tool_calls": [
{
"id": "call_8d1f",
"type": "function",
"function": {
"name": "run_tests",
"arguments": "{\"path\": \"tests/checkout.spec.ts\"}"
}
}
]
},
"finish_reason": "tool_calls"
}
],
"usage": {
"prompt_tokens": 214,
"completion_tokens": 38,
"total_tokens": 252,
"prompt_tokens_details": {
"cached_tokens": 0
}
}
}{
"error": {
"type": "service_unavailable",
"message": "Ostra Pro is starting up after a quiet period. Nothing was charged; retry shortly, or send stream: true to wait on the open connection.",
"retry_after_ms": 60000,
"state": "starting",
"request_id": "req_01JDXK8B9C0D1E2F3G4H5J6K7L"
}
}{
"error": {
"type": "insufficient_balance",
"message": "Your balance ($0.10) does not cover this request's maximum cost ($0.2043). Top up in the TestRelic Console, or lower max_tokens.",
"balance_usd": "0.10",
"cost_usd": "0.2043",
"request_id": "req_01JDXK8B9C0D1E2F3G4H5J6K7L"
}
}Request headers
x-ostra-sessionstringOptional. One value per conversation or agent run (1–128 letters, digits,
_,.,:or-). Requests with the same value are routed to the same model replica when possible, so more of the conversation’s earlier turns are served from the prompt cache and bill as cached input. Best effort: an unknown value or a different replica just means no cache hit. See Sessions and caching.pattern ^[\w.:-]{1,128}$
Request body
modelstringRequiredAlways
ostra-pro.Valueostra-promessagesarray of objectsRequiredThe conversation so far. Up to 8 images and 1 video per request.
1–4,000 itemsShow 5 child fieldsHide child fields
rolestringRequiredWho wrote the message.
One ofsystemdeveloperuserassistanttoolcontentstring or array of parts or nullText, or an array of parts:
{ "type": "text", "text" },{ "type": "image_url", "image_url": { "url" } }(https ordata:image/...;base64,URL) or{ "type": "video_url", "video_url": { "url" } }.tool_callsarray of objectsOn
assistantmessages: the tool calls the model made, sent back as you received them.tool_call_idstringOn
toolmessages: the id of the call this message answers.namestringOptional participant name.
max_completion_tokensintegerMost output tokens to generate, reasoning included. Values above 32,768 are lowered to 32,768. Takes precedence over
max_tokens.≥ 1default 8192max_tokensintegerSame as
max_completion_tokens(older name).≥ 1default 8192streambooleanStream the reply as server-sent events. See Streaming.
default falsestream_optionsobjectWith
stream. Setinclude_usage: trueto get a final chunk with token usage.Show 1 child fieldHide child fields
include_usagebooleanSend a usage-only chunk before
[DONE].
reasoning_effortstringHow long the model thinks before answering. Lower is faster and cheaper.
One oflowmediumxhighdefault "xhigh"chat_template_kwargsobjectModel template switches.
Show 1 child fieldHide child fields
enable_thinkingbooleanfalseanswers directly, with no reasoning.default true
toolsarray of objectsFunctions the model may call, in OpenAI format.
0–128 itemsShow 2 child fieldsHide child fields
typestringRequiredAlways
function.ValuefunctionfunctionobjectRequired{ "name", "description", "parameters" }, whereparametersis a JSON Schema.
tool_choicestring or objectauto(default),none,required, or a specific function, as in OpenAI.temperaturenumberSampling temperature.
0 to 2nintegerOnly
1is supported.Value1
Response
idstringCompletion id.
objectstringchat.completion(orchat.completion.chunkwhen streaming).createdintegerUnix time.
modelstringostra-pro.choicesarray of objectsOne choice.
Show 3 child fieldsHide child fields
indexintegerAlways 0.
messageobjectThe reply.
Show 4 child fieldsHide child fields
rolestringassistant.contentstring or nullThe answer text.
reasoning_contentstring or nullThe model’s reasoning, when thinking is on.
tool_callsarray of objectsTool calls the model wants you to run:
{ "id", "type": "function", "function": { "name", "arguments" } }.
finish_reasonstringstop,length(hit the token limit) ortool_calls.
usageobjectToken counts this request was billed for.
Show 4 child fieldsHide child fields
prompt_tokensintegerInput tokens, cached ones included.
completion_tokensintegerOutput tokens, reasoning included.
total_tokensintegerSum of the two.
prompt_tokens_detailsobjectBreakdown of input.
Show 1 child fieldHide child fields
cached_tokensintegerInput tokens served from the prompt cache, billed at the cached rate.
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-model-versionstringOstra Pro version that answered:
1.0.ostra-cost-usdstringNon-streaming only: what this request cost.
ostra-balance-remaining-usdstringWorkspace credit balance after this request, in USD. Approximate under concurrent requests.
Errors
| Status | Type | When |
|---|---|---|
| 400 | invalid_request | Validation failed (param names the field), or the model rejected the request. |
| 413 | payload_too_large | The body is larger than 5.5 MB (images and video count). |
| 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 balance doesn’t cover the request’s maximum cost. Top up or lower max_tokens. |
| 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 Pro failed to answer. Nothing was charged. |
| 503 | service_unavailable | Ostra Pro is starting after a quiet period (state: "starting", retry after 60 s) or at capacity (retry after 5 s). Nothing was charged. |
Every error has the same envelope and a request_id. See Errors for messages and retry advice.