Skip to main content

OpenAI-compatible inference

Every project has an OpenAI-compatible API, so any OpenAI client or SDK can call its models by changing the base URL and the key. The model you call can be a hosted model of the project, a finished training job, or a catalog base model. Base models can also be called without any project; see "Base models without a project" below.

Endpoints​

GET /api/projects/{owner_slug}/{project_slug}/openai/v1/models
POST /api/projects/{owner_slug}/{project_slug}/openai/v1/chat/completions
POST /api/projects/{owner_slug}/{project_slug}/openai/v1/completions
POST /api/projects/{owner_slug}/{project_slug}/openai/v1/embeddings

Point an OpenAI SDK at the project's base URL:

from openai import OpenAI

client = OpenAI(
base_url="https://reopenly.com/api/projects/<owner>/<project>/openai/v1",
api_key="<your ReOpenly API key>",
)

Install the JavaScript SDK with npm install openai; the JavaScript examples use await at the top level, so run them as an ES module. The examples below use this client.

GET /models returns the hosted models you can call:

{
"object": "list",
"data": [
{
"id": "support-assistant",
"object": "model",
"created": 1764547200,
"owned_by": "reopenly"
}
]
}

Use a returned id as model. The list does not include base models or training jobs: read GET /api/v1/base-models for the base catalog and address a base model by its id, such as ReOpenly/Qwen3.5-9B, and a finished job of a project you can access as training-job#<job-id>.

Base models without a project​

The catalog base models belong to no project, and any account can call them without creating one:

GET /api/openai/v1/models
POST /api/openai/v1/chat/completions
POST /api/openai/v1/completions
POST /api/openai/v1/embeddings
from openai import OpenAI

client = OpenAI(
base_url="https://reopenly.com/api/openai/v1",
api_key="<your ReOpenly API key>",
)

chat = client.chat.completions.create(
model="ReOpenly/Qwen3.5-9B",
messages=[{"role": "user", "content": "Hello"}],
)
vectors = client.embeddings.create(
model="ReOpenly/Qwen3-Embedding-0.6B",
input=["text to embed"],
)
  • GET /models lists the base models: ReOpenly/Qwen3.5-9B, ReOpenly/Qwen3-Embedding-0.6B and ReOpenly/Qwen3-Embedding-4B.
  • Each call is charged to your account, at the same rates as through a project.
  • Only base models are served here. A hosted model or a training job is called through its project's URL; naming one here answers model_not_found, the same as a model that does not exist.
  • Nothing is saved: inference auto-save is a project setting, so it applies only to calls made through a project.

Chat completions​

completion = client.chat.completions.create(
model="ReOpenly/Qwen3.5-9B",
messages=[{"role": "user", "content": "Give me one sentence about datasets."}],
max_tokens=512,
temperature=0.2,
)
print(completion.choices[0].message.content)

Request fields​

FieldWhat happens
model, messagesRequired. model is a hosted model's slug, a base model id, or training-job#<job-id>.
max_tokensAt least 1. null or omitted means 1024.
max_completion_tokensOpenAI's newer name for max_tokens. Send one of the two, or the same value in both.
temperatureFrom 0 to 2.
top_pFrom 0 to 1. 0 keeps only the most likely token.
stopA string, or up to 4 strings. Generation ends where the answer would first write one of them, which is left out, and finish_reason is stop.
seedA 64-bit integer. Repeating an identical request with the same seed tends to repeat the answer; it is not a guarantee.
presence_penalty, frequency_penaltyFrom -2 to 2, as in OpenAI.
response_formattext (the default), json_object or json_schema; see "JSON output" below.
toolsFunction tools, in OpenAI's format (see the limit below the table). When the model calls one, the answer has tool_calls and finish_reason: "tool_calls".
tool_choiceauto (the default) lets the model decide; none does not offer the tools to the model.
parallel_tool_callstrue (the default): the model may call several tools in one answer.
reasoning_effortSee "Reasoning" below.
stream, stream_options.include_usageSee "Streaming" below.
userAccepted and not used.

Any field not in this table or the next one is ignored, with no error.

Tool calls across turns. A single answer can call tools as described. When you send the conversation back with the results, the model does not see the calls it made: an assistant message's tool_calls, and a tool message's tool_call_id and name, are left out of the prompt, so only the result text reaches the model. A multi-step tool loop can therefore lose track of which result belongs to which call. Until this is fixed, put what the model needs from earlier calls into the message text.

Refused, never ignored. Some valid OpenAI values ask for something this API cannot do. They answer 400 with error.code unsupported_value and the field in error.param, before the model runs, with no charge. The same fields at their default values are accepted, so a client that always sends them keeps working:

FieldAcceptedRefused
n1Above 1: there is one choice per request.
logprobsfalsetrue
top_logprobs0Above 0
logit_bias{}Any entry
tool_choiceauto, nonerequired, or a named function
parallel_tool_callstruefalse while tools are sent
response_formattext, json_object, json_schemaAny other type; JSON output together with tools; JSON output with a reasoning_effort that turns reasoning on

A value outside its range (temperature above 2, max_tokens of 0, five stop sequences, max_tokens and max_completion_tokens with different values) answers 400 invalid_request, also with the field in error.param. Neither refusal goes away by retrying: change the request first.

The model itself applies stop, seed, the penalties and response_format. If the model serving your request cannot apply one of them at that moment, the request is refused with 400 unsupported_value naming it, rather than answered without it.

JSON output​

response_format: {"type": "json_object"} makes the answer a JSON object, and {"type": "json_schema", "json_schema": {"name": "...", "schema": {...}}} makes it JSON that matches your schema:

completion = client.chat.completions.create(
model="ReOpenly/Qwen3.5-9B",
messages=[{"role": "user", "content": "Name a color and its hex code."}],
response_format={"type": "json_object"},
)
print(completion.choices[0].message.content)

The JSON arrives as text in message.content, for you to parse. Reasoning is off for JSON output: an omitted reasoning_effort is treated as "none", and a value that turns reasoning on is refused. JSON output cannot be combined with tools. If max_tokens cuts the answer short (finish_reason: "length"), the JSON is incomplete.

The response is an OpenAI chat completion with choices, a finish reason, and usage. With the catalog base model reasoning by default, it looks like this:

{
"id": "chatcmpl-…",
"object": "chat.completion",
"created": 1764547200,
"model": "ReOpenly/Qwen3.5-9B",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "…",
"reasoning": "…",
"reasoning_content": "…"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 18,
"completion_tokens": 52,
"total_tokens": 70,
"reasoning_tokens": 40,
"cached_tokens": 0,
"completion_tokens_details": {"reasoning_tokens": 40}
}
}

Reading usage. Token counts come from the model when it reports them:

  • prompt_tokens, completion_tokens and total_tokens: when the model does not report a count, the field is 0. That 0 means "not measured", not zero tokens and not an estimate.
  • completion_tokens_details.reasoning_tokens is set only when the reasoning tokens were measured; otherwise completion_tokens_details is null (and absent from a stream's usage frame). With reasoning off it is a measured 0.
  • The top-level reasoning_tokens repeats that measured count for older clients and is 0 when it was not measured, so read completion_tokens_details instead.
  • cached_tokens is always 0: it is not measured. Do not read it as "no cache hits".

Defaults for omitted fields​

FieldApplied when omitted
max_tokens1024
temperature1.0
top_p1.0
streamfalse
reasoning_effortnothing: the model's own default

GET /api/v1/base-models publishes the same table as an inference block (defaults and capabilities), so a client can read it rather than hard-code it. The playground starts from that block, so a prompt typed there and the same prompt sent through this API are the same request.

reasoning_effort takes a string. "none" and "low" keep reasoning off; any other value (for example "high") turns it on. Omitting the field asks the model for whatever it does by default, so omitting it and sending "none" are different requests. The playground offers none, low and high, and its "model default" sends no field at all.

Reasoning​

When a model reasons before answering, the reasoning is returned separately from the answer:

  • message.content (and delta.content when streaming) carries only the answer.
  • message.reasoning carries the reasoning, and message.reasoning_content carries the same text, for clients that read that name. Streams send it in delta.reasoning and delta.reasoning_content.
  • usage.completion_tokens_details.reasoning_tokens reports how many completion tokens went into reasoning, when it was measured (see "Reading usage" above).

Defaults:

  • A fine-tuned model (a hosted alias or training-job#N) does not reason unless you ask: an omitted reasoning_effort is treated as "none".
  • The catalog base model reasons by default.
  • none and low turn reasoning off; any other value turns it on.

Reasoning uses max_tokens. If the limit is reached while the model is still reasoning, the response has finish_reason: "length", the reasoning, and no answer: raise max_tokens or send reasoning_effort: "none".

Streaming​

Set stream: true to receive text/event-stream frames. A successful stream ends with a finish chunk followed by:

data: [DONE]

Ask for the standard final usage chunk when you need it:

stream = client.chat.completions.create(
model="support-assistant",
messages=[{"role": "user", "content": "Summarize this."}],
stream=True,
stream_options={"include_usage": True},
)
for chunk in stream:
if chunk.choices:
print(chunk.choices[0].delta.content or "", end="")
elif chunk.usage:
print()
print(chunk.usage)

The usage frame has an empty choices array and a usage object. Not every frame carries a role or content: tool-call deltas and the finish frame have other shapes.

A request that fails before the stream starts gets the normal JSON error response. If generation fails after 200 OK and the stream headers were sent, the last frame is a JSON error envelope and the stream ends without [DONE]. See Errors and retries.

Legacy completions​

POST /completions accepts a string or a list of strings in prompt and returns one OpenAI text_completion. A list is joined with spaces and treated as one prompt; it does not produce one choice per prompt, so send separate requests when you need that. It takes model, prompt, max_tokens, temperature, top_p, reasoning_effort, stop, seed, presence_penalty and frequency_penalty, with the same ranges and handling as chat completions. user is accepted and not used, and unknown fields are ignored.

It does not stream: stream: true answers 400 unsupported_value, so use chat completions to stream. It returns one completion without log probabilities, so n or best_of above 1, logprobs, echo: true, a non-empty suffix and a non-empty logit_bias are refused the same way. It also does not separate reasoning from the answer, and a fine-tuned model is not switched to "none" when reasoning_effort is omitted, so text can include the model's reasoning. Send reasoning_effort: "none" when you want only the answer, or use chat completions.

Embeddings​

POST /embeddings serves an embedding project's hosted embedding models.

response = client.embeddings.create(
model="citation-embedding",
input=["A short passage to embed.", "A second passage."],
extra_body={"input_type": "document"},
)
print(len(response.data), len(response.data[0].embedding))

The request takes a non-empty string or list of strings, float or base64 encoding (base64, which the official OpenAI Python SDK requests by default, returns little-endian float32 bytes, base64-encoded), the model's vector size as dimensions, and the optional input_type query or document. A trained model with a query_instruction applies it to queries only.

An empty input list (input: []) is refused with 400 invalid_request and error.param="input" before tokenization or model execution, without a charge. This applies to both project-scoped and project-less embedding requests.

Limits. Each input may be up to 512 tokens. A model you trained with max_seq_length 1024 or 2048 accepts inputs up to that length; a model trained at 512 or less keeps 512. A request may carry up to 64 inputs and 32,768 tokens in total. The model itself embeds a limited batch at a time (max_batch_items and max_batch_tokens in GET /api/v1/base-models: 16 inputs and 8,192 tokens for the 0.6B base, 8 inputs and 4,096 tokens for the 4B base), so a larger request is split into batches on the server and answered as one response, with the vectors in input order. It is charged once, for the input tokens of all its batches, and only when every batch succeeded: a request that fails part-way is not charged. Splitting saves you the re-batching; it does not make the model faster than sending the same batches yourself. The input limit is separate from the output size: the 0.6B base returns a 1,024-dimensional vector whatever the input length. An input over its limit, or a request over 64 inputs or 32,768 tokens, answers 400 invalid_request with error.param="input" and no Retry-After: split or shorten it, because retrying it unchanged will not help.

A value of the wrong type or shape answers 422 with detail (unknown fields are ignored); a well-formed but unsupported dimensions answers 400 invalid_request with error.param="dimensions". An inactive or unknown model answers 404, and a project without embeddings answers 409.

By default an input over the limit is refused with 400, as OpenAI does. Set truncate: true to cut each over-limit input to the limit instead: the end of the text is removed, exactly as the models were trained, and the item is marked "truncated": true. A truncated input fills the whole input budget, so send it in a request of its own. The truncated field is present only when an input was shortened; an omitted field means false. From the OpenAI Python SDK:

response = client.embeddings.create(
model="citation-embedding",
input=["A long document. " * 600],
extra_body={"truncate": True},
)
print(getattr(response.data[0], "truncated", False))

The response keeps input order:

{
"object": "list",
"data": [
{"object": "embedding", "embedding": [0.01, -0.02], "index": 0}
],
"model": "citation-embedding",
"usage": {"prompt_tokens": 12, "total_tokens": 12}
}

Timeouts and capacity. A model that has been idle can take a moment to answer its first request, so set a client timeout of at least 60 seconds. If the model cannot answer within that time, or more requests arrive at once than it can take, the response is 503 capacity_unavailable with Retry-After; see the retry policy. After a long quiet period, starting the model can occasionally take several minutes, so keep retrying. Every response is checked before it is returned (vector count, size, order and usage), and a request is charged at most once, even when it is retried internally. A request refused with capacity_unavailable or artifact_not_ready (the model is starting, busy or still loading) is not charged.

Embedding calls are never saved into a dataset. ReOpenly does not keep the request text or the returned vectors as training data: a vector cannot say which passage answered a query, so it would be half a training pair at best. To build training pairs from real searches, report them through Search feedback. To try a model interactively or rank a dataset with it, see Playground and Search.

Context limits​

A chat request must fit the model's context: max_context_tokens from GET /api/v1/base-models (4,096 for Qwen3.5 9B), counting both the prompt and max_tokens. The check happens before the model runs, and a request that does not fit answers invalid_request. Read the limit from the catalog rather than from this page, and leave room for max_tokens.

When the model is starting, and client timeouts​

Text models stop when idle, so the first request after a quiet period starts the model again and can take a few minutes to answer. A request either starts answering within 4 minutes (a stream sends its first token) or fails with 503 model_warming and a Retry-After header, uncharged. Set your client timeout to at least 5 minutes, and when you get model_warming, follow the retry policy.

Billing and retries​

A request is charged only after the model has run it, and a failed request is not charged. If you close a streamed response before it ends, its prompt and the output tokens generated until then are charged; closed before its first token arrives, it is not charged. If ReOpenly ends it, for example by answering 503 model_warming at the time limit above, it is not charged: a request refused while the model is warming up or busy is never charged.

Inference is charged per token: input (prompt) tokens and output tokens each at the model's price per million tokens, from the model's own counts, rounded up to the next $0.000001 per request. Reasoning tokens are output tokens and are part of completion_tokens. A request is never charged less than the per-request minimum, $0.00001 (minimum_credits_per_request), and time in a queue or with the model idle costs nothing. The prices are in GET /api/v1/pricing/platform (inference_prices); a hosted fine-tuned model pays its base's prices times fine_tuned_multiplier. See How inference is billed.

When to retry is defined once, in the retry policy. In short: retry only a response that carries Retry-After. An ambiguous_transport response may mean the request was served, so a blind retry can duplicate work and billing.

The playground​

The playground keeps the original conversation, makes at most three automatic retries after the original request, and then leaves a manual Retry. It never retries an error that arrives mid-stream. It stores the project in the page URL (/app/playground?project=owner/project) and calls the same project API shown above.