Create a message
POST /api/v1/messages — Ostra Pro in Anthropic Messages format, for Anthropic SDKs and Anthropic-compatible tools.
https://ostra.testrelic.ai/api/v1/messagesSends a conversation to Ostra Pro in Anthropic Messages format. Anthropic SDKs and Anthropic-compatible tools work unchanged.
Point an Anthropic client at base URL https://ostra.testrelic.ai/api (the SDK adds /v1/messages) with your Ostra key. The model you send is ignored: Ostra Pro always answers, and the response says ostra-pro.
Some Anthropic options are adapted: output_config.effort above medium runs as medium; tool_choice any or tool runs as auto, and none removes the tools; mid-conversation system messages are folded into the next user turn. Errors use the Anthropic error shape. count_tokens isn’t supported.
- Auth
x-api-key: $OSTRA_API_KEYorAuthorization: Bearer $OSTRA_API_KEY. Needs a Full-access key.- Rate limit
- Counts against your workspace's requests per minute.
- Cost
- Same rates as chat completions. Input is
input_tokens + cache_read_input_tokens + cache_creation_input_tokens;cache_read_input_tokensbill at the cached rate.
curl https://ostra.testrelic.ai/api/v1/messages \
-H "x-api-key: $OSTRA_API_KEY" \
-H 'Content-Type: application/json' \
-H 'anthropic-version: 2023-06-01' \
-H 'x-ostra-session: checkout-suite-run-42' \
-d '{
"model": "ostra-pro",
"max_tokens": 1024,
"system": "You are a senior test engineer. Answer briefly.",
"messages": [
{
"role": "user",
"content": "This Playwright test times out on CI but passes locally. Why, and how do I fix it?"
}
]
}'import os
import anthropic
client = anthropic.Anthropic(base_url="https://ostra.testrelic.ai/api", api_key=os.environ["OSTRA_API_KEY"])
message = client.messages.create(
model="ostra-pro",
max_tokens=1024,
system="You are a senior test engineer. Answer briefly.",
messages=[
{
"role": "user",
"content": "This Playwright test times out on CI but passes locally. Why, and how do I fix it?",
},
],
extra_headers={"x-ostra-session": "checkout-suite-run-42"},
)
# A thinking block can come before the answer: print the text blocks.
print("".join(block.text for block in message.content if block.type == "text"))import Anthropic from '@anthropic-ai/sdk';
const client = new Anthropic({ baseURL: 'https://ostra.testrelic.ai/api', apiKey: process.env.OSTRA_API_KEY });
const message = await client.messages.create({
model: 'ostra-pro',
max_tokens: 1024,
system: 'You are a senior test engineer. Answer briefly.',
messages: [
{
role: 'user',
content: 'This Playwright test times out on CI but passes locally. Why, and how do I fix it?',
},
],
}, { headers: { 'x-ostra-session': 'checkout-suite-run-42' } });
// A thinking block can come before the answer: print the text blocks.
for (const block of message.content) if (block.type === 'text') console.log(block.text);import os
import requests
response = requests.post(
"https://ostra.testrelic.ai/api/v1/messages",
headers={
"x-api-key": os.environ["OSTRA_API_KEY"],
"anthropic-version": "2023-06-01",
"x-ostra-session": "checkout-suite-run-42",
},
json={
"model": "ostra-pro",
"max_tokens": 1024,
"system": "You are a senior test engineer. Answer briefly.",
"messages": [
{
"role": "user",
"content": "This Playwright test times out on CI but passes locally. Why, and how do I fix it?",
},
],
},
timeout=60,
)
response.raise_for_status()
print(response.json())const response = await fetch('https://ostra.testrelic.ai/api/v1/messages', {
method: 'POST',
headers: {
'x-api-key': process.env.OSTRA_API_KEY!,
'Content-Type': 'application/json',
'anthropic-version': '2023-06-01',
'x-ostra-session': 'checkout-suite-run-42',
},
body: JSON.stringify({
model: 'ostra-pro',
max_tokens: 1024,
system: 'You are a senior test engineer. Answer briefly.',
messages: [
{
role: 'user',
content: 'This Playwright test times out on CI but passes locally. Why, and how do I fix it?',
},
],
}),
});
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",
"max_tokens": 1024,
"system": "You are a senior test engineer. Answer briefly.",
"messages": [
{
"role": "user",
"content": "This Playwright test times out on CI but passes locally. Why, and how do I fix it?"
}
]
}`)
req, err := http.NewRequest("POST", "https://ostra.testrelic.ai/api/v1/messages", body)
if err != nil {
panic(err)
}
req.Header.Set("x-api-key", os.Getenv("OSTRA_API_KEY"))
req.Header.Set("Content-Type", "application/json")
req.Header.Set("anthropic-version", "2023-06-01")
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",
"max_tokens": 1024,
"system": "You are a senior test engineer. Answer briefly.",
"messages": [
{
"role": "user",
"content": "This Playwright test times out on CI but passes locally. Why, and how do I fix it?"
}
]
}
""";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://ostra.testrelic.ai/api/v1/messages"))
.header("x-api-key", System.getenv("OSTRA_API_KEY"))
.header("Content-Type", "application/json")
.header("anthropic-version", "2023-06-01")
.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.Add("x-api-key", Environment.GetEnvironmentVariable("OSTRA_API_KEY"));
client.DefaultRequestHeaders.Add("anthropic-version", "2023-06-01");
client.DefaultRequestHeaders.Add("x-ostra-session", "checkout-suite-run-42");
using var request = new HttpRequestMessage(HttpMethod.Post, "https://ostra.testrelic.ai/api/v1/messages");
request.Content = new StringContent(
"""
{
"model": "ostra-pro",
"max_tokens": 1024,
"system": "You are a senior test engineer. Answer briefly.",
"messages": [
{
"role": "user",
"content": "This Playwright test times out on CI but passes locally. Why, and how do I fix it?"
}
]
}
""",
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/messages")
request = Net::HTTP::Post.new(uri)
request["x-api-key"] = ENV.fetch("OSTRA_API_KEY")
request["Content-Type"] = "application/json"
request["anthropic-version"] = "2023-06-01"
request["x-ostra-session"] = "checkout-suite-run-42"
request.body = <<~'JSON'
{
"model": "ostra-pro",
"max_tokens": 1024,
"system": "You are a senior test engineer. Answer briefly.",
"messages": [
{
"role": "user",
"content": "This Playwright test times out on CI but passes locally. Why, and how do I fix it?"
}
]
}
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/messages");
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
"x-api-key: " . getenv("OSTRA_API_KEY"),
"Content-Type: application/json",
"anthropic-version: 2023-06-01",
"x-ostra-session: checkout-suite-run-42",
],
CURLOPT_POSTFIELDS => <<<'JSON'
{
"model": "ostra-pro",
"max_tokens": 1024,
"system": "You are a senior test engineer. Answer briefly.",
"messages": [
{
"role": "user",
"content": "This Playwright test times out on CI but passes locally. Why, and how do I fix it?"
}
]
}
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
- request-id
- req_01JDXK4M7Q2N8R5T6V9W3Y1Z0A
- ostra-model-version
- 1.0
- ostra-cost-usd
- 0.00079318
- ostra-balance-remaining-usd
- 24.99920682
{
"id": "msg_01JDXKA2B3C4D5E6F7G8H9J0K1",
"type": "message",
"role": "assistant",
"model": "ostra-pro",
"content": [
{
"type": "thinking",
"thinking": "Timeout only on CI: likely slower runners or shared state between parallel tests…",
"signature": ""
},
{
"type": "text",
"text": "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."
}
],
"stop_reason": "end_turn",
"stop_sequence": null,
"usage": {
"input_tokens": 52,
"output_tokens": 170,
"cache_read_input_tokens": 0,
"cache_creation_input_tokens": 0
}
}{
"type": "error",
"error": {
"type": "overloaded_error",
"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.",
"ostra_type": "service_unavailable",
"retry_after_ms": 60000,
"state": "starting"
},
"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}$anthropic-versionstringAccepted and ignored, so SDK defaults work.
anthropic-betastringAccepted and ignored.
Request body
modelstringOptional and ignored: Ostra Pro answers whatever you send. Anthropic SDKs require one; use
ostra-pro.messagesarray of objectsRequiredThe conversation. Up to 8
imageblocks per request, including those insidetool_result.1–4,000 itemsShow 2 child fieldsHide child fields
rolestringRequiredWho wrote it.
systemmid-conversation is folded into the next user turn.One ofuserassistantsystemcontentstring or array of blocksRequiredText, or content blocks (
text,image,tool_use,tool_result,thinking).
systemstring or array of text blocksSystem prompt.
max_tokensintegerMost output tokens, thinking included. Above 32,768 is lowered to 32,768.
≥ 1default 8192streambooleanStream Anthropic events (
message_start,content_block_*,message_delta,message_stop).default falsetoolsarray of objectsTools in Anthropic format:
{ "name", "description", "input_schema" }.0–128 itemstool_choiceobject{ "type": "auto" }or{ "type": "none" }.anyandtoolrun asauto.thinkingobjectPassed through, e.g.
{ "type": "enabled", "budget_tokens": 2048 }.output_configobjecteffort:lowormedium(higher values run asmedium).temperaturenumberSampling temperature.
0 to 1metadataobjectPassed through.
Response
idstringMessage id.
typestringmessage.rolestringassistant.modelstringostra-pro.contentarray of objectsContent blocks:
thinking(when thinking is on),text,tool_use.stop_reasonstringend_turn,max_tokensortool_use.stop_sequencestring or nullThe stop sequence that ended the answer, if any.
usageobjectinput_tokens,output_tokens,cache_read_input_tokens,cache_creation_input_tokens.
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.
request-idstringSame as
x-request-id, under Anthropic’s name.ostra-model-versionstring1.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_error | Validation failed, or the model rejected the request. |
| 401 | authentication_error | Missing or invalid key. |
| 402 | billing_error | Balance too low, or a spend limit reached (ostra_type says which). |
| 403 | permission_error | IP not allowed, or a read-only key. |
| 413 | request_too_large | Body larger than 5.5 MB. |
| 429 | rate_limit_error | Rate limit reached. |
| 502 | api_error | Ostra Pro failed to answer. |
| 503 | overloaded_error | Ostra Pro is starting or at capacity. Retry after Retry-After. |
Every error has the same envelope and a request_id. See Errors for messages and retry advice.