Completions (legacy)
Menu
Text & embeddings

Completions (legacy)

Generate text from a single prompt with the legacy OpenAI Completions API.

POST /v1/completions

The legacy OpenAI Completions API: the model continues a plain-text prompt. It is kept for older tools and for models that only support completion-style input (e.g. gpt-3.5-turbo-instruct, code completion with suffix).

For new projects use Chat Completions or Responses — most current models do not support this endpoint.

Authentication

Authorization: Bearer sk-xxxx

Request body

Parameter Type Required Description
model string Yes Model ID, e.g. gpt-3.5-turbo-instruct.
prompt string | array Yes Prompt text, or an array of prompts.
suffix string No Text that follows the completion (fill-in-the-middle).
max_tokens integer No Maximum number of tokens to generate. Default 16.
temperature number No Sampling temperature, 0–2.
top_p number No Nucleus sampling, 0–1.
n integer No Number of completions per prompt.
stop string | array No Up to 4 stop sequences.
presence_penalty number No -2.0–2.0.
frequency_penalty number No -2.0–2.0.
logprobs integer No Return log probabilities of the top N tokens.
seed integer No Best-effort deterministic sampling.
stream boolean No Stream as SSE, ending with data: [DONE]. See Streaming.
stream_options object No {"include_usage": true} adds a final usage chunk.
user string No Stable end-user identifier.

Request example

cURL
curl https://rutoken.ai/v1/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $API_KEY" \
  -d '{
    "model": "gpt-3.5-turbo-instruct",
    "prompt": "Write a tagline for a coffee shop:",
    "max_tokens": 30,
    "temperature": 0.8
  }'
Python
from openai import OpenAI

client = OpenAI(base_url="https://rutoken.ai/v1", api_key="sk-xxxx")
resp = client.completions.create(
    model="gpt-3.5-turbo-instruct",
    prompt="Write a tagline for a coffee shop:",
    max_tokens=30,
    temperature=0.8,
)
print(resp.choices[0].text)
Node.js
import OpenAI from "openai";

const client = new OpenAI({ baseURL: "https://rutoken.ai/v1", apiKey: "sk-xxxx" });
const resp = await client.completions.create({
  model: "gpt-3.5-turbo-instruct",
  prompt: "Write a tagline for a coffee shop:",
  max_tokens: 30,
  temperature: 0.8,
});
console.log(resp.choices[0].text);

Response

json
{
  "id": "cmpl-9xYz",
  "object": "text_completion",
  "created": 1760000000,
  "model": "gpt-3.5-turbo-instruct",
  "choices": [
    {
      "text": " Brewed with love, served with a smile.",
      "index": 0,
      "logprobs": null,
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 9,
    "completion_tokens": 10,
    "total_tokens": 19
  }
}
Field Type Description
choices[].text string Generated text.
choices[].finish_reason string stop or length.
usage object Token counts used for billing.