Create a message

POST /api/v1/messages — Ostra Pro in Anthropic Messages format, for Anthropic SDKs and Anthropic-compatible tools.

POSThttps://ostra.testrelic.ai/api/v1/messages

Sends 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_KEY or Authorization: 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_tokens bill 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?"
      }
    ]
  }'
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
  }
}

Request headers

  • x-ostra-sessionstring

    Optional. 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-versionstring

    Accepted and ignored, so SDK defaults work.

  • anthropic-betastring

    Accepted and ignored.

Request body

  • modelstring

    Optional and ignored: Ostra Pro answers whatever you send. Anthropic SDKs require one; use ostra-pro.

  • messagesarray of objectsRequired

    The conversation. Up to 8 image blocks per request, including those inside tool_result.

    1–4,000 items
    Show 2 child fields
    • rolestringRequired

      Who wrote it. system mid-conversation is folded into the next user turn.

      One ofuserassistantsystem
    • contentstring or array of blocksRequired

      Text, or content blocks (text, image, tool_use, tool_result, thinking).

  • systemstring or array of text blocks

    System prompt.

  • max_tokensinteger

    Most output tokens, thinking included. Above 32,768 is lowered to 32,768.

    ≥ 1default 8192
  • streamboolean

    Stream Anthropic events (message_start, content_block_*, message_delta, message_stop).

    default false
  • toolsarray of objects

    Tools in Anthropic format: { "name", "description", "input_schema" }.

    0–128 items
  • tool_choiceobject

    { "type": "auto" } or { "type": "none" }. any and tool run as auto.

  • thinkingobject

    Passed through, e.g. { "type": "enabled", "budget_tokens": 2048 }.

  • output_configobject

    effort: low or medium (higher values run as medium).

  • temperaturenumber

    Sampling temperature.

    0 to 1
  • metadataobject

    Passed through.

Response

  • idstring

    Message id.

  • typestring

    message.

  • rolestring

    assistant.

  • modelstring

    ostra-pro.

  • contentarray of objects

    Content blocks: thinking (when thinking is on), text, tool_use.

  • stop_reasonstring

    end_turn, max_tokens or tool_use.

  • stop_sequencestring or null

    The stop sequence that ended the answer, if any.

  • usageobject

    input_tokens, output_tokens, cache_read_input_tokens, cache_creation_input_tokens.

Response headers

  • x-request-idstring

    Id of this request (req_ + 26 characters). Quote it to support.

  • ostra-ratelimit-requests-limitinteger

    Your workspace’s requests-per-minute limit.

  • ostra-ratelimit-requests-remaininginteger

    Requests left in the current minute.

  • ostra-ratelimit-requests-resetinteger

    Seconds until the current minute ends and the count resets.

  • request-idstring

    Same as x-request-id, under Anthropic’s name.

  • ostra-model-versionstring

    1.0.

  • ostra-cost-usdstring

    Non-streaming only: what this request cost.

  • ostra-balance-remaining-usdstring

    Workspace credit balance after this request, in USD. Approximate under concurrent requests.

Errors

StatusTypeWhen
400invalid_request_errorValidation failed, or the model rejected the request.
401authentication_errorMissing or invalid key.
402billing_errorBalance too low, or a spend limit reached (ostra_type says which).
403permission_errorIP not allowed, or a read-only key.
413request_too_largeBody larger than 5.5 MB.
429rate_limit_errorRate limit reached.
502api_errorOstra Pro failed to answer.
503overloaded_errorOstra 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.

Was this page helpful?