Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Create completion

Generate a text completion for the given prompt, following the OpenAI Completions API wire format.

Set stream: true to receive a Server-Sent Events stream. Each event carries a text_completion chunk object. When stream_options.include_usage is true, the final chunk before [DONE] includes a usage field with token counts.

post
Authorizations
AuthorizationstringRequired

Please provide header value as 'Bearer ' and don't forget to add 'Bearer' HTTP Authorization Scheme before the token.

Body

Request body for POST /v1/completions (OpenAI Completions API).

modelstringRequired

ID of the model to use.

Example: meta-llama/Llama-3.3-70B-Instruct
promptone ofRequired

The prompt to generate completions for. Either a single string, or an array of strings to complete independently in one request. The response then carries one choice per prompt, in the order given.

The model continues the prompt as plain text, without a chat template. A model that only works in its own chat format, for example openai/gpt-oss-120b, rarely stops on its own when given a plain prompt and generates until max_tokens. Use /v1/chat/completions for such a model.

Example: Once upon a time
stringOptional
or
string[] · min: 1Optional
temperaturenumber · max: 2Optional

Sampling temperature between 0 and 2. Higher values produce more random output.

top_pnumber · max: 1Optional

Nucleus sampling probability mass, greater than 0 and at most 1. A value outside that range, including exactly 0, is rejected with a 400.

ninteger · min: 1Optional

Number of completions to generate. When omitted, the model chooses.

streambooleanOptional

If true, stream partial results as Server-Sent Events.

Default: false
stopone ofOptional

Up to 4 sequences at which generation stops.

stringOptional
or
string[] · max: 4Optional
max_tokensinteger · min: 1Optional

Maximum number of tokens to generate. When omitted, the model chooses. The models in the catalog stop after 16 tokens, as OpenAI's completions API does.

presence_penaltynumber · min: -2 · max: 2Optional

Penalize tokens that have appeared so far in the text.

frequency_penaltynumber · min: -2 · max: 2Optional

Penalize tokens based on their frequency in the text.

userstringOptional

Opaque identifier for your end user.

logprobsinteger · nullableOptional

Include the log probabilities of this many most-likely tokens, when set.

suffixstringOptional

Text to append after the completion. Support is model-specific.

seedintegerOptional

Seed for deterministic sampling. Repeated requests with the same seed and parameters return the same completion on a best-effort basis. Support is model-specific.

echobooleanOptional

If true, the prompt is echoed back at the start of the generated text. Support is model-specific.

Responses
200

Successful operation. Returns CompletionResponse for non-streaming requests, or a text/event-stream of completion chunks when stream: true.

post/v1/completions
POST /v1/completions HTTP/1.1
Host: openai.inference.de-txl.ionos.com
Authorization: Bearer YOUR_SECRET_TOKEN
Content-Type: application/json
Accept: */*
Content-Length: 108

{
  "model": "meta-llama/Llama-3.3-70B-Instruct",
  "prompt": "Once upon a time",
  "max_tokens": 100,
  "temperature": 0.7
}
{
  "id": "cmpl-abc123",
  "object": "text_completion",
  "created": 1700000000,
  "model": "meta-llama/Llama-3.3-70B-Instruct",
  "choices": [
    {
      "text": " there lived a brave knight",
      "index": 0,
      "finish_reason": "stop",
      "logprobs": null
    }
  ],
  "usage": {
    "prompt_tokens": 5,
    "completion_tokens": 7,
    "total_tokens": 12
  }
}

Last updated

Was this helpful?