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/completionsRequires 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:
| Field | Type | Description |
|---|---|---|
model | string (required) | An OpenRelay public model id, e.g. openrelay/gpt-oss-120b. See Models. |
messages | array (required) | The conversation so far — a list of { "role": "system" | "user" | "assistant", "content": "…" } objects. |
Common OpenAI sampling and control parameters are supported, including:
| Field | Type | Description |
|---|---|---|
max_completion_tokens | integer | Upper bound on the number of tokens to generate. |
temperature | number | Sampling temperature. Higher is more random. |
top_p | number | Nucleus-sampling probability mass. |
stop | string or array | Sequence(s) that halt generation. |
presence_penalty | number | Penalize tokens by whether they've appeared. |
frequency_penalty | number | Penalize tokens by how often they've appeared. |
seed | integer | Best-effort deterministic sampling. |
stream | boolean | Stream the response as Server-Sent Events. See Streaming. |
stream_options | object | Streaming 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 }
}
}| Field | Description |
|---|---|
id | Unique id for this completion. |
model | Always the public OpenRelay model id you requested. |
choices | The generated message(s) and each one's finish_reason. |
usage | Token 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.