The /v1/completions endpoint provides the OpenAI legacy text completions interface. Instead of a messages array, you pass a single prompt string and receive a generated completion. Rolter proxies the request to the upstream target selected by the named route, applying the same authentication, load balancing, and param injection as every other inference endpoint.
For most use cases, prefer /v1/chat/completions. The chat interface is the current OpenAI standard and is supported across all provider kinds (OpenAI, Anthropic, and OpenAI-compatible). This endpoint exists for backward compatibility with legacy clients and tooling that predate the chat format.
Request#
POST /v1/completions
Headers#
Must be application/json.
Body#
The route name defined in your rolter.toml. Rolter rewrites this to the upstream model ID before forwarding. Returns 404 if no matching route exists.
The text prompt the model completes. Unlike the chat endpoint, this is a plain string rather than a structured messages array.
Maximum number of tokens to generate in the completion. Many upstream providers require this field for the legacy endpoint; check your upstream’s documentation.
Set to true to receive the completion as a Server-Sent Events stream. Each event carries a delta chunk; the stream terminates with data: [DONE].
Default: "false"
Sampling temperature between 0 and 2. Passed through to the upstream and subject to the route’s param_policy.
One or more sequences at which the model stops generating.
Nucleus sampling probability mass.
Example#
Response#
A successful non-streaming response follows the standard OpenAI completions shape:
Unique identifier for this completion, prefixed with cmpl-.
Array of completion choices. Each entry contains:
Token counts for the request.