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

Chat Completions

POST /v1/chat/completions — the OpenAI-compatible chat completions endpoint, its request parameters, and response shape.

Generate a model response for a conversation.

POST https://inference.openrelay.inc/v1/chat/completions

Requires an API key (see Authentication) and a funded balance (see Pricing & billing). Send Content-Type: application/json.

Request

The body is OpenAI-compatible. Only two fields are required:

FieldTypeDescription
modelstring (required)An OpenRelay public model id, e.g. openrelay/gpt-oss-120b. See Models.
messagesarray (required)The conversation so far — a list of { "role": "system" | "user" | "assistant", "content": "…" } objects.

Common OpenAI sampling and control parameters are supported, including:

FieldTypeDescription
max_completion_tokensintegerUpper bound on the number of tokens to generate.
temperaturenumberSampling temperature. Higher is more random.
top_pnumberNucleus-sampling probability mass.
stopstring or arraySequence(s) that halt generation.
presence_penaltynumberPenalize tokens by whether they've appeared.
frequency_penaltynumberPenalize tokens by how often they've appeared.
seedintegerBest-effort deterministic sampling.
streambooleanStream the response as Server-Sent Events. See Streaming.
stream_optionsobjectStreaming options, e.g. { "include_usage": true }.

Other OpenAI-compatible parameters are generally supported as well. Unsupported parameters are ignored rather than rejected.

Example request

curl https://inference.openrelay.inc/v1/chat/completions \
  -H "Authorization: Bearer $OPENRELAY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openrelay/gpt-oss-120b",
    "messages": [
      { "role": "system", "content": "You are a terse assistant." },
      { "role": "user", "content": "Name three primary colors." }
    ],
    "max_completion_tokens": 64,
    "temperature": 0.2
  }'

Response

A unary (non-streaming) response is an OpenAI chat.completion object:

{
  "id": "chatcmpl-…",
  "object": "chat.completion",
  "created": 1750000000,
  "model": "openrelay/gpt-oss-120b",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Red, green, and blue."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 24,
    "completion_tokens": 7,
    "total_tokens": 31,
    "prompt_tokens_details": { "cached_tokens": 0 }
  }
}
FieldDescription
idUnique id for this completion.
modelAlways the public OpenRelay model id you requested.
choicesThe generated message(s) and each one's finish_reason.
usageToken counts for the request. See Pricing & billing.

Response model id

The model field in the response is always the public OpenRelay id you sent.

Streaming

Set "stream": true to receive the completion incrementally as Server-Sent Events. The final event carries the usage object, followed by a data: [DONE] sentinel. See Streaming for the full format.

Limits

The request body is capped at 10 MiB; a larger body is rejected with 413 Payload Too Large. See Errors.

On this page