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.
Please provide header value as 'Bearer ' and don't forget to add 'Bearer' HTTP Authorization Scheme before the token.
Request body for POST /v1/completions (OpenAI Completions API).
ID of the model to use.
meta-llama/Llama-3.3-70B-InstructThe 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.
Once upon a timeSampling temperature between 0 and 2. Higher values produce more random output.
Nucleus sampling probability mass, greater than 0 and at most 1. A value outside that range, including exactly 0, is rejected with a 400.
Number of completions to generate. When omitted, the model chooses.
If true, stream partial results as Server-Sent Events.
falseUp to 4 sequences at which generation stops.
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.
Penalize tokens that have appeared so far in the text.
Penalize tokens based on their frequency in the text.
Opaque identifier for your end user.
Include the log probabilities of this many most-likely tokens, when set.
Text to append after the completion. Support is model-specific.
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.
If true, the prompt is echoed back at the start of the generated text. Support is model-specific.
Successful operation. Returns CompletionResponse for non-streaming requests, or a
text/event-stream of completion chunks when stream: true.
Bad Request
The request sent to the API was malformed.
Unauthorized
The request is missing authorization information or the authorization information provided are expired.
Forbidden
The user issuing the request does not have the needed permissions.
Not Found
The requested model or endpoint does not exist. A model that exists but lacks the capability the request needs is rejected with a 400 instead.
Payload Too Large
The request exceeds a size limit. The request body is limited to 16 MiB, an inline
base64 data URI to 12 MiB decoded, and an uploaded image or mask to 10 MiB. On
/v1/chat/completions, /v1/embeddings, and /v1/rerank, a message, query, or
document is limited to 2048 content parts. Count limits, such as the number of
documents, are stated with each field. Pass large media as a remote HTTP or HTTPS URL
instead of inline base64: a URL does not count against the size limits, though it
still counts as a content part.
Unprocessable Entity
The request was well-formed but contains semantic errors.
Too Many Requests
Your contract's rate limit is exhausted. Wait the number of seconds in Retry-After
before retrying, rather than a delay of your own. The OpenAI SDKs do this
automatically. Limits are contract-specific.
Internal Server Error
The request could not be completed because of an internal error. The request was
not necessarily rejected, so a retry is safe for idempotent calls. If it persists,
quote the value of the X-Request-Id response header when contacting support.
Bad Gateway
The model could not be reached, or stopped before it finished answering. No partial answer is returned in its place, and nothing is billed for it. Retrying is reasonable. An image or video URL in the request whose host cannot be reached, times out or answers with a server error is also answered this way.
Service Overloaded (503)
Too many large requests are already being handled at once. This applies only
to a request above a size threshold, or one sent with chunked transfer
encoding. An ordinary-sized request is never refused this way. Always retry
using the Retry-After header, not a fixed delay, to avoid a synchronized
retry storm. For sustained traffic in media, keep individual requests small:
pass large media in a JSON body as a remote HTTP or HTTPS URL rather than
inline base64, and keep a file upload small, for example by sending audio in
a compressed format such as MP3 or Opus. The message gives the advice that
fits how the request was sent.
Gateway Timeout
The model did not answer within the time allowed for it. The request may
have reached the model and may even have been served, so a retry is only safe for
idempotent calls. Retrying the same request unchanged tends to time out again: the
work itself is usually what was too slow, so prefer a smaller request (fewer or
smaller images, a shorter prompt, a lower n) or a model that can serve it.
Capacity Exhausted (529)
The service is temporarily overloaded. This is a non-standard status,
matching the convention used by other LLM providers for the same
condition: capacity is exhausted, not a client error (429) and not an
outage (503). error.code distinguishes a per-user throttle
(user_overloaded) from a system-wide capacity shortage
(server_overloaded). If you check only the status, treat both
alike. Always retry using the Retry-After header, not a
fixed delay, to avoid a synchronized retry storm.
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?