OP Inference
API reference

Create a chat completion

POST
/v1/chat/completions

Send a conversation and get a reply. Set stream to true for server-sent events. A request can fail over to another endpoint only before the first content token; after that the stream ends with a terminal frame instead.

Authorization

bearerAuth
headerAuthorizationBearer <token>

Your API key, sent as Authorization: Bearer <key>.

Header Parameters

Idempotency-Key?string

Any string you choose. A retry with the same key and body returns the first result instead of running again. The same key with a different body is a 409 idempotency_conflict.

x-op-metadata?"enabled"

Set to enabled to receive op_metadata (cost, retention class, region, policy notes) with the response.

Value in"enabled"

Request Body

application/json
  1. body
model*string

The model id, in author/slug form.

models?array<string>

Fallback models, tried in order if the first cannot serve. Only with this list may another model answer.

Itemsitems <= 5
messages*array<>
stream?boolean
Defaultfalse
max_tokens?integer
max_completion_tokens?integer
temperature?number
tools?array<>

OpenAI tool definitions.

response_format?

{"type": "json_object"} or {"type": "json_schema", ...} as in the OpenAI API.

provider?

How the request is routed. Each option can only narrow it.

op?

Response Body

The reply. JSON when stream is false, server-sent events when it is true.

  1. response
id?string
object?string
created?integer
model?string
choices?array<>
usage?
curl -X POST "https://example.com/v1/chat/completions" \  -H "Authorization: Bearer $OP_API_KEY" \  -H "Content-Type: application/json" \  -d '{    "model": "openai/gpt-oss-120b",    "messages": [      {        "role": "user",        "content": "Say hello in one sentence."      }    ]  }'
{  "id": "string",  "object": "chat.completion",  "created": 0,  "model": "string",  "choices": [    {      "index": 0,      "message": {},      "finish_reason": "string"    }  ],  "usage": {    "prompt_tokens": 0,    "completion_tokens": 0,    "total_tokens": 0  }}