OpenAI-compatible

Completions (legacy)

Use the Privatemode completions API to generate text from a prompt via a large language model. The API is compatible with the legacy OpenAI Completions API. It's deprecated in favor of the chat completions API. To generate text, send your requests to the Privatemode proxy. Completion requests and responses are encrypted, both in transit and during processing.

POST/v1/completions

Request body

modelstringrequired

The name of a currently available model. Note that models are updated regularly, and support for older models is discontinued over time. Use the models API to list available models.

promptstring or listrequired

The prompts for which a response is generated. Completion prompts must follow the format the target model was trained on. You can find the required format in the model's source data (for example, in its chat template on Hugging Face). In particular, for gpt-oss models you must use the Harmony format.

streambooleandefault: false

Whether to stream the response as server-sent events. The SDKs return an iterator over the response chunks.

cache_saltstring

Opts this request into prompt caching: all requests that use the same salt share a cache, reducing response latency when the first part of a prompt is reused across requests. Keep salts private and use at least 256 bits of entropy, e.g. generated with openssl rand -base64 32. If caching is also configured in the Privatemode proxy, the value from the request takes precedence. With the OpenAI Python client, pass cache_salt via the extra_body argument.

Additional parameters mirror the OpenAI API and are supported based on the model server's capabilities.

Returns

The response is a completion object or a sequence of completion objects.

idstring

A unique identifier for the completion.

objectstring

Always "text_completion".

createdinteger

The Unix timestamp (in seconds) of when the completion was created.

modelstring

The model used.

choiceslist

The responses generated by the model.

Show properties

indexinteger

The index of the choice in the list.

textstring

The generated text.

finish_reasonstring

The reason the model stopped generating, e.g. "stop".

usageobject

Token usage statistics.

Show properties

prompt_tokensinteger

The number of tokens in the prompt.

completion_tokensinteger

The number of generated tokens.

total_tokensinteger

The total number of tokens.

Other fields are consistent with the OpenAI API specifications.