Skip to content
OpenRelay is in early access, and the /v1 API is stable. New capabilities ship in the changelog.
API ReferenceInferenceMessages

Generate a message (Anthropic-compatible)

Generates a model response in the Anthropic Messages shape, a drop-in for the Anthropic SDKs and Claude Code on models that support messages. Messages is a second online family alongside Chat Completions; check a model's supported_apis on GET /v1/models before calling it rather than assuming. Requires a funded balance. Send the API key as x-api-key (the Anthropic SDK convention) or as Authorization Bearer; either is accepted. Set "stream" to true for event-typed Server-Sent Events (message_start, content_block_delta, message_stop, and so on). The request body is capped at 10 MiB.

Required permission

Requires the inference.invoke permission. See Permissions for the roles and API key permissions that include it.

Command line

The orl CLI wraps this endpoint:

orl messages create --max-tokens <max-tokens> --messages <messages> --model <model>
POST
/v1/messages

Authorization

apiKey
headerAuthorizationBearer <token>

OpenRelay API key. Send it as Authorization: Bearer or_… (legacy vl_… keys still work).

Request Body

application/json
  1. body

An Anthropic-compatible Messages request. Opaque: unlisted Anthropic parameters (temperature, top_p, stop_sequences, tools, tool_choice, ...) are forwarded as sent.

model*string

An OpenRelay public model id, e.g. openrelay/glm-5.2.

max_tokens*integer

Upper bound on tokens to generate. Required (unlike Chat Completions).

messages*array<>

The conversation so far: {role, content} objects (user, assistant only; use the top-level system field for a system prompt).

system?string

The system prompt, as a top-level field.

stream?boolean

Stream the response as event-typed Server-Sent Events.

[key: string]?any

Response Body

OK

  1. response

An Anthropic message object (opaque; additionalProperties carries the rest of the dialect).

id?string
type?"message"
Value in"message"
role?"assistant"
Value in"assistant"
model?string

Always the public OpenRelay model id requested.

content?array<>
stop_reason?string
usage?
openrelay?

What the request is billed, on every online inference response.

[key: string]?any
Example Request
curl -X POST 'https://inference.openrelay.inc/v1/messages' \  -H 'Content-Type: application/json' \  -d '{  "model": "string",  "max_tokens": 0,  "messages": [    {}  ]}'
Example Response
{  "id": "string",  "type": "message",  "role": "assistant",  "model": "string",  "content": [    {}  ],  "stop_reason": "string",  "usage": {},  "openrelay": {    "cost_nano_usd": 0,    "priced_at": "string"  }}